快轉到主要內容

關閉centos7防火牆firewalld改用傳統的iptables

·184 字·1 分鐘·
PolloChang
作者
PolloChang
我是一隻雞

關閉 centos7 防火牆 firewalld 改用傳統的 iptables
#

這樣做的原因
#

因為firewalld 政策是對外嚴謹對內寬鬆,所以當需求是需要對內嚴謹時無法滿足需求

處理方式
#

預設開機不啟動 且 立即停止

1
systemctl disable --now firewalld

改用傳統的 iptables-services , 安裝

1
yum install iptables-utils iptables-services -y

設定網路
#

清空
#

1
2
3
sudo iptables -F
sudo iptables -X
sudo iptables -Z

允許輸入
#

1
2
3
sudo iptables -I INPUT 1 -s 192.168.56.0/24 -j ACCEPT
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -s 0.0.0.0/0 -j DROP

允許輸出
#

1
2
sudo iptables -I OUTPUT 1 -d 192.168.56.0/24 -j ACCEPT
sudo iptables -A OUTPUT -d 0.0.0.0/0 -j DROP

儲存
#

1
sudo iptables save