前端之家收集整理的这篇文章主要介绍了
Centos 防火墙命令,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Centos7
Centos7 的firewalld 取代了iptables
查看开放端口
- firewall-cmd --list-ports
开启端口
- - -- --- --
开启范围端口 8080 - 9090范围的端口
- - -- ---- --
命令含义
- –zone
- –add-port=80/tcp
- –permanent
防火墙命令
- firewall-cmd --reload #重启firewall
- firewall-cmd --state #查看防火墙状态
- systemctl start firewalld.service #开启firewall
- systemctl stop firewalld.service #停止firewall
- systemctl disable firewalld.service #禁止firewall开机启动
Centos6
- #查看开放端口
- service iptables status
-
- #开启8080端口
- /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
-
- #开启命令:
- service iptables start
-
- #关闭命令:
- service iptables stop
-
- #永久关闭防火墙:
- chkconfig iptables off
可能发生的异常
1.启动或者关闭防火墙没任何的提示
- [root@ethnicity ~]
- [root@ethnicity ~]
2.查看防火墙的状态直接提示模块未加载
- [root@ethnicity ~]
- iptables: Firewall modules are not loaded.
- modprobe ip_tables
- modprobe iptable_filter
- [root@ethnicity ~]
- iptable_filter 2173 0
- ip_tables 9567 1 iptable_filter