有些用戶,之前一直習(xí)慣centos5.x? 6.x的iptables防火墻遂庄,一旦換到centos7.x上進(jìn)行操作的時候就麻爪了寥院。
今天給大家?guī)硪恍?shí)際可行的命令。演示操作給大家看一下
第一條:查看 firewall 防火墻狀態(tài)涛目,可使用一下命令查看
1秸谢、[root@localhost ~]# firewall-cmd --state?
2、[root@localhost ~]# systemctl status firewalld.service
反饋結(jié)果如下
運(yùn)行狀態(tài)
不運(yùn)行狀態(tài)
第二條:查看完防火墻狀態(tài)后霹肝,可以選擇運(yùn)行或關(guān)閉估蹄,可使用一下命令
啟動:[root@localhost ~]#?? systemctl start firewalld
停止:[root@localhost ~]#?? systemctl stop firewalld
重啟:[root@localhost ~]#??systemctl restart firewalld
或
啟動:[root@localhost ~]#? systemctl start firewalld.service
關(guān)閉:[root@localhost ~]#? systemctl stop firewalld.service
重啟:[root@localhost ~]#? systemctl restart firewalld.service? ? ?(以上命令輸入后無反饋,不做圖片演示沫换。執(zhí)行后可用第一條命令查看)
第三條:開機(jī)啟用或禁用防火墻
啟用:[root@localhost ~]#? systemctl enable firewalld.service
禁用:[root@localhost ~]#? systemctl disable firewalld.service
或
啟用:[root@localhost ~]# systemctl enable firewalld
禁用: [root@localhost ~]# systemctl disable firewalld
查看是否開機(jī)啟動
?[root@localhost ~]#??systemctl is-enabled firewalld.service
第四條:防火墻 添加/刪除/查看 服務(wù)命令
1臭蚁、查看已添加的服務(wù)
?[root@localhost ~]#?firewall-cmd --list-services
2、?添加服務(wù)
[root@localhost ~]#? firewall-cmd --add-service=http (添加http服務(wù)讯赏,等同于開放80端口)
3垮兑、刪除服務(wù)
[root@localhost ~]#?firewall-cmd --remove-service=http?
?第五條:防火墻 添加/刪除/查看開放的防火墻
1、查看開啟了哪些端口
? [root@localhost ~]#?firewall-cmd --zone=public --list-ports (防火墻放行服務(wù)時漱挎,自動放行的默認(rèn)服務(wù)端口系枪,如22)
?2、添加一個端口到防火墻
?[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent? (permanent是永久生效的意思磕谅,部署的話私爷,重啟機(jī)器之后雾棺,添加的端口會自動刪除)
?3、刪除一個防火墻端口
[root@localhost ~]#?firewall-cmd --zone=public --remove-port=80/tcp --permanent?
第六條:第四当犯、五條命令執(zhí)行后垢村,需要輸入 重載/更新防火墻 命令
[root@localhost ~]# firewall-cmd --reload
更新反饋值:success(成功)割疾,添加或刪除的規(guī)則就會立刻生效
網(wǎng)云互聯(lián)(www.94ip.net/www.94ip.com)是一家從事服務(wù)器安全防護(hù)嚎卫、入侵檢測、服務(wù)器代維等為一體的公司宏榕,免費(fèi)服務(wù)器安全檢測拓诸,并有24小時在線運(yùn)維工程師為您服務(wù)。