CentOS6.5
1、查看防火墙的状态:
[root@localhost ~]$ service iptable status
2、关闭防火墙
[root@localhost ~]$ servcie iptables stop --临时关闭防火墙
[root@localhost ~]$ chkconfig iptables off --永久关闭防火墙
CentOS 7.2
1、检查防火墙的状态:
从centos7开始使用 systemctl 来管理服务和程序,包括了 service 和 chkconfig 。
[root@localhost ~]$ systemctl status firewalld.service
2、关闭防火墙:
[root@localhost ~]$ systemctl stop firewalld.service --停止firewall
[root@localhost ~]$ systemctl disable firewalld.service --禁止firewall开机启动
CentOS 7的 firewalld.service 命令
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $?
查看已启动的服务列表:systemctl list-unit-files|grep enabled
CentOS 7 以下版本 iptables 命令
关闭防火墙
1) 永久性生效,重启后不会复原
chkconfig iptables on --开启
chkconfig iptables off --关闭
2) 即时生效,重启后复原
service iptables start --开启
service iptables stop --关闭
3)查看防火墙状态:
service iptables status