我正在尝试使用GRE隧道(或TAP)将本地Linux网络名称空间轻量级VM连接到本地HOST计算机。看起来一切正常,除了主机的答复不会使其返回虚拟机。
我的设置:
主机真实IP: 10.1.101.101/24
主机GRE(安装类似):
ip l add dev gre1 type gretap remote 10.1.101.101 local 10.1.101.101 key 101
ip a add dev gre1 10.201.0.2/24
ip l set dev gre1 up
主机网络配置:
ip a
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 pfifo_fast state UP group default qlen 1000
link/ether 00:30:1b:42:65:ac brd ff:ff:ff:ff:ff:ff
inet 10.1.101.101/24 brd 10.1.101.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::230:1bff:fe42:65ac/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:50:04:d0:50:0f brd ff:ff:ff:ff:ff:ff
82: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default
link/gre 0.0.0.0 brd 0.0.0.0
83: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
84: gre1@NONE: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65494 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether e2:83:0d:a4:cc:23 brd ff:ff:ff:ff:ff:ff
inet 10.201.0.2/24 scope global gre1
valid_lft forever preferred_lft forever
inet6 fe80::e083:dff:fea4:cc23/64 scope link tentative dadfailed
valid_lft forever preferred_lft forever
寄宿路线:
ip r
default via 10.1.101.1 dev eth0
10.1.101.0/24 dev eth0 proto kernel scope link src 10.1.101.101
10.201.0.0/24 dev gre1 proto kernel scope link src 10.201.0.2
169.254.0.0/16 dev eth0 scope link metric 1000
HOST iptables的是空白(IE: iptables -F
)
VM网络配置:
ip a
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: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default
link/gre 0.0.0.0 brd 0.0.0.0
3: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
114: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:00:00:aa:00:00 brd ff:ff:ff:ff:ff:ff
inet 10.201.0.1/24 brd 10.201.0.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::200:ff:feaa:0/64 scope link
valid_lft forever preferred_lft forever
虚拟机路由:
ip r
10.201.0.0/24 dev eth0 proto kernel scope link src 10.201.0.1
现在10.201.0.2
从VM ping HOST 10.201.0.1
并捕获数据包:
tcpdump -ni gre1
在主机上:
11:57:36.379404 ARP, Request who-has 10.201.0.2 tell 10.201.0.1, length 28
11:57:36.379431 ARP, Reply 10.201.0.2 is-at e2:83:0d:a4:cc:23, length 28
11:57:36.379455 ARP, Reply 10.201.0.2 is-at e2:83:0d:a4:cc:23, length 28
11:57:37.376634 ARP, Request who-has 10.201.0.2 tell 10.201.0.1, length 28
11:57:37.376658 ARP, Reply 10.201.0.2 is-at e2:83:0d:a4:cc:23, length 28
11:57:37.376683 ARP, Reply 10.201.0.2 is-at e2:83:0d:a4:cc:23, length 28
11:57:38.376539 ARP, Request who-has 10.201.0.2 tell 10.201.0.1, length 28
11:57:38.376567 ARP, Reply 10.201.0.2 is-at e2:83:0d:a4:cc:23, length 28
11:57:38.376596 ARP, Reply 10.201.0.2 is-at e2:83:0d:a4:cc:23, length 28
tcpdump -ni eth0
在VM上:
11:57:36.379243 ARP, Request who-has 10.201.0.2 tell 10.201.0.1, length 28
11:57:37.376384 ARP, Request who-has 10.201.0.2 tell 10.201.0.1, length 28
11:57:38.376384 ARP, Request who-has 10.201.0.2 tell 10.201.0.1, length 28
那么,AFAICS VM将ARP请求发送到HOST,HOST(正确地)回答了ARP,但是ARP数据包没有使其通过GRE隧道返回吗?
注1:VM由称为CORE Emulator的产品创建,由连接到GRE节点的基本路由器组成,该节点指向,密钥为10110.1.101.101
注意2:如果不是在本地使用Core Emulator,而是在其他计算机上运行它,但使用所有相同的设置,则相同的配置可以正常工作(使用10.1.101.101)。
我还尝试将HOST GRE隧道设置为:
ip l add gre1 type gretap remote 127.0.0.1 local 127.0.0.1 key 101
和VM GRE节点指向127.0.0.1
但是我得到相同的结果,ARP被HOST看到并答复,但VM 却看不到。
编辑1:
为了回答我的“现实世界”问题,CORE确实为我提供了如下所述的合适解决方案:https : //downloads.pf.itd.nrl.navy.mil/docs/core/core-html/usage .html#other-methods
编辑2:随后的问题?
“ Linux容器/网络名称空间/ LXC”等VM是否可以通过GRE隧道与HOST计算机通信。GRE隧道的端点会是这样的HOST:127.0.0.1
,以VM:?.?.?.?
(这些问号使我的结论是,虽然虚拟机可能能够发送到127.0.0.1的主机没有返回路径的虚拟机,这可能是为什么ARP,在我的第一个问题中,它没有连接到VM)。
感谢您抽出宝贵的时间阅读本文档,对您的帮助非常感谢。