Centos7 port mapping

After opening tomcat, plus access required to access the port number 8080, in tomcat without changing the default port number, add a nat port mapping, map port 80 to port 8080, 8080 can be achieved without access.

Adding entries "destination port 80, mapped to 8080" to the end of the chain nat table PREROUTING

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

 

Port mapping command (80> 8080):

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

After the restart will fail.

Save command:

service iptables save

centos7 Without this command:

# service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, 
force-reload, status). For other actions, please try to use systemctl. 

Solution:
1. First execute the following command:

systemctl stop firewalld
systemctl mask firewalld

2. Install iptables services

yum install iptables-services

3. Set the boot

systemctl enable iptables

4. Restart iptables service

systemctl restart iptables

5. Save execute configuration commands

service iptables save

Guess you like

Origin www.cnblogs.com/kinwing/p/11202847.html