CentOS6和
CentOS7两个版本的火墙操作操作工具不同,分别是iptables和firewalld
,如果想
CentOS7也可以使用iptables,需要安装iptables-services服务;
CentOS6关闭防火墙:
[root@test01 ~]# service iptables status -- 查看防火墙状态
[root@test01 ~]# service iptables stop -- 关闭防火墙
[root@test01 ~]# chkconfig iptables off -- 关闭防火墙开机自启动
CentOS7关闭防火墙:
[root@test01 ~]# systemctl status firewalld -- 查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Fri 2020-12-18 14:36:16 CST; 3s ago
Docs: man:firewalld(1)
Main PID: 7111 (firewalld)
CGroup: /system.slice/firewalld.service
└─7111 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
Dec 18 14:36:16 test01 systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 18 14:36:16 test01 systemd[1]: Started firewalld - dynamic firewall daemon.
[root@test01 ~]# systemctl stop firewalld -- 关闭防火墙
[root@test01 ~]# systemctl disable firewalld -- 关闭防火墙开机自启动
CentOS7使用iptables操作防火墙:
[root@test01 ~]# service iptables status -- 安装iptables-services之前
Redirecting to /bin/systemctl status iptables.service
Unit iptables.service could not be found.
[root@test01 ~]# yum install iptables-services -- 安装iptables-services
[root@test01 ~]# service iptables status -- 安装iptables-services之后
Redirecting to /bin/systemctl status iptables.service
● iptables.service - IPv4 firewall with iptables
Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled; vendor preset: disabled)
Active: inactive (dead)