Skip to content

Instantly share code, notes, and snippets.

@tuoxie007
Last active August 29, 2015 14:06
Show Gist options
  • Save tuoxie007/ce46900f14490be8f82d to your computer and use it in GitHub Desktop.
Save tuoxie007/ce46900f14490be8f82d to your computer and use it in GitHub Desktop.
linux-config-port-mirror
local_ip=
local_port=
remote_ip=
remote_port=
iptables -t nat -A PREROUTING -d $local_ip -p tcp --dport $local_port -j DNAT --to-destination $remote_ip:$local_port
iptables -t nat -A POSTROUTING -d $remote_ip -p tcp --dport $remote_port -j SNAT --to $local_ip
iptables -A FORWARD -o eth1 -d $remote_ip -p tcp --dport $remote_port -j ACCEPT
iptables -A FORWARD -i eth1 -s $remote_ip -p tcp --sport $remote_port -j ACCEPT
iptables -vnL --line-numbers
iptables -D FORWARD 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment