-
[
root
@localhost ~]# cd /etc/sysconfig/network-scripts/
-
[
root
@localhost network-scripts]# ls
-
ifcfg-eth0 ifdown-ib ifdown-ppp ifup-aliases ifup-ipv6 ifup-ppp init.ipv6-
global
-
ifcfg-lo ifdown-ippp ifdown-routes ifup-bnep ifup-isdn ifup-routes net.hotplug
-
ifdown ifdown-ipv6 ifdown-sit ifup-eth ifup-plip ifup-sit network-functions
-
ifdown-bnep ifdown-isdn ifdown-tunnel ifup-ib ifup-plusb ifup-tunnel network-functions-ipv6
-
ifdown-eth ifdown-post ifup ifup-ippp ifup-post ifup-wireless
-
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-br0
-
-
[root@localhost network-scripts]
# vi ifcfg-eth0
-
DEVICE=eth0
-
HWADDR=00:0C:29:DB:B2:28
-
TYPE=Ethernet
-
UUID=b2268aab-fa2e-49e9-bd67-2572f29e5790
-
ONBOOT=yes
-
NM_CONTROLLED=yes
-
BOOTPROTO=static
-
IPADDR=192.168.1.179
-
NETMASK=255.255.255.0
-
GATEWAY=192.168.1.1
-
DNS1=114.114.114.114
-
DNS2=8.8.4.4
-
增加BRIDGE=br0,删除IPADDR、NETMASK、GATEWAY、DNS
-
DEVICE=eth0
-
HWADDR=00:0C:29:DB:B2:28
-
TYPE=Ethernet
-
UUID=b2268aab-fa2e-49e9-bd67-2572f29e5790
-
ONBOOT=yes
-
BRIDGE=br0
-
BOOTPROTO=none
-
#IPADDR=192.168.1.179
-
#NETMASK=255.255.255.0
-
#GATEWAY=192.168.1.1
-
#DNS1=114.114.114.114
-
#DNS2=8.8.4.4
-
保存退出
-
[root@localhost network-scripts]
# vi ifcfg-br0
-
DEVICE=eth0
-
HWADDR=00:0C:29:DB:B2:28
-
TYPE=Ethernet
-
UUID=b2268aab-fa2e-49e9-bd67-2572f29e5790
-
ONBOOT=yes
-
NM_CONTROLLED=yes
-
BOOTPROTO=static
-
IPADDR=192.168.1.179
-
NETMASK=255.255.255.0
-
GATEWAY=192.168.1.1
-
DNS1=114.114.114.114
-
DNS2=8.8.4.4
-
修改DEVICE为br0,Type为Bridge,把eth0的网络设置设置到这里来
-
DEVICE=br0
-
TYPE=Bridge
-
ONBOOT=yes
-
BOOTPROTO=static
-
IPADDR=192.168.1.179
-
NETMASK=255.255.255.0
-
GATEWAY=192.168.1.1
-
DNS1=114.114.114.114
-
DNS2=8.8.4.4
-
保存退出
[root@localhost network-scripts]# service network restart
这一步我出现了问题,不过重启宿主机后就OK了。
-
[root
@localhost ~]# ifconfig
-
br
0 Link encap:Ethernet HWaddr 00:0C:29:DB:B2:28
-
inet
addr:192.168.1.179 Bcast:192.168.1.255 Mask:255.255.255.0
-
inet6
addr: fe80::20c:29ff:fedb:b228/64 Scope:Link
-
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
-
RX packets:137 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:13745 (13.4 KiB) TX bytes:11095 (10.8 KiB)
-
-
docker0 Link encap:Ethernet HWaddr C6:01:70:AF:C6:E4
-
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
-
inet6 addr: fe80::c401:70ff:feaf:c6e4/64 Scope:Link
-
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
-
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:0 (0.0 b) TX bytes:468 (468.0 b)
-
-
eth0 Link encap:Ethernet HWaddr 00:0C:29:DB:B2:28
-
inet6 addr: fe80::20c:29ff:fedb:b228/64 Scope:Link
-
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
-
RX packets:137 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:101 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:1000
-
RX bytes:15663 (15.2 KiB) TX bytes:11959 (11.6 KiB)
-
-
lo Link encap:Local Loopback
-
inet addr:127.0.0.1