« Forward web port » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 1 : | Ligne 1 : | ||
Code to execute as root: |
Code to execute as root: |
||
<pre> |
<pre> |
||
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT |
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT |
||
iptables -A INPUT -i eth0 -p tcp --dport |
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 |
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 9000 |
||
</pre> |
</pre> |
||
To keep the rules at boot |
|||
[https://askubuntu.com/a/270696 From this forum ] |
|||
Run <code>sudo apt-get install iptables-persistent</code>, 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: <code>sudo su -c 'iptables-save > /etc/iptables/rules.v4'</code> |
|||
* To save your IPv6 ip6tables rules: <code>sudo su -c 'ip6tables-save > /etc/iptables/rules.v6'</code> |
Version du 19 mai 2017 à 11:15
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
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'