探索,發現,愛好、學習,記錄,分享。
學海無涯,天涯若比鄰,三人行,必有我師。

Centos 7 查看端口,防火墙开放与关闭。

Centos 7 firewall 命令:

查看已经开放的端口:

firewall-cmd --list-ports 

开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent 

命令含义:

–zone #作用域

–add-port=80/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效

重启防火墙

firewall-cmd --reload #重启firewall systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 

CentOS 7 以下版本 iptables 命令

如要开放80,22,8080 端口,输入以下命令即可

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

然后保存:

/etc/rc.d/init.d/iptables save

查看打开的端口:

/etc/init.d/iptables status

关闭防火墙 
1) 永久性生效,重启后不会复原

开启: chkconfig iptables on

关闭: chkconfig iptables off

2) 即时生效,重启后复原

开启: service iptables start

关闭: service iptables stop

版權聲明:本文采用知識共享 署名4.0國際許可協議 [BY-NC-SA] 進行授權
轉載事宜:如需轉載需徵得應允,轉載必須注明來源於本站的信息。
文章名称:《Centos 7 查看端口,防火墙开放与关闭。》
文章链接:https://www.thefreesky.com/blog/25366.html
本站資源僅供個人學習交流,請於下載後24小時內刪除,不允許用於商業用途,否則法律問題自行承擔。

評論 抢沙发