Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Created June 7, 2013 01:59
Show Gist options
  • Save yuuichi-fujioka/5726604 to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/5726604 to your computer and use it in GitHub Desktop.
simple port forwarding
out_nic=eth0
in_nic=eth1
in_net_cidr=192.168.0.0/24
iptables -t nat -A POSTROUTING -o ${out_nic} -j MASQUERADE
iptables -t nat -A POSTROUTING -o ${in_nic} -s ${in_net_cidr} -j MASQUERADE
dst_port=10022
dst=192.168.0.5:22
iptables -t nat -A PREROUTING -p tcp --dport ${dst_port} -j DNAT --to-destination ${dst}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment