CentOS 7 0防火牆設定

2021-07-27 14:33:36 字數 1625 閱讀 7986

作業系統環境:centos linux release 7.0.1406(core) 64位

centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆步驟。

1、關閉firewall:

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall開機啟動

firewall-cmd --state #檢視預設防火牆狀態(關閉後顯示notrunning,開啟後顯示running)

2.安裝iptables

3、iptables防火牆

vi/etc/sysconfig/iptables

# sample configuration for iptables service

# you can edit this manually or use system-config-firewall

# please do not ask us to add additional ports/services to this default configuration

*filter

:input accept [0:0]

:forward accept [0:0]

:output accept [0:0]

-a input -m state --state related,established -j accept

-a input -p icmp -j accept

-a input -i lo -j accept

-a input -p tcp -m state --state new -m tcp --dport 22 -j accept

-a input -p tcp -m state --state new -m tcp --dport 80 -j accept

-a input -p tcp -m state --state new -m tcp --dport 3306 -j accept

-a input -m state --state new -m tcp -p tcp --dport 6379 -j accept

-a input -m state --state new -m tcp -p tcp --dport 21 -j accept

-a input -j reject --reject-with icmp-host-prohibited

-a forward -j reject --reject-with icmp-host-prohibited

commit

:wq! #儲存退出

備註:這裡使用80和8080埠為例。配置一般新增到「-a input -p tcp -m state --state new -m tcp--dport 22 -j accept」行的上面或者下面,切記不要新增到最後一行,否則防火牆重啟後不生效。

systemctl         restart                  iptables.service #重啟防火牆

systemctl         enable                 iptables.service #設定防火牆開機啟動

CentOS 7 0 配置防火牆

1.centos 7.2 解決centos採用firewalld來管理防火牆,棄用iptables的解決辦法 使用firewalld來開放埠,對防火牆的簡單操作1.停止iptables服務 systemctl stop iptables.service2.啟動 firewalld服務 systemc...

CentOS 7 0如何配置防火牆

在虛擬機器中安裝了centos,然後啟動個web服務,想從本地機器訪問怎麼辦?安裝它,只需 yum install firewalld 如果需要圖形介面的話,則再安裝 yum install firewall config 一 介紹 防火牆守護 firewalld 服務引入了乙個信任級別的概念來管理...

CentOS7 0以上版本linux防火牆問題

centos 7.0預設使用的是firewall作為防火牆,使用iptables來做防火牆,那麼必須重新設定一下 1 直接關閉防火牆 systemctl stop firewalld.service 停止firewall systemctl disable firewalld.service 禁止f...