這篇文章主要介紹了Linux系統如何修改防火墻配置,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
改Linux系統防火墻配置需要修改 /etc/sysconfig/iptables 這個文件
vim /etc/sysconfig/iptables
在vim編輯器,會看到下面的內容
# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT
需要開放端口,請在里面添加一條一下內容即可:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
其中 1521 是要開放的端口號,然后重新啟動linux的防火墻服務。
Linux下停止/啟動防火墻服務的命令(root用戶使用):
service iptables stop --停止service iptables start --啟動
寫在最后:
#永久性生效,重啟后不會復原chkconfig iptables on #開啟chkconfig iptables off #關閉#即時生效,重啟后復原service iptables start #開啟service iptables stop #關閉
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答