CentOS 6
查看系统版本号
cat /etc/centos-release
笔者在这里使用的是CentOS 6.10 (Final)
查看防火墙状态
service iptables status
或
/etc/init.d/iptables status
上述两条命令是等价的
如下述两张图所示
若结果类似上述两张图,则表示防火墙处于开启状态
若结果类似上述两张图,则表示防火墙处于关闭状态
暂时关闭防火墙(重启后会重新开启)
service iptables stop
或
/etc/init.d/iptables stop
启动防火墙
service iptables start
或
/etc/init.d/iptables start
上述两条命令是等价的
如下述两张图所示
永久关闭防火墙
chkconfig iptables off
设置为开机不自动启动,即可永久关闭防火墙
永久开启防火墙
chkconfig iptables on
设置为开机自动启动,即可永久开启防火墙
CentOS 7
查看系统版本号
cat /etc/centos-release
笔者在这里使用的是CentOS 7.5.1804 (Core)
查看防火墙状态
firewall-cmd –state
如果结果为running,则表示防火墙处于开启状态
如果结果为not running,则表示防火墙处于关闭状态
暂时关闭防火墙(重启后会重新开启)
systemctl stop firewalld.service
启动防火墙
systemctl start firewalld.service
永久关闭防火墙
systemctl disable firewalld.service
设置为开机不自动启动,即可永久关闭防火墙
永久开启防火墙
systemctl enable firewalld.service
设置为开机自动启动,即可永久开启防火墙
CentOS 6和CentOS 7的对比
对比上面的命令可以看出CentOS6和CentOS 7的一些区别
防火墙系统
CentOS 6及以前的版本使用的是使用iptables控制的防火墙系统,而在CentOS 7中推出了新的防火墙系统,即firewall系统。
服务
在CentOS 6中,服务由service (/etc/init.d)和chkconfig控制,而在CentOS 7中,服务由systemctl控制,其统一了service和chkconfig。
发表回复