Linux VRF 感知 SSH

Linux VRF 感知 SSH

我正在尝试为 eth0 上的 Linux 设备(位于 Azure 中)创建一个管理 vrf,同时使用 eth1 和 eth2 作为数据包转发接口。到目前为止,使用 Cumulus 指南,我正在使用以下配置:

sudo ip link add mgmt-vrf type vrf table 10
ip link set dev mgmt-vrf up
ip route add table 10 unreachable default metric 4278198272
sudo ip link set dev eth0 master mgmt-vrf
sudo ip route add table 10 0.0.0.0/0 dev eth0 via 10.40.255.1

我相信这应该可行,并且我得到了合理的输出:

ip -br link show vrf mgmt-vrf
eth0             UP             00:22:48:00:d4:8b <BROADCAST,MULTICAST,UP,LOWER_UP>

ip vrf show
Name              Table
-----------------------
mgmt-vrf            10

当我运行 tcpdump 时,很明显 SSH 没有响应:

sudo tcpdump -i eth0 !(port 80 or 53) -nn
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
11:17:56.843175 IP 10.26.0.112.55756 > 10.40.255.4.22: Flags [S], seq 782432837, win 64960, options [nop,wscale 8,nop,nop,sackOK], length 0
11:17:58.011786 ARP, Request who-has 10.40.255.1 tell 10.40.255.4, length 28
11:17:58.012169 ARP, Reply 10.40.255.1 is-at 12:34:56:78:9a:bc, length 28
11:17:59.956102 IP 10.26.0.112.55756 > 10.40.255.4.22: Flags [S], seq 782432837, win 64960, options [nop,wscale 8,nop,nop,sackOK], length 0
11:18:05.845234 IP 10.26.0.112.55756 > 10.40.255.4.22: Flags [S], seq 782432837, win 64960, options [nop,wscale 8,nop,nop,sackOK], length 0

据我了解,VRF 不是网络命名空间,因此我无法在命名空间下运行 SSH。此外,我还运行了以下命令:

sudo sysctl -w net.ipv4.tcp_l3mdev_accept=1
sudo sysctl -w net.ipv4.udp_l3mdev_accept=1

但还是没有喜悦。谢谢帮助

编辑

ip -4 r ls table 10
unreachable default
10.26.0.0/21 via 10.40.255.1 dev eth0
broadcast 10.40.255.0 dev eth0 proto kernel scope link src 10.40.255.4
10.40.255.0/24 dev eth0 proto kernel scope link src 10.40.255.4
local 10.40.255.4 dev eth0 proto kernel scope host src 10.40.255.4
broadcast 10.40.255.255 dev eth0 proto kernel scope link src 10.40.255.4

ip route get 10.40.255.4 from 10.26.0.112 iif eth0
local 10.40.255.4 from 10.26.0.112 dev mgmt-vrf table 10
    cache <local> iif eth0

ip route get 10.26.0.112 from 10.40.255.4
10.26.0.112 from 10.40.255.4 via 10.40.0.1 dev eth1 uid 1000
    cache

ip route get 10.26.0.1 from 10.40.255.4 vrf mgmt-vrf
10.26.0.1 from 10.40.255.4 via 10.40.255.1 dev eth0 table 10 uid 1000
    cache

此外,tcpdump 不再解析主机 IP 地址,我无法 ping 本地接口,就好像此 VRF 中的服务不再可用,并且 sysctl mdev 命令不起作用一样。希望这能有所帮助

答案1

谢谢你的帮助,我成功解决了这个问题

我已将 IPtables 配置为按照以下方式接受 eth0 mgmt-vrf 接口上的 INPUT:

sudo iptables -L -v
136M ACCEPT     all  --  eth0   any     anywhere             anywhere

这确实引用了从属设备,但是在这里:https://www.kernel.org/doc/Documentation/networking/vrf.txt

我发现你还需要引用主设备,所以添加了规则

sudo iptables -A INPUT -i mgmt-vrf -j ACCEPT

这为我解决了这个问题

谢谢你的帮助——帮助我朝着正确的方向前进

相关内容