iptables basic

iptables basic

Donny Donny
December 27, 2018
December 27, 2018

Tags in blue are handcrafted tags; Tags in green are generated using AutoTag.


# list filter table
sudo iptables -L

# list nat table
sudo iptables -L -t nat


# Redirect locally
sudo iptables -A OUTPUT -t nat -p tcp --src --dport 80 -j REDIRECT --to-port 8080

# Redirect in LAN
sudo iptables -A PREROUTING -t nat -p tcp --src --dst --dport 80 -j REDIRECT --to-port 8080


# Reject with ICMP-port-unreachable.
sudo iptables -A OUTPUT --dst www.bing.com -j REJECT 

# Drop and hang up the connection.
sudo iptables -A OUTPUT --dst www.bing.com -j DROP

Package flow paths

Package flow paths (from iptables - Wikipedia):

Netfilter Packet Flow