關於virt-manager創建虛機時不能配置share physical device
/etc/sysconfig/network-scripts/ifcfg-vnet0
DEVICE=vnet0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
STP=on
DELAY=0
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BRIDGE=vnet0
BOOTPROTO=dhcp
HWADDR=00:1A:A0:2E:76:36
ONBOOT=yes
DHCP_HOSTNAME=centos.kvm
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:1A:A0:2E:76:36
inet6 addr: fe80::21a:a0ff:fe2e:7636/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33070 errors:0 dropped:0 overruns:0 frame:0
TX packets:32579 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2444226 (2.3 MiB) TX bytes:14594767 (13.9 MiB)
Interrupt:169 Memory:f8000000-f8012800
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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 b) TX bytes:648 (648.0 b)
virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::200:ff:fe00:0/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)
vnet0 Link encap:Ethernet HWaddr 00:1A:A0:2E:76:36
inet addr:172.16.100.209 Bcast:172.16.100.255 Mask:255.255.255.0
inet6 addr: fe80::21a:a0ff:fe2e:7636/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32882 errors:0 dropped:0 overruns:0 frame:0
TX packets:25370 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1798115 (1.7 MiB) TX bytes:14028794 (13.3 MiB)
service network restart
# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.000000000000 yes
vnet0 8000.001aa02e7636 yes eth0
Virtualization Method ---
CPU:architecture
Hypervisor : kvm|qemu
Network ---
share physical device : null
使用virt-manager創建虛機時不能配置share physical device列表為空,沒有任何設備可用.只能使用Virtual network
導致我新建的虛機,不與使用與物理網路相同的網段(172.16.100.0/24)的IP,直接對外網提供網路服務.
CentOS release 5.4 (Final)
virt-manager-0.6.1-8.el5
libvirt-0.6.3-20.1.el5_4
[ 本帖最後由 ygl23 於 2009-12-31 16:31 編輯 ]
《解決方案》
參考http://wiki.libvirt.org/page/Networking
Bridged networking (aka "shared physical device")
Host configuration
The NAT based connectivity is useful for quick & easy deployments, or on machines with dynamic/sporadic networking connectivity. More advanced users will want to use full bridging, where the guest is connected directly to the LAN. The instructions for setting this up vary by distribution, and even by release.
Fedora/RHEL Bridging
This outlines how to setup briding using standard network initscripts
Disabling Xen's network scripts
If using Xen it is recommended to disable its network munging by editing /etc/xen/xend-config.sxp and changing the line
(network-script network-bridge)
To be
(network-script /bin/true)
Disabling NetworkManager
As of time of writing (Fedora 9) NetworkManager does not support bridging, so it is neccessary to disable it, and revert to "classic" network initscripts
# chkconfig NetworkManager off
# chkconfig network on
# service NetworkManager stop
# service network start
NB, as an alternative to turning off NetworkManager, you can add "NM_CONTROLLED=no" to the ifcfg-XXX scripts below
Creating network initscripts
In the /etc/sysconfig/network-scripts directory it is necccessary to create 2 config files. The first (ifcfg-eth0) defines your physical network interface, and says that it will be part of a bridge:
# cat > ifcfg-eth0 <<EOF
DEVICE=eth0
HWADDR=00:16:76:D6:C9:45
ONBOOT=yes
BRIDGE=br0
EOF
Obviously change the HWADDR to match your actual NIC's address. You may also wish to configure the device's MTU here using e.g. MTU=9000.
The second config file (ifcfg-br0) defines the bridge device:
# cat > ifcfg-br0 <<EOF
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
EOF
WARNING: The line TYPE=Bridge is case-sensitive - it must have uppercase 'B' and lower case 'ridge'
After changing this restart networking (or simply reboot)
# service network restart
The final step is to disable netfilter on the bridge:
# cat >> /etc/sysctl.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
EOF
# sysctl -p /etc/sysctl.conf
It is recommended to do this for performance and security reasons. See Fedora bug #512206. Alternatively you can configure iptables to allow all traffic to be forwarded across the bridge:
# echo "-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT" > /etc/sysconfig/iptables-forward-bridged
# lokkit --custom-rules=ipv4:filter:/etc/sysconfig/iptables-forward-bridged
# service libvirtd reload
You should now have a "shared physical device", to which guests can be attached and have full LAN access
# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.000000000000 yes
br0 8000.000e0cb30550 no eth0
Note how this bridge is completely independant of the virbr0. Do *NOT* attempt to attach a physical device to 'virbr0' - this is only for NAT connectivity
Debian/Ubuntu Bridging
This outlines how to setup bridging using standard network interface config files
Disabling NetworkManager
Stop network manager
sudo /etc/dbus-1/event.d/26NetworkManagerDispatcher stop
sudo /etc/dbus-1/event.d/25NetworkManager stop
Create two files with only the word 'exit' in them. These files are:
/etc/default/NetworkManager
/etc/default/NetworkManagerDispatcher
from https://help.ubuntu.com/community/NetworkManager#Disabling%20NetworkManager
Altering the interface config
First take down the interface you wish to bridge
ifdown eth0
Edit /etc/network/interfaces and find the config for the physical interface, which looks something like
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.4
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.2
Remove the 'allow-hotplug eth0' line, replacing it with 'auto br0', and change the next line with iface name to 'br0', so it now starts with
auto br0
iface br0 inet static
And then define the interface as being a bridge and specify its ports
bridge_ports eth0
bridge_stp off
bridge_maxwait 5
The complete config should now look like
auto br0
iface br0 inet static
address 192.168.2.4
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.2
bridge_ports eth0
bridge_stp off
bridge_maxwait 5
The interface can now be started with
ifup br0
Finally add the '/etc/sysctl.conf' settings
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
And then load the settings with
sysctl -p /etc/sysctl.conf
You should now have a "shared physical device", to which guests can be attached and have full LAN access
# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.000000000000 yes
br0 8000.000e0cb30550 no eth0
Note how this bridge is completely independant of the virbr0. Do *NOT* attempt to attach a physical device to 'virbr0' - this is only for NAT connectivity