Port mirroring in Linux is currently only supported via the DSA framework, controlled by tc
.
ip
and tc
tools, both from the iproute
packageTurn on the mirror port:
ip link set up dev p5
Add the clsact
queue discipline. This qdisc lets us attach the matchall
filter:
tc qdisc add dev p2 clsact
Mirror all packets inbound on p2 (ingress
) to p5. Note the skip_sw
flag, meaning this command will not fall back on mirroring via the CPU if the hardware offload fails:
tc filter add dev p2 ingress matchall skip_sw action mirred egress mirror dev p5
Mirror all packets going out of p2 (egress
) to p5:
tc filter add dev p2 egress matchall skip_sw action mirred egress mirror dev p5
ip link set up dev p5 tc qdisc add dev p2 clsact tc filter add dev p2 ingress matchall skip_sw action mirred egress mirror dev p5 tc filter add dev p2 egress matchall skip_sw action mirred egress mirror dev p5