iptables -t nat -nL 查看
设置
systemctl stop firewalld.service | |||
systemctl disable firewalld.service | |||
yum -y install iptables-services | |||
systemctl enable iptables.service | |||
vi /etc/sysctl.conf | |||
net.ipv4.ip_forward = 1 | |||
sysctl -p | |||
echo 1 > /proc/sys/net/ipv4/ip_forward | |||
iptables -t nat -I PREROUTING -p tcp –dport 80 -j DNAT –to 对应的内网IP(如果不是一个局域网只能配置外网IP) | |||
iptables -t nat -I POSTROUTING -p tcp –dport 80 -j MASQUERADE | |||
iptables -A INPUT -p tcp –dport 80 -j ACCEPT | |||
iptables -A INPUT -p tcp –dport 20 -j ACCEPT | |||
iptables -A INPUT -p tcp –dport 21 -j ACCEPT | |||
iptables -A INPUT -p tcp –dport 22 -j ACCEPT | |||
service iptables save | |||
service iptables restart |
查看转发 cat /etc/sysconfig/iptables