linux - 使用 tc over GRE Tunnel 的流量镜像只获取入口流量

标签 linux mirroring network-monitoring trafficshaping

我正在尝试在 tc 的帮助下通过 GRE-Tunnel tun0 从一个接口(interface)镜像“所有”网络流量。 GRE-Tunnel 工作正常,我可以 ping 并通过它发送数据包,没有任何问题。我使用以下命令添加了 tc-qdisctc-filter:

tc qdisc add dev ens5 ingress

tc filter add dev ens5 parent ffff: \
protocol all \
u32 match u8 0 0 \
action mirred egress mirror dev tun0

tc qdisc add dev ens5 handle 1: root prio

tc filter add dev ens5 parent 1: \
protocol all \
u32 match u8 0 0 \
action mirred egress mirror dev tun0

喜欢这个Tutorial

问题

问题是只有入口流量通过 GRE 隧道。当我通过接口(interface) ens5 ping 另一台计算机时,我只能通过 tun0 接口(interface)获得 icmp echo replies。 我做错了什么?

调试

ubuntu@switch:~$ tcpdump -i tun0 icmp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun0, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
10:23:28.952197 IP 192.168.20.12 > 192.168.20.15: ICMP echo reply, id 3453, seq 1, length 64
10:23:29.954454 IP 192.168.20.12 > 192.168.20.15: ICMP echo reply, id 3453, seq 2, length 64
10:23:30.952864 IP 192.168.20.12 > 192.168.20.15: ICMP echo reply, id 3453, seq 3, length 64
10:23:31.953207 IP 192.168.20.12 > 192.168.20.15: ICMP echo reply, id 3453, seq 4, length 64
10:23:32.955350 IP 192.168.20.12 > 192.168.20.15: ICMP echo reply, id 3453, seq 5, length 64
10:23:33.957000 IP 192.168.20.12 > 192.168.20.15: ICMP echo reply, id 3453, seq 6, length 64
10:23:34.956313 IP 192.168.20.12 > 192.168.20.15: ICMP echo reply, id 3453, seq 7, length 64

最佳答案

我自己解决了这个问题。

tc 镜像带有以太网 header 的导出流量和没有以太网 header 的入口流量 GRE 隧道只需要 IP 数据包,因此 header 不匹配。 如果我使用 VXLAN 而不是 GRE,它工作正常。

关于linux - 使用 tc over GRE Tunnel 的流量镜像只获取入口流量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41037569/

相关文章:

linux - 从 arm32v7 golang 镜像构建 docker 镜像时出现 exec 格式错误

linux - Linux 中的实时文件镜像到 NAS

networking - 轻量级网络可视化工具

c - 编写Linux shell

python - 读取 Unicode 文件时出现 UnicodeDecodeError

c++ - clang++ 是否以更宽松的方式对待系统头?

Maven <mirror>标签,外部:* parameter的含义

algorithm - 确定镜像延迟(镜像是使用 rsync 和 rsh 完成的)

linux - 如何创建一个可以拦截所有进出网络接口(interface)的数据包的内核模块

centos - vnstat 未在某些界面上更新