您好,欢迎访问一九零五行业门户网

linux桥接模式下配置静态ip的方法

本文主要和大家分享linux桥接模式下配置静态ip的方法,希望能帮助到大家。
一:桥接模式
vmware桥接模式,也就是将虚拟机的虚拟网络适配器与主机的物理网络适配器进行交接,虚拟机中的虚拟网络适配器可通过主机中的物理网络适配器直接访问到外部网络,简而言之,这就好像在局域网中添加了一台新的、独立的计算机一样。因此,虚拟机也会占用局域网中的一个ip地址,并且可以和其他终端进行相互访问。桥接模式网络连接支持有线和无线主机网络适配器。如果你想把虚拟机当做一台完全独立的计算机看待,并且允许它和其他终端一样的进行网络通信,那么桥接模式通常是虚拟机访问网络的最简单途径。
二:设置网络适配器
三:修改配置文件,设置静态ip
1:查看网卡接口名称  ifconfig | more 或者 ip addr | more
[root@localhost ~]# ifconfig | more eth0 link encap:ethernet hwaddr 00:0c:29:5a:71:6d inet addr:192.168.1.123 bcast:192.168.1.255 mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe5a:716d/64 scope:link up broadcast running multicast mtu:1500 metric:1 rx packets:5631 errors:0 dropped:0 overruns:0 frame:0 tx packets:324 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:398905 (389.5 kib) tx bytes:27775 (27.1 kib) lo link encap:local loopback inet addr:127.0.0.1 mask:255.0.0.0 inet6 addr: ::1/128 scope:host up loopback running mtu:16436 metric:1 rx packets:230 errors:0 dropped:0 overruns:0 frame:0 tx packets:230 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 rx bytes:19722 (19.2 kib) tx bytes:19722 (19.2 kib)
2:编辑网卡文件 vim /etc/sysconfig/network-scripts/ifcfg-eth0
如上图所示,我的网卡名称是eth0,那么对应的文件名称就是ifcfg-eth0
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 device=eth0 #网卡接口名称 bootproto=dhcp #系统启动地址协议 dhcp:dhcp动态地址协议 static:静态地址协议 hwaddr=00:0c:29:5a:71:6d ipv6init=yes nm_controlled=yes onboot=yes #系统启动时是否激活网卡接口 type=ethernet uuid="793813e9-4cbd-4ae1-a1de-f9f38b8369ee" userctl=no peerdns=yes
修改bootproto和onboot选项
bootproti=static
onboot=yes
然后在文件中添加如下内容
ipaddr=192.168.1.123 #静态ip,添加前先ping一下该ip,ping不通才能使用,确保唯一 netmask=255.255.255.0 #子网掩码 gateway=192.168.1.1 #网关
完整版配置文件如下
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 device=eth0 bootproto=static hwaddr=00:0c:29:5a:71:6d ipv6init=yes nm_controlled=yes onboot=yes type=ethernet uuid="793813e9-4cbd-4ae1-a1de-f9f38b8369ee" userctl=no peerdns=yes ipaddr=192.168.1.123 netmask=255.255.255.0 gateway=192.168.1.1
3:重启网络 service network restart
[root@localhost desktop]# service network restart shutting down interface eth0: [ ok ] shutting down loopback interface: [ ok ] bringing up loopback interface: [ ok ] bringing up interface eth0: active connection state: activating active connection path: /org/freedesktop/networkmanager/activeconnection/9 state: activated connection activated [ ok ]
四:本机打开cmd进行测试 ping 192.168.1.123
c:\windows\system32>ping 192.168.1.123 正在 ping 192.168.1.123 具有 32 字节的数据: 来自 192.168.1.123 的回复: 字节=32 时间=6ms ttl=64 来自 192.168.1.123 的回复: 字节=32 时间=30ms ttl=64 来自 192.168.1.123 的回复: 字节=32 时间=8ms ttl=64 来自 192.168.1.123 的回复: 字节=32 时间=8ms ttl=64
相关推荐:
php设计模式之桥接模式详解
以上就是linux桥接模式下配置静态ip的方法的详细内容。
其它类似信息

推荐信息