網站首頁 學習教育 IT科技 金融知識 旅遊規劃 生活小知識 家鄉美食 養生小知識 健身運動 美容百科 遊戲知識 綜合知識
當前位置:趣知科普吧 > IT科技 > 

linux防火牆配置

欄目: IT科技 / 發佈於: / 人氣:1.91W

品牌型號: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