我正在尝试从可以访问主机网络并具有功能( )的第三个容器延迟容器之间的流量(container1
调用) 。container2
NET_ADMIN
container3_admin
tc
当我在容器上应用以下规则时,我想延迟(使用此回答),运行正常。
tc qdisc add dev eth0 root handle 1: prio
tc filter add dev eth0 protocol ip parent 1: prio 1 u32 match ip dst 172.21.0.2 flowid 1:1
tc filter add dev eth0 protocol all parent 1: prio 2 u32 match ip dst 0.0.0.0/0 flowid 1:2
tc filter add dev eth0 protocol all parent 1: prio 2 u32 match ip protocol 1 0xff flowid 1:2
tc qdisc add dev eth0 parent 1:1 handle 10: netem delay 55ms
tc qdisc add dev eth0 parent 1:2 handle 20: sfq
但是,在虚拟接口上应用相同规则时container3_admin
会失败。从以下命令的输出来看,过滤器不匹配。
root@linuxkit-025000000001:/# tc -s filter ls dev veth71cd412
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 1 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 (rule hit 4 success 0)
match ac150002/ffffffff at 16 (success 0 )
filter parent 1: protocol all pref 2 u32
filter parent 1: protocol all pref 2 u32 fh 801: ht divisor 1
filter parent 1: protocol all pref 2 u32 fh 801::800 order 2048 key ht 801 bkt 0 flowid 1:2 (rule hit 5 success 5)
match 00000000/00000000 at 16 (success 5 )
filter parent 1: protocol all pref 2 u32 fh 801::801 order 2049 key ht 801 bkt 0 flowid 1:2 (rule hit 0 success 0)
match 00010000/00ff0000 at 8 (success 0 )
container2
正在运行 netcat 来监听端口54321
( nc -l -k 54321
) ,它的 IP 地址是172.21.0.2
。
你能告诉我为什么延迟规则不匹配吗match ac150002/ffffffff at 16 (success 0 )
?
ins的输出ip a
如下。
container2
369: eth0@if370: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:15:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.21.0.2/16 brd 172.21.255.255 scope global eth0
valid_lft forever preferred_lft forever
container3
370: veth7a1036d@if369: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-ea46af09b7f5 state UP group default
link/ether 06:2d:a5:4b:84:7e brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::42d:a5ff:fe4b:847e/64 scope link
valid_lft forever preferred_lft forever