防火墙查看和配置命令
- CentOS7 新防火墙使用的是firewall(firewall是centos7下管理iptables的新命令)
firewall防火墙
1.查看firewall服务状态
systemctl status firewalld
2.查看firewall的状态
firewall-cmd --state
- not running (未运行)
- running(正在运行)
3.开启firewall防火墙
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
4.查看防火墙开放端口号
firewall-cmd --zone=public --list-ports
5.设置开放端口号
firewall-cmd --add-port=8090/tcp --permanent
6.重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
参数解释
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;
iptables防火墙
1.查看防火墙状态
service iptables status
2.停止防火墙
service iptables stop
3. 启动防火墙
service iptables start
4. 重启防火墙
service iptables restart
5. 永久关闭防火墙
chkconfig iptables off
6. 永久关闭后重启
chkconfig iptables on
7.开启端口号
// 打开iptables 并编辑
vim /etc/sysconfig/iptables
# 加入如下代码 并存并退出(wq)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
// 重启 应用配置文件
service iptables restart