标签:xen 网络配置
xen4.4.2安装完成后我们观察到以下信息:
Dom0:
[root@node1 ~]#ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:2E:72:81
inet addr:10.43.2.11 Bcast:10.43.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2e:7281/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3882 errors:0 dropped:0 overruns:0 frame:0
TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:431458 (421.3 KiB) TX bytes:7243 (7.0 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:65536 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 FE:FF:FF:FF:FF:FF
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)
我们Dom2的ip地址为:
[root@node1 ~]# xm console Dom2
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:16:3E:DD:82:E8
inet addr:192.168.122.71 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::216:3eff:fedd:82e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2319 errors:0 dropped:0 overruns:0 frame:0
TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:93605 (91.4 KiB) TX bytes:10126 (9.8 KiB)
Interrupt:247
我们发现Dom2默认使用的是virbr0这个桥,通过
使用:A single bridged network configured with a local IP address via DHCP
修改vifbr0的IP地址跟主机Dom0在同一个网段内(10.43.2.0/24)
通过以上信息我们知道在装完livrit-manager后Dom2默认使用的是livirt提供的virbr0这个桥,而这个桥默认是使用的NAT模式。
1.增加一个桥xenbr0
在/etc/sysconfig/network-scripts/下创建ifcfg-xenbr0为以下内容
[root@node1 network-scripts]# vim ifcfg-xenbr0
DEVICE=xenbr0
TYPE=Bridge
ONBOOT=yes
DELAY=0
BOOTPROTO=dhcp
NM_CONTROLLED=no
2.修改ifcfg-eth0为以下内容:(将eth0关联到桥xenbr0上边)
[root@node1 network-scripts]# vim ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:2E:72:81
ONBOOT=yes
NM_CONTROLLED=no
BRIDGE=xenbr0
3.reboot
[root@node1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:2E:72:81
inet6 addr: fe80::20c:29ff:fe2e:7281/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3882 errors:0 dropped:0 overruns:0 frame:0
TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:431458 (421.3 KiB) TX bytes:7243 (7.0 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:65536 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)
vif1.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:0 (0.0 b) TX bytes:1664 (1.6 KiB)
virbr0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
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)
xenbr0 Link encap:Ethernet HWaddr 00:0C:29:2E:72:81
inet addr:10.43.2.11 Bcast:10.43.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2e:7281/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2631 errors:0 dropped:0 overruns:0 frame:0
TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:160369 (156.6 KiB) TX bytes:10303 (10.0 KiB)
重启后我们发现xenbr0现在拥有eth0的MAC地址和IP地址。
4.去掉默认使用的default配置(virbr0)
进入virsh命令行:
virsh # net-destroy default
Network default destroyed
virsh # net-undefine default
Network default has been undefined
service libvirtd restart
5.修改Dom2默认使用的桥
[root@node1 ~]# virsh edit Dom2
将以下信息:
<source bridge=‘virbr0‘/>
改为
<source bridge=‘xenbr0‘/>
6.重新启动Dom2并连接Dom2
xm start Dom2
xm console Dom2
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:DD:82:E8
inet addr:10.43.2.104 Bcast:10.43.2.255 Mask:255.255.255.0
inet6 addr: fe80::216:3eff:fedd:82e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:414 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:27434 (26.7 KiB) TX bytes:2028 (1.9 KiB)
Interrupt:247
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)
观察到Dom2的IP地址已经和Dom0在同一个网段了。
后来发现使用virsh这个管理工具的时候有一个简单的命令也可以实现
virsh iface-bridge eth0 xenbr0
总结:
删除默认的virbr0--->创建一个桥(桥设置为DHCP获取IP地址)---->将物理网卡关联到此桥上边----->重启操作系统
标签:xen 网络配置
原文地址:http://germanygu.blog.51cto.com/3574209/1669416