CentOS 7 firewall
查看已开放端口
> firewall-cmd --list-ports
开启端口
> firewall-cmd --zone=public --add-port=80/tcp --permanent
命令说明:
--zone
:作用域--add-prot
:添加端口,格式为(端口/通讯协议)--permanent
:永久生效,没有此参数重启后失效
删除端口
> firewall-cmd --zone=public --remove-port=80/tcp --permanent
重启防火墙
> firewall-cmd --reload
停止 firewall 服务
> systemctl stop firewalld.service
禁止 firewall 开机启动
> systemctl disable firewalld.service
查看防火墙状态
> firewall-cmd --state
CentOS 7 以下版本
开启端口
1、如要开放 80 端口,输入以下命令
> /sbin/iptables -T INPUT -p tcp --dport 80 -j ACCEPT
2、保存
> /etc/rc.d/init.d/iptables save
查看打开的端口
> /etc/init.d/iptables status
关闭端口
永久性,重启不失效
> chkconfig iptables on # 开启
> chkconfig iptables off # 关闭
即时性,重启复原
> service iptables start # 开启
> service iptables stop # 关闭
查看防火墙状态
> service iptables status
本文由 OceanicKang 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Nov 23, 2018 at 02:07 pm