CISCO 스위치의 monitor 처럼 포트미러링 설정 하려면
# source interface 를 `eth0` 으로 하고, destination interface를 `eth3` 로
SOURCE_IF=eth0
MIRROR_IF=eth3
ifconfig dummy0 127.4.4.4/32 up
ifconfig $MIRROR_IF 0/0 up
brctl addbr tap-$MIRROR_IF
brctl addif tap-$MIRROR_IF dummy0 $MIRROR_IF
ifconfig tap-$MIRROR_IF 127.5.5.5/32 up
# RX
tc qdisc add dev $SOURCE_IF ingress
tc filter add dev $SOURCE_IF parent ffff: protocol all u32 match u8 0 0 action mirred egress mirror dev tap-$MIRROR_IF
# TX
tc qdisc add dev $SOURCE_IF handle 1: root prio
tc filter add dev $SOURCE_IF parent 1: protocol all u32 match u8 0 0 action mirred egress mirror dev tap-$MIRROR_IF
위와 같이 설정하고 tcpdump -nni tap-eth3
로 보면 eth0
의 패킷들이 미러링 되어 eth3으로 전달 되는 것을 확인 할 수 있습니다.