linux关闭防火墙之service和chkconfig命令、进程运行级别

service 后台服务管理

  1. 基本语法
    service 服务名 start (功能描述:开启服务)
    service 服务名 stop (功能描述:关闭服务)
    service 服务名 restart (功能描述:重新启动服务)
    service 服务名 status (功能描述:查看服务状态)
  2. 经验技巧
    查看服务的方法:/etc/init.d/服务名
[root@hadoop100 init.d]# pwd
/etc/init.d
[root@hadoop100 init.d]# ls -al
  1. 案例实操
    (1)查看网络服务的状态
[root@hadoop100 桌面]#service network status

(2)停止网络服务

[root@hadoop100 桌面]#service network stop

(3)启动网络服务

[root@hadoop100 桌面]#service network start

(4)重启网络服务

[root@hadoop100 桌面]#service network restart

(5)查看系统中所有的后台服务

[root@hadoop100 桌面]#service --status-all

查看防火前状态、关闭防火墙、开启防火墙:

[root@hadoop100 桌面]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

[root@hadoop100 桌面]# service iptables stop
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
[root@hadoop100 桌面]# service iptables start
iptables:应用防火墙规则:                                 [确定]

service命令关闭防火墙后,重启后会自动启动,只是临时关闭。

chkconfig 设置后台服务的自启配置

  1. 基本语法
    chkconfig (功能描述:查看所有服务器自启配置)
    chkconfig 服务名 off (功能描述:关掉指定服务的自动启动)
    chkconfig 服务名 on (功能描述:开启指定服务的自动启动)
    chkconfig 服务名 --list (功能描述:查看服务开机启动状态)
  2. 案例实操
    (1)关闭iptables服务的自动启动
[root@hadoop100 桌面]#chkconfig iptables off

(2)开启iptables服务的自动启动

[root@hadoop100 桌面]#chkconfig iptables on

进程运行级别

Linux进程运行级别:
linux进程运行级别

关闭防火墙

  1. 临时关闭防火墙
    (1)查看防火墙状态
[root@hadoop100桌面]# service iptables status

(2)临时关闭防火墙

[root@hadoop100桌面]# service iptables stop

2.开机启动时关闭防火墙
(1)查看防火墙开机启动状态

[root@hadoop100桌面]#chkconfig iptables --list	

(2)设置开机时关闭防火墙

[root@hadoop100桌面]#chkconfig iptables off
[root@hadoop100 桌面]# chkconfig iptables --list
iptables       	0:关闭	1:关闭	2:启用	3:启用	4:启用	5:启用	6:关闭
[root@hadoop100 桌面]# chkconfig iptables off
[root@hadoop100 桌面]# chkconfig iptables --list
iptables       	0:关闭	1:关闭	2:关闭	3:关闭	4:关闭	5:关闭	6:关闭
[root@hadoop100 桌面]# chkconfig iptables on
[root@hadoop100 桌面]# chkconfig iptables --list
iptables       	0:关闭	1:关闭	2:启用	3:启用	4:启用	5:启用	6:关闭

引用自尚硅谷课件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值