centos7 關(guān)于防火墻的常見(jiàn)錯(cuò)誤和處理

1 systemctl daemon-reload
這個(gè)常在修改了某項(xiàng)服務(wù)的配置文件后,如果需要生效的話,系統(tǒng)主動(dòng)會(huì)提示你
舉個(gè)例子你修改了防火墻設(shè)置
此時(shí)你想systemctl start firewalld.service
或者systemctl stop?firewalld.service
此時(shí)系統(tǒng)就會(huì)提示
Warning:firewalld.service changed on disk. Run "systemctl?daemon-reload"
運(yùn)行systemctl?daemon-reload之后
就可以正常啟停服務(wù)了
當(dāng)然有時(shí)候會(huì)碰到unit firewalld.service is masked這種情況
這種就是服務(wù)被鎖定了
只需要輸入
systemctl unmask firewalld即可解鎖
2 關(guān)于iptables
iptables,是Linux下自帶的一款免費(fèi)的基于包過(guò)濾的防火墻工具
centos7中默認(rèn)的防火墻是firewalld,使用iptables需要先關(guān)閉firewalld防火墻
且需要關(guān)閉selinux,不關(guān)閉時(shí),iptables不讀取配置文件
安裝iptables用
yum -y install iptables-services
就可以了
臨時(shí)關(guān)閉selinux使用
cetenforce 0
永久關(guān)閉selinux需要
vim /etc/sysconfig/selinux
將里面的SELINUX=enforcing更改為SELINUX=disabled
iptables的常用命令是
systemctl start iptables #啟動(dòng)
systemctl status?iptables #查看狀態(tài)
systemctl enable?iptables #設(shè)置開(kāi)機(jī)啟動(dòng)
iptables -h #獲取幫助
iptables -L #查看當(dāng)前規(guī)則
iptables -F #清除所有規(guī)則
防火墻常用命令是
systemctl start firewalld.service #啟動(dòng)
systemctl status firewalld.service #防火墻狀態(tài)
systemctl disable?firewalld.service #開(kāi)機(jī)禁用防火墻
systemctl stop?firewalld.service #停用防火墻
systemctl enable?firewalld.service #開(kāi)機(jī)啟動(dòng)防火墻
