狮子的雄心,骆驼的耐力,孩子的执著!
分类: 虚拟化
2010-01-08 15:53:01
How do I configure a bridged network interface for KVM using Red Hat Enterprise Linux 5.4 or later?
Red Hat Enterprise Linux 5.4 or later versions
By default, kvm uses NAT networking. If you want your guest to appear as another host on the LAN which is the same network with the host, you need to use bridged network. However, virtualization hosts configured to use KVM will not automatically create a bridged interface for the Ethernet devices on your system.
Before performing the following steps, you should connect to the server using a physical or serial session as changes to the network configuration files may cause the network interfaces to not restart correctly.
Stop the Ethernet device that you plan to create a bridge for using the ifdown command
# ifdown eth0
To create the bridged interface named 'br0' you must edit your /etc/sysconfig/network-scripts/ifcfg-ethX file and include the line:
BRIDGE=br0
Once this has been done, the configuration file will look similar to:
DEVICE=eth0 BOOTPROTO=dhcp HWADDR=XX:XX:XX:XX:XX:XX ONBOOT=yes BRIDGE=br0
If using static IP, the configuration file will look similar to:
DEVICE=eth0 BOOTPROTO=static HWADDR=XX:XX:XX:XX:XX:XX IPADDR=NETMASK= GATEWAY= ONBOOT=yes BRIDGE=br0
Now create a file /etc/sysconfig/network-scripts/ifcfg-br0 (replace br0 with the chosen name for the bridge) with the following contents:
DEVICE=br0 BOOTPROTO=none TYPE=Bridge ONBOOT=yes DELAY=0
Start the Ethernet device and the bridge device using the ifup command
#service libvirtd start
#service messagebus start
#service haldaemon start # ifup eth0 # ifup br0
Test to make sure that the host can still communicate with the network
# ping
If a firewall is running on your host system, you need to add a new rule shown below into the /etc/sysconfig/iptables file.
-A RH-Firewall-1-INPUT -i br0 -j ACCEPT
Then, restart firewall:
# service iptables restart
For more detailed information about bridged networking on KVM environment, please refer to the following official document:
Reference :