NAT: masquerade outgoing traffic

Turn on IP masquerading for outgoing traffic, as on a router

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

tool
iptables10 commands
tags
iptableslinuxnetwork

More iptables commands

  • iptables-save > /etc/iptables/rules.v4 iptables-restore < /etc/iptables/rules.v4

    Save rules to a file and load them back, for example after a reboot

  • iptables -D INPUT 3

    Remove rule number 3 from the INPUT chain

  • iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m limit --limit 3/min --limit-burst 5 -j ACCEPT

    Accept no more than 3 new SSH connections per minute with a burst of 5

  • nft list ruleset

    Show the full nftables configuration

  • nft add rule inet filter input tcp dport 8080 accept

    Accept incoming TCP traffic on port 8080 in nftables

all 10 iptables commands