Openvswitch / KVM Guest无法ping外部GW

时间:2016-04-05 00:49:30

标签: networking kvm rhel6 openvswitch vlan

我有RHEL6.4操作系统的主机。在主机下我有一个运行RHEL6.4的KVM VM。

主机连接到带有vlan标记1的标记交换机接口。

我已按如下方式配置主机网络接口:

的ifcfg-eth0的

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

的ifcfg-eth1的

DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

的ifcfg-bond0

DEVICE=bond0
TYPE=Bond
BONDING_MASTER=yes
BOOTPROTO=static
NAME=bond0
ONBOOT=yes
USERCTL=no
BONDING_OPTS="mode=active-backup primary=eth0 miimon=100"

和主机vswitch如下:

ovs-vsctl add-br ovsbr0
ovs-vsctl add-port ovsbr0 bond0
ovs-vsctl add-port ovsbr0 vlan1 tag=1 -- set interface content type=internal
ifconfig vlan1 192.168.1.2/28 up

我能够ping外部vlan1 GW(192.168.1.1)。

我遇到的问题是我无法从VM ping外部IPv4网关。 当我从VM ping时,我得到第一个数据包的响应,但其余的似乎丢失了VLAN标记并进入了错误的接口。 如果我tcpdump bond0.1我看到第一个ICMP请求和回复,但其余的ICMP回复似乎出现在bond0接口(而不是bond0.1)

[root@vm ~]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=2.64 ms
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 1 received, 80% packet loss, time 4786ms
rtt min/avg/max/mdev = 2.642/2.642/2.642/0.000 ms
[root@vm ~]#
[root@vm ~]#  tcpdump -i bond0.1 host 192.168.1.1
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on bond0.1, link-type EN10MB (Ethernet), capture size 65535 bytes
20:49:28.053502 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 1, length 64
20:49:28.054158 IP 192.168.1.1 > 192.168.1.3: ICMP echo reply, id 55664, seq 1, length 64
20:49:29.055189 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 2, length 64
20:49:30.054971 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 3, length 64
20:49:31.054935 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 4, length 64
20:49:32.054918 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 5, length 64
[root@vm]# tcpdump -i bond0 host 192.168.1.1
tcpdump: WARNING: bond0: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on bond0, link-type EN10MB (Ethernet), capture size 65535 bytes
20:49:28.053509 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 1, length 64
20:49:29.055199 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 2, length 64
20:49:29.055653 IP 192.168.1.1 > 192.168.1.3: ICMP echo reply, id 55664, seq 2, length 64
20:49:30.054983 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 3, length 64
20:49:30.055522 IP 192.168.1.1 > 192.168.1.3: ICMP echo reply, id 55664, seq 3, length 64
20:49:31.054968 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 4, length 64
20:49:31.056497 IP 192.168.1.1 > 192.168.1.3: ICMP echo reply, id 55664, seq 4, length 64
20:49:32.054927 IP 192.168.1.3 > 192.168.1.1: ICMP echo request, id 55664, seq 5, length 64
20:49:32.055402 IP 192.168.1.1 > 192.168.1.3: ICMP echo reply, id 55664, seq 5, length 64

VM网络接口配置如下:

的ifcfg-eth0的

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

的ifcfg-eth1的

DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

的ifcfg-bond0

DEVICE=bond0
TYPE=Bond
BONDING_MASTER=yes
BOOTPROTO=static
NAME=bond1
ONBOOT=yes
USERCTL=no
BONDING_OPTS="mode=active-backup primary=eth0 miimon=100"

ifcfg-bond0.1

VLAN=yes
TYPE=Vlan
DEVICE=bond0.1
NAME=bond0.1
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.3
NETMASK=255.255.255.240

知道为什么会出现这个问题吗?

1 个答案:

答案 0 :(得分:0)

默认情况下,Vlan 1未标记。因此,当您使用它作为标记(端口在干线模式)时,您应该在交换机上选择另一个未标记的(默认vlan)。 在错误的vlan配置上,您可能会看到上述行为:您正在发送流量,但您无法收回流量。 所以创建另一个vlan并再试一次。

同时使用this article

检查sysctl和其他设置