9 月 032013
 

安装完毕虚拟化环境后新增了virbr0接口(NAT模式)

[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0B:2F:82:14:8E
inet addr:192.168.1.151 Bcast:192.168.3.255 Mask:255.255.252.0
inet6 addr: fe80::20b:2fff:fe82:148e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:265 errors:0 dropped:0 overruns:0 frame:0
TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:24298 (23.7 KiB) TX bytes:6918 (6.7 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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

virbr0 Link encap:Ethernet HWaddr 52:54:00:C5:A5:7C
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

[root@localhost ~]#

桥接功能的实现依赖于已安装的bridge-utils包

[root@localhost ~]# less install.log |grep bridge
Installing bridge-utils-1.2-9.el6.x86_64
[root@localhost ~]#

查看bridge-utils包描述信息

[root@localhost ~]# rpm -qi bridge-utils
Name : bridge-utils Relocations: (not relocatable)
Version : 1.2 Vendor: CentOS
Release : 10.el6 Build Date: Fri 22 Feb 2013 05:43:02 AM CST
Install Date: Mon 26 Aug 2013 03:29:18 AM CST Build Host: c6b9.bsys.dev.centos.org
Group : System Environment/Base Source RPM: bridge-utils-1.2-10.el6.src.rpm
Size : 58535 License: GPLv2+
Signature : RSA/SHA1, Sun 24 Feb 2013 01:38:20 AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://bridge.sourceforge.net/
Summary : Utilities for configuring the linux ethernet bridge
Description :
This package contains utilities for configuring the linux ethernet
bridge. The linux ethernet bridge can be used for connecting multiple
ethernet devices together. The connecting is fully transparent: hosts
connected to one ethernet device see hosts connected to the other
ethernet devices directly.

Install bridge-utils if you want to use the linux ethernet bridge.

[root@localhost ~]#

修改现有的eth0接口配置文件

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
 [root@localhost network-scripts]# vi ifcfg-eth0
 DEVICE="eth0"
 BOOTPROTO="static"
 HWADDR="00:0B:2F:82:14:8E"
 NM_CONTROLLED="yes"
 ONBOOT="yes"
 TYPE="Ethernet"
 UUID="a1dedea5-3dc4-483a-a53b-8e20071ca774"
 #IPADDR=192.168.1.151
 #PREFIX=22
 #GATEWAY=192.168.1.254
 #DNS1=8.8.8.8
 BRIDGE="br0"

新建桥接接口配置文件

[root@localhost network-scripts]# vi ifcfg-br0
 DEVICE="br0"
 BOOTPROTO="static"
 ONBOOT="yes"
 TYPE="Bridge"
 IPADDR=192.168.1.151
 PREFIX=22
 GATEWAY=192.168.1.254
 DNS1=202.96.128.86
 DNS2=202.96.134.33

重启网络服务(支持SSH远程操作)

[root@localhost network-scripts]# service network restart
 Shutting down interface eth0: bridge br0 does not exist!
 [ OK ]
 Shutting down loopback interface: [ OK ]
 Bringing up loopback interface: [ OK ]
 Bringing up interface eth0: [ OK ]
 Bringing up interface br0: [ OK ]
 [root@localhost network-scripts]#

查看已启用的网络接口
[root@localhost network-scripts]# ifconfig
br0 Link encap:Ethernet HWaddr 00:0B:2F:82:14:8E
inet addr:192.168.1.151 Bcast:192.168.3.255 Mask:255.255.252.0
inet6 addr: fe80::20b:2fff:fe82:148e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1658 errors:0 dropped:0 overruns:0 frame:0
TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:102856 (100.4 KiB) TX bytes:6466 (6.3 KiB)

eth0 Link encap:Ethernet HWaddr 00:0B:2F:82:14:8E
inet6 addr: fe80::20b:2fff:fe82:148e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5844 errors:0 dropped:0 overruns:0 frame:0
TX packets:628 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:481672 (470.3 KiB) TX bytes:70448 (68.7 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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

virbr0 Link encap:Ethernet HWaddr 52:54:00:C5:A5:7C
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

[root@localhost network-scripts]#