CentOS 7 0,啟用iptables防火牆

2021-09-20 22:51:45 字數 1133 閱讀 5996

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

1、關閉firewall:

systemctl stop firewalld.service #停止firewall

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

2、安裝iptables防火牆

yum install iptables-services #安裝

vi /etc/sysconfig/iptables #編輯防火牆配置檔案

# 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 80 -j accept

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

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

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

commit

:wq! #儲存退出

systemctl restart iptables.service #最後重啟防火牆使配置生效

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

CentOS 7 0,啟用iptables防火牆

centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service 停止firewall systemctl disable firewalld.service 禁止firewall開...

CentOS 7 0,啟用iptables防火牆

url centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service 停止firewall systemctl disable firewalld.service 禁止firew...

CentOS 7 0,啟用iptables防火牆

centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service 停止firewall systemctl disable firewalld.service 禁止firewall開...