Linux关闭防火墙
1.service
- 基本语法:
service 服务名 start | stop | restart | status - 查看服务的方法:
cd /etc/init.d/服务名 ,发现只有两个服务保留在service - 案例实操:
(1)查看网络服务的状态
[root@hadoop100 桌面]#service network status
(2)停止网络服务
[root@hadoop100 桌面]#service network stop
(3)启动网络服务
[root@hadoop100 桌面]#service network start
(4)重启网络服务
[root@hadoop100 桌面]#service network restart
2.chkconfig设置后台服务的自启配置
- 基本语法
chkconfig (功能描述:查看所有服务器自启配置)
chkconfig 服务名 off (功能描述:关掉指定服务的自动启动)
chkconfig 服务名 on (功能描述:开启指定服务的自动启动)
chkconfig 服务名 --list (功能描述:查看服务开机启动状态) - 案例实操
(1)开启/关闭iptables(防火墙)服务的自动启动
[root@hadoop100 桌面]#chkconfig iptables on
[root@hadoop100 桌面]#chkconfig iptables off
3.systemctl
- 基本语法
systemctl start | stop | restart | status 服务名 - 案例实操
(1)查看防火墙服务的状态
[root@hadoop100 桌面]# systemctl status firewalld
(2)停止防火墙服务
[root@hadoop100 桌面]# systemctl stop firewalld
(3)启动防火墙服务
[root@hadoop100 桌面]# systemctl start firewalld
(4)重启防火墙服务
[root@hadoop100 桌面]# systemctl restart firewalld
4.systemctl设置后台服务的自启配置
- 基本语法
systemctl list-unit-files (功能描述:查看服务开机启动状态)
systemctl disable service_name (功能描述:关掉指定服务的自动启动)
systemctl enable service_name (功能描述:开启指定服务的自动启动) - 案例实操
(1)开启/关闭iptables(防火墙)服务的自动启动
[root@hadoop100 桌面]# systemctl enable firewalld.service
[root@hadoop100 桌面]# systemctl disable firewalld.service
5.关闭防火墙
- 临时关闭防火墙
(1)查看防火墙状态
[root@hadoop100桌面]# systemctl status firewalld
(2)临时关闭防火墙
[root@hadoop100桌面]# systemctl stop firewalld - 开机启动时关闭防火墙
(1)查看防火墙开机启动状态
[root@hadoop100桌面]# systemctl enable firewalld.service
(2)设置开机时关闭防火墙
[root@hadoop100桌面]# systemctl disable firewalld.service