You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

In this example all incoming traffic on port 80 redirect to port 8123

iptables -t nat -I PREROUTING --src 0/0 --dst 192.168.1.5 -p tcp --dport 80 -j REDIRECT --to-ports 8123

Below is a case to forward all the incoming packets to two different local mysql servers

sudo iptables -F
sudo iptables -t nat -F
sudo iptables -t mangle -F
sudo iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 63001 -j DNAT --to-destination 10.0.3.10:3306
sudo iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 63101 -j DNAT --to-destination 10.0.3.20:3306
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Show all the list in the iptables

sudo iptables -S

Delete all existing rules

sudo iptables -F
  • No labels