在 CentOS 7 上为 Xen 设置桥接网络
警告:在更改网络前,请确保你不用依靠网络亦能访问目标系统,供出错时用。
首先,寻找你的主网络设备:
ip route show | grep 'default' | awk '{print $5}'
一般来说这是 eth0。本指引接下来假设你想创建一个名叫 xenbr0 的网桥,并将 eth0 设成它的从属设备。
首先,创建 xenbr0,并给它适当的缺省值:
nmcli con add type bridge con-name xenbr0 ifname xenbr0 nmcli con modify xenbr0 bridge.stp no nmcli con modify xenbr0 bridge.hello-time 0
然后找出 eth0 的接线名称。一般来说这是 System eth0:
# nmcli con show NAME UUID TYPE DEVICE System eth0 1619a4a0-518e-4547-9ade-31dff5ef8f5e 802-3-ethernet eth0
最后,把 System eth0 设成 xenbr0 的从属设备:
nmcli con modify "System eth0" connection.master xenbr0 connection.slave-type bridge
接著重新引导网络:
systemctl restart network
检查设置是否已完成:
# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master xenbr0 state UP qlen 1000 link/ether 30:5b:d6:f1:d6:a2 brd ff:ff:ff:ff:ff:ff 4: xenbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether 30:5b:d6:f1:d6:a2 brd ff:ff:ff:ff:ff:ff inet 10.80.237.209/20 brd 10.80.239.255 scope global dynamic xenbr0 valid_lft 1798sec preferred_lft 1798sec inet6 fe80::325b:d6ff:fef1:d6a2/64 scope link valid_lft forever preferred_lft forever
Translation of revision 2