我使用 OpenVSwitch 作为 KVM 虚拟机的网络层。我有一个主桥,每个虚拟机在桥上都有一个水龙头。我在主机上也有一个内部分路器,它与 VM 分路器位于同一 VLAN 上。我可以在主机和 VM 之间正常通信,但是我很难弄清楚如何使用主机通过物理接口将 VM 流量路由到 Internet。
这是我的 OVS 配置...
foo@bar# ovs-vsctl show
b9d8798d-5a95-4d96-8df4-690ae9c8bae5
Bridge br0
Port br0
Interface br0
type: internal
Port "br0_tap0"
tag: 100
Interface "br0_tap0"
type: internal
Port "br0_tap1"
tag: 100
Interface "br0_tap1"
Port "br0_tap2"
tag: 100
Interface "br0_tap2"
ovs_version: "2.3.1"
这是我的界面配置...
foo@bar# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
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 mq state UP group default qlen 1000
link/ether 3c:07:54:0e:9c:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.10/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 2601:140:8000:508b:3e07:54ff:fe0e:9c16/64 scope global mngtmpaddr dynamic
valid_lft 345514sec preferred_lft 345514sec
inet6 fe80::3e07:54ff:fe0e:9c16/64 scope link
valid_lft forever preferred_lft forever
3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
link/ether 36:3f:76:54:8c:1a brd ff:ff:ff:ff:ff:ff
135: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 8a:c6:9d:08:23:4d brd ff:ff:ff:ff:ff:ff
inet6 fe80::88c6:9dff:fe08:234d/64 scope link
valid_lft forever preferred_lft forever
136: br0_tap0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 82:86:88:2c:6a:56 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.1/24 scope global mega_tap0
valid_lft forever preferred_lft forever
inet6 fe80::8086:88ff:fe2c:6a56/64 scope link
valid_lft forever preferred_lft forever
137: br0_tap1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP group default qlen 500
link/ether 8e:50:e5:4f:1d:60 brd ff:ff:ff:ff:ff:ff
inet6 fe80::8c50:e5ff:fe4f:1d60/64 scope link
valid_lft forever preferred_lft forever
138: br0_tap2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP group default qlen 500
link/ether d2:a7:4e:68:51:4c brd ff:ff:ff:ff:ff:ff
inet6 fe80::d0a7:4eff:fe68:514c/64 scope link
valid_lft forever preferred_lft forever
tap0
是为主机提供 IP 地址的内部分接头,VLAN 100
以便我可以与连接到tap1
和的虚拟机进行通信tap2
。我使用sysctl -w net.ipv4.ip_forward=1
.
VM 上tap1
的 IP 地址为192.168.0.10/24
。从那个虚拟机,我可以 ping 另一个虚拟机tap2
,主机的tap0
接口和主机eth0
接口的 IP 地址。但是,我无法 ping 主机之外的任何内容。我的 VM 有一个主机tap0
IP 地址的默认网关。
有任何想法吗?