Forward web port

De wiki-fabmstic
Aller à la navigation Aller à la recherche

Code to execute as root:

iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 9000 -j ACCEPT
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 9000

To keep the rules at boot

From this forum

Run sudo apt-get install iptables-persistent, and follow the prompts.

If you change your rules after this, you will need to do the following command(s) after the changes:

  • To save your IPv4 iptables rules: sudo su -c 'iptables-save > /etc/iptables/rules.v4'
  • To save your IPv6 ip6tables rules: sudo su -c 'ip6tables-save > /etc/iptables/rules.v6'