iptables tips and tricks

From WebHostingNeeds.com
Jump to: navigation, search

Port Redirects

Suppose you'd like to accommodate customers that aren't able to connect to port 25 through there ISP. This will redirect any traffic going to IP (port 26) and send it to IP (port 25):

iptables -A PREROUTING -p tcp -m tcp -d --dport 26 -j DNAT --to

OR you might need to do:

iptables -t nat -A PREROUTING -d -p tcp --dport 26 -j REDIRECT --to-ports 25

NAT Masquerade

iptables -t nat -A POSTROUTING -s -d ! -j MASQUERADE
sysctl -w net.ipv4.ip_forward=1

Where is the network you are masquerading for.