linux配置防火牆

來源:趣味經驗館 2.58W

品牌型號:Thinkpad E15

系統版本:centos7

linux主機防火牆使用的是iptables和firewall服務,以iptables為例:

1、首先在Linux系統中查詢並開啟編輯配置防火牆的檔案。執行命令: vi /etc/sysconfig/iptables。

linux配置防火牆

2、在開啟的檔案中新增語句:-A INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT (以埠80為例,配置允許埠80通過防火牆)。語句一定要在icmp-host-prohibited之前。

linux配置防火牆 第2張

3、重啟防火牆,使配置生效。輸入命令:/etc/init.d/iptables restart或者service iptables restart。

linux配置防火牆 第3張

4、檢視防火牆是否生效,輸入命令:iptables -L -n。

linux配置防火牆 第4張

總結:

以iptables為例:

1、在Linux系統中查詢並開啟編輯配置防火牆的檔案。執行命令: vi /etc/sysconfig/iptables

2、在開啟的檔案中新增語句:-A INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT 

3、重啟防火牆,使配置生效。輸入命令:/etc/init.d/iptables restart或者service iptables restart

4、檢視防火牆是否生效,輸入命令:iptables -L -n

熱門標籤