1. 程式人生 > >Centos7防火墻操作

Centos7防火墻操作

nta 防火墻配置 iptables cep com rep stop 增加 開機

CentOS 7.0默認使用的是firewall作為防火墻

啟動一個服務:systemctl start firewalld.service 關閉一個服務:systemctl stop firewalld.service 重啟一個服務:systemctl restart firewalld.service 顯示一個服務的狀態:systemctl status firewalld.service 在開機時啟用一個服務:systemctl enable firewalld.service 在開機時禁用一個服務:systemctl disable firewalld.service
查看服務是否開機啟動:systemctl is-enabled firewalld.service;echo $? 查看已啟動的服務列表:systemctl list-unit-files|grep enabled 查看已經開放的端口:firewall-cmd --list-ports 開啟端口:firewall-cmd --zone=public --add-port=80/tcp --permanent

      命令含義:

          –zone #作用域

          –add-port=80/tcp #添加端口,格式為:端口/通訊協議

           –permanent #永久生效,沒有此參數重啟後失效

CentOS 7默認使用的是firewall作為防火墻,使用iptables必須重新設置一下

1、直接關閉防火墻

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall開機啟動 2、設置 iptables service yum -y install iptables-services 如果要修改防火墻配置,如增加防火墻端口3306: vim /etc/sysconfig/iptables 增加規則 -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
保存退出後 systemctl restart iptables.service #重啟防火墻使配置生效 systemctl enable iptables.service #設置防火墻開機啟動 最後重啟系統使設置生效即可。

Centos7防火墻操作