久久青草精品A片狠狠,日韩欧美视频一区二区,亚洲国码AV日韩,国产精品黄在

centOS7如何修改firewall為iptables

2016-08-31 07:39:24 261

1、關閉默認的firewall防火墻

#systemctl stop firewalld.service停止firewalld服務

#systemctl disable firewalld.service進制開機自啟動

 

        2、開啟iptables

#yum install iptables(根據centOS7的版本和內核,有些版本已經裝過,可以跳過此命令)

#yum install iptables-services

#vim /etc/sysconfig/iptables

編輯如下(開啟了21,22,80,3306端口):


  1. # sampleconfiguration for iptables service  

  2. # # you can edit thismanually or use system-config-firewall  

  3. # # please do not askus to add additional ports/services to this default configuration  

  4. *filter  

  5. :INPUT ACCEPT [0:0]  

  6. :FORWARD ACCEPT [0:0]  

  7. :OUTPUT ACCEPT [0:0]  

  8. -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT  

  9. -A INPUT -p icmp -j ACCEPT  

  10. -A INPUT -i lo -j ACCEPT  

  11. -A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT  

  12. -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT  

  13. -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT  

  14. -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT  

  15. -A INPUT -j REJECT --reject-with icmp-host-prohibited  

  16. -A FORWARD -j REJECT --reject-with icmp-host-prohibited  

  17. COMMIT  


:wq保存

        3、開啟服務,設置開機自啟動

#service iptables restart

#chkconfig iptables on或者systemctl enable iptables.service?機自啟

 

tip:如果在重啟iptables的時候,碰到讓你journalctl -xe的錯誤,使用#journalctl -xe -l來查看錯誤

一般是語法錯誤,請仔細查看iptables文件的語法。


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: