dom0和domU都是Debian 8。
Dom0的networkingconfiguration是:
auto xenbr0 iface xenbr0 inet manual bridge_ports eth1 bridge_stp off bridge_waitport 0 bridge_fd 0 auto xenbr0.4 iface xenbr0.4 inet static address 192.168.4.13 broadcast 192.168.4.255 netmask 255.255.255.0 gateway 192.168.4.1 vlan-raw-device xenbr0
在主机上,我还更改了某些内核参数,以允许转发和通过防火墙传递数据包。
# sysctl -p /etc/sysctl.conf net.ipv4.ip_forward = 1 net.ipv4.conf.xenbr0.proxy_arp = 1 net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0
/ etc / xen /中的configuration文件包含以下行:
vif = ['bridge=xenbr0,mac=00:16:3e:40:27:fa,ip=192.168.4.21']
现在这里是domUnetworkingconfiguration。
auto eth0 iface eth0 inet static address 192.168.4.21 broadcast 192.168.4.255 netmask 255.255.255.0 gateway 192.168.4.1
重启networking后,我们可以看到默认路由和ARP表。
在dom0:
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.4.1 0.0.0.0 UG 0 0 0 xenbr0.4 192.168.4.0 0.0.0.0 255.255.255.0 U 0 0 0 xenbr0.4 # arp -n Address HWtype HWaddress Flags Mask Iface 192.168.4.21 (incomplete) xenbr0.4 192.168.4.21 ether 00:16:3e:40:27:fa C xenbr0 192.168.4.1 ether 00:00:5e:00:01:05 C xenbr0.4 192.168.4.2 ether 00:17:7c:41:7c:ce C xenbr0.4
DomU的:
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.4.1 0.0.0.0 UG 0 0 0 eth0 192.168.4.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 # arp -n Address HWtype HWaddress Flags Mask Iface 192.168.4.1 ether 20:47:47:8c:d0:4c C eth0
那么如果我从domU ping 192.168.4.1并在dom0上运行tcpdump会发生什么?
在dom0:
# tcpdump -vv host 192.168.4.21 tcpdump: listening on xenbr0, link-type EN10MB (Ethernet), capture size 262144 bytes 11:14:57.603076 IP (tos 0x0, ttl 64, id 55216, offset 0, flags [DF], proto ICMP (1), length 84) domU > 192.168.4.1: ICMP echo request, id 725, seq 1, length 64 11:14:57.603086 IP (tos 0x0, ttl 63, id 55216, offset 0, flags [DF], proto ICMP (1), length 84) domU > 192.168.4.1: ICMP echo request, id 725, seq 1, length 64 11:14:57.621871 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has domU tell 192.168.4.1, length 46 ... 8 packets captured 11 packets received by filter 0 packets dropped by kernel
DomU的:
# ping 192.168.4.1 PING 192.168.4.1 (192.168.4.1) 56(84) bytes of data. ^C --- 192.168.4.1 ping statistics --- 148 packets transmitted, 0 received, 100% packet loss, time 147000ms
当ping 192.168.4.13时,我得到了类似的结果,当然dom0能够达到外部IP地址,但是domU不是。 任何人都有下一步该怎么做的想法? 谢谢。