Skip to content

Instantly share code, notes, and snippets.

@ebeigarts
Created August 7, 2012 20:51
Show Gist options
  • Select an option

  • Save ebeigarts/3289199 to your computer and use it in GitHub Desktop.

Select an option

Save ebeigarts/3289199 to your computer and use it in GitHub Desktop.
iptables

iptables

Port forwarding

sysctl net.ipv4.ip_forward=1

10.57.68.122:6022 => 10.200.5.60:22 (SNAT)

iptables -t nat -A PREROUTING -p tcp -m tcp --dport 6022 -j DNAT --to-destination 10.200.5.60:22
iptables -t nat -A POSTROUTING -m conntrack --ctstate DNAT -j SNAT --to-source 10.57.68.122

office.makit.lv:8008 => 192.168.0.157:8008

iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 8008 -j DNAT --to 192.168.0.157:8008
iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.157 --dport 8008 -j ACCEPT

List rules

iptables -L -t nat --line-numbers
iptables -L FORWARD --line-numbers

Delete rules

iptables -t nat -D PREROUTING 1
iptables -D FORWARD 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment