Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

iptables notes

list

sudo iptables -vL -t filter
sudo iptables -vL -t nat
sudo iptables -vL -t mangle
sudo iptables -vL -t raw
sudo iptables -vL -t security
sudo iptables -vL --line-numbers
sudo iptables -vL -t nat --line-numbers
sudo iptables-save

delete

sudo iptables -t nat -D {number}

nat

Assume:

  • public network: eth0 1.2.3.4
  • local network: 10.0.0.0/8
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o eth0 -s 10.0.0.0/8 -j SNAT --to-source 1.2.3.4
sudo iptables -A FORWARD -i zt+ -s 10.0.0.0/8 -d 0.0.0.0/0 -j ACCEPT
sudo iptables -A FORWARD -i eth0 -s 0.0.0.0/0 -d 10.0.0.0/8 -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.