CentOS操作系統(tǒng)中的防火墻可以使用firewalld或iptables來(lái)進(jìn)行配置。
firewalld(默認(rèn)):
查看當(dāng)前狀態(tài):systemctl status firewalld
開(kāi)啟/關(guān)閉防火墻服務(wù):sudo systemctl start/stop firewalld
設(shè)置開(kāi)機(jī)自動(dòng)啟動(dòng)/不啟動(dòng):sudo systemctl enable/disable firewalld
添加規(guī)則:sudo firewall-cmd --zone=public --add-port=80/tcp --permanent (將TCP端口80永久性地打開(kāi))
移除規(guī)則:sudo firewall-cmd --zone=public --remove-port=80/tcp --permanent (從公共區(qū)域刪除TCP端口80的規(guī)則)
重新加載防火墻配置:sudo firewall-cmd --reload
iptables:
查看當(dāng)前狀態(tài):service iptables status
開(kāi)啟/關(guān)閉防火墻服務(wù):sudo service iptables start/stop
設(shè)置開(kāi)機(jī)自動(dòng)啟動(dòng)/不啟動(dòng):sudo chkconfig iptables on/off
添加規(guī)則:sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT (接受TCP端口80的連接)
保存規(guī)則并重新加載:sudo /etc/init.d/iptables save && sudo /etc/init.d/iptables restart文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-820301.html
注意:在CentOS7及更高版本上,建議使用firewalld而非iptables。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-820301.html
到了這里,關(guān)于CentOS防火墻基本操作的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!