流量镜像一般在交换机上做,实际上iptables也有tee模块可以做流量镜像。
root@xs-zhu-OpenWrt:~# opkg install kmod-ipt-tee
Installing kmod-ipt-tee (4.14.221-1) to root...
Downloading http://downloads.openwrt.org/releases/19.07.7/targets/ramips/mt7620/kmods/4.14.221-1-18384755d38fc43c447d83d4a3e07054/kmod-ipt-tee_4.14.221-1_mipsel_24kc.ipk
Configuring kmod-ipt-tee.
root@xs-zhu-OpenWrt:~# iptables -t mangle -A PREROUTING -s 192.168.1.0/24 -j TEE –gateway 192.168.1.101 # 整个网段的都镜像
root@xs-zhu-OpenWrt:~# iptables -t mangle -A POSTROUTING -d 192.168.1.0/24 -j TEE –gateway 192.168.1.101