Linux系统修改防火墙配置

匿名 (未验证) 提交于 2019-12-02 21:59:42
转载:https://www.cnblogs.com/ixan/p/8243623.html

修改Linux系统防火墙配置需要修改 /etc/sysconfig/iptables 这个文件
1 vim /etc/sysconfig/iptables

在vim编辑器,会看到下面的内容

 1 # Firewall configuration written by system-config-firewall  2 # Manual customization of this file is not recommended.  3 *filter  4 :INPUT ACCEPT [0:0]  5 :FORWARD ACCEPT [0:0]  6 :OUTPUT ACCEPT [0:0]  7 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  8 -A INPUT -p icmp -j ACCEPT  9 -A INPUT -i lo -j ACCEPT 10 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT 11 -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT 12 -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 13 -A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT 14 -A INPUT -j REJECT --reject-with icmp-host-prohibited 15 -A FORWARD -j REJECT --reject-with icmp-host-prohibited 16 COMMIT

需要开放端口,请在里面添加一条一下内容即可:

1 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT

其中 1521 是要开放的端口号,然后重新启动linux的防火墙服务。

Linux下停止/启动防火墙服务的命令(root用户使用):

1 service iptables stop --ֹͣ 2  3 service iptables start --启动

写在最后:

1 #永久性生效,重启后不会复原 2 chkconfig iptables on    #开启 3  4 chkconfig iptables off    #关闭 5  6 #即时生效,重启后复原 7 service iptables start    #开启 8  9 service iptables stop    #关闭

原文:https://www.cnblogs.com/qq1069284034/p/9336720.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!