新聞中心
centos從7版本開(kāi)始默認(rèn)用的是firewalld,這個(gè)是基于iptables的,雖然有iptables的核心,但是iptables的服務(wù)是沒(méi)安裝的。所以只要先關(guān)閉firewalld服務(wù),再安裝iptables服務(wù)即可。

目前成都創(chuàng)新互聯(lián)公司已為超過(guò)千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管運(yùn)營(yíng)、企業(yè)網(wǎng)站設(shè)計(jì)、周口網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶(hù)導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶(hù)和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
1、關(guān)閉firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開(kāi)機(jī)啟動(dòng)
2、安裝iptables防火墻
yum install -y iptables-services #安裝iptables
vim /etc/sysconfig/iptables #編輯防火墻配置文件
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
保存退出
3、重啟防火墻
systemctl restart iptables.service #最后重啟防火墻使配置生效
systemctl enable iptables.service #設(shè)置防火墻開(kāi)機(jī)啟動(dòng)
4、其他相關(guān)命令
systemctl disable iptables #禁止iptables服務(wù)
systemctl stop iptables #暫停服務(wù)
systemctl enable iptables #解除禁止iptables
systemctl start iptables #開(kāi)啟服務(wù)
service iptables save #因?yàn)橐呀?jīng)添加iptables服務(wù),故該命令可以運(yùn)行;若沒(méi)有之前的添加服務(wù)則不能運(yùn)行
service iptables status #查看iptables服務(wù)狀態(tài)
分享名稱(chēng):CentOS7配置iptables
本文網(wǎng)址:http://fisionsoft.com.cn/article/ccscjpp.html


咨詢(xún)
建站咨詢(xún)
