Linux iptables
service command
# 启动防火墙
service iptables start
# 重启防火墙
service iptables restart
# 停止防火墙
service iptables stop
Add firewall rules
Edit the /etc/sysconfig/iptables file, if there is no such file, execute the following command
# 添加一条防火墙规则
iptables -P OUTPUT ACCEPT
# 保存规则并创建iptables文件
service iptables save
Add firewall port configuration in iptables file
# 开放端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# 向指定ip开放口
-A INPUT -m state -s ip地址 --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
port redirection
Listen on port 80 and redirect to port 8081
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8081