文件地址:/etc/sysconfig/ipconfig ------- -A INPUT -p tcp -m state --state NEW -m tcp --dport 8082 -j ACCEPT --dport 后面跟想要对外开放的端口号。 ------以下是示例----- # Generated by iptables-save v1.3.5 on Mon Apr 2 22:57:22 2012 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [5958:3482917] -A INPUT -i lo -j ACCEPT -A INPUT -p icmp -m icmp --icmp-type any -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 8888 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 8081 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 8082 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 9001 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 27017 -j ACCEPT -A INPUT -p udp -m state --state NEW -m udp --dport 27017 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 3001 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 3690 -j ACCEPT -A INPUT -p udp -m state --state NEW -m udp --dport 3690 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 81 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited COMMIT # Completed on Mon Apr 2 22:57:22 2012
重启生效: service iptables restart |
转载于:https://my.oschina.net/minglic/blog/64742