廢話不多說,直接上**
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
sudo yum install iptables-services #安裝iptables防火牆
sudo systemctl enable iptables #設定iptables開機啟動
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 改用iptables作為防火牆
從centos 7開始系統預設使用的是firewall作為防火牆。關閉防火牆的方式與以往的有所不同。systemctl stop firewalld.servicesystemctl disable firewalld.serviceyum install iptables services y修改...
CentOS 7 使用iptables 開放埠
centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewal...
centos7使用iptables作為防火牆方法
centos7使用iptables作為防火牆方法 檢視firewalld狀態 systemctl status firewalld 將centos7預設的firewalld停止,並將iptables作為預設防火牆 關閉並禁用firewalld systemctl stop firewalld sys...