带有 Linux iproute2 的 MPLS over GRE 隧道

网络工程 linux 聚光灯 隧道 格雷
2021-07-24 21:30:06

我正在尝试将 IP 数据包封装在 MPLS 中,通过两个 Linux 主机(a 和 b)之间的 GRE 隧道传输。a10.199.0.1在 GRE 隧道接口上foo4,而 b10.199.0.2在 GRE 隧道接口上foo4我可以通过以下路线互相 ping 通:

10.199.0.0/24 dev foo4

在 a 和 b 上。

现在我想用 MPLS 封装通过隧道的数据包。我正在执行以下操作:

ip route change 10.199.0.0/24 encap mpls 100 dev foo4

...10.199.0.0/24根据我的理解,它封装了来自 a 的数据包和 b 上的以下解封装数据包:

ip -f mpls 100 dev lo

...解封装数据包并将其发送到本地环回以进行进一步路由。

通过上述设置,a和b都可以互相ping通。

然后我对 b 应用相同的策略:

在 b:

ip route change 10.199.0.0/24 encap mpls 101 dev foo4

在:

ip -f mpls 101 dev lo

然而它不起作用。当我从 a ping b 时,我在 a 上得到以下捕获:

tcpdump: listening on foo4, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
14:47:50.888846 Out ethertype MPLS unicast (0x8847), length 104: MPLS (label 100, exp 0, [S], ttl 64)
        (tos 0x0, ttl 64, id 16234, offset 0, flags [DF], proto ICMP (1), length 84)
    10.199.0.1 > 10.199.0.2: ICMP echo request, id 21604, seq 1, length 64
14:47:50.894911  In ethertype MPLS unicast (0x8847), length 104: MPLS (label 101, exp 0, [S], ttl 64)
        (tos 0x0, ttl 64, id 49128, offset 0, flags [none], proto ICMP (1), length 84)
    10.199.0.2 > 10.199.0.1: ICMP echo reply, id 21604, seq 1, length 64

...以及以下 b 上的捕获:

tcpdump: listening on foo4, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
14:51:03.544222  In ethertype MPLS unicast (0x8847), length 104: MPLS (label 100, exp 0, [S], ttl 64)
        (tos 0x0, ttl 64, id 56858, offset 0, flags [DF], proto ICMP (1), length 84)
    10.199.0.1 > 10.199.0.2: ICMP echo request, id 27962, seq 1, length 64
14:51:03.544393 Out ethertype MPLS unicast (0x8847), length 104: MPLS (label 101, exp 0, [S], ttl 64)
        (tos 0x0, ttl 64, id 54680, offset 0, flags [none], proto ICMP (1), length 84)
    10.199.0.2 > 10.199.0.1: ICMP echo reply, id 27962, seq 1, length 64

数据包回复数据包已收到,但 ping 并没有说它收到了数据包(即在 ping 的标准输出上没有回复)。

但是,当我从 b ping a 时,a 没有回复。tcpdump 在一个:

15:15:13.594917  In ethertype MPLS unicast (0x8847), length 104: MPLS (label 101, exp 0, [S], ttl 64)
        (tos 0x0, ttl 64, id 52653, offset 0, flags [DF], proto ICMP (1), length 84)
    10.199.0.2 > 10.199.0.1: ICMP echo request, id 47152, seq 2, length 64

b 上的 tcpdump:

15:17:08.450994 Out ethertype MPLS unicast (0x8847), length 104: MPLS (label 101, exp 0, [S], ttl 64)
        (tos 0x0, ttl 64, id 52944, offset 0, flags [DF], proto ICMP (1), length 84)
    10.199.0.2 > 10.199.0.1: ICMP echo request, id 49211, seq 1, length 64

(以上捕获不是在同一时间执行的;请忽略 echo id、序列号和时间的差异)

我的问题如下:

  • 为什么当从 a ping b 时,ping 报告没有收到回复,尽管实际上收到了回声回复?
  • 为什么 a 不响应 b 的回声请求?
1个回答

结果我忘记接受mpls输入以及打开rp_filter机器a。执行以下操作解决了问题:

sysctl -w net.ipv4.conf.all.rp_filter=0
sysctl -w net.mpls.conf.foo4.input=1