arp_filter的验证,使用net namespace

使用网络命名空间:net namespace

在namespace ns1中增加了两个网卡

sudo ip netns add ns1

sudo ip link add veth0 type veth peer name veth1

sudo ip link add veth2 type veth peer name veth3

sudo ip link set veth0 netns ns1

sudo ip link set veth2 netns ns1

sudo ip netns exec ns1 ifconfig veth0 172.17.0.2/16

sudo ip netns exec ns2 ifconfig veth2 172.17.0.3/16

然后通过 sudo ip netns ns1 route

内核 IP 路由表
目标            网关            子网掩码        标志  跃点   引用  使用 接口
172.17.0.0      *               255.255.0.0     U     0      0        0 veth2
172.17.0.0      *               255.255.0.0     U     0      0        0 veth0

这个路由表是很奇怪的,对于相同网段的话,默认是通过veth2发送出去的,这个时候去ping veth0应该是失败的,因为有反向路由的检查,发现竟然可以ping通veth0,这说明怎么配置网络namespace的其他的域?

原文地址:https://www.cnblogs.com/honpey/p/10271176.html