Linux下防火墙和selinux的启动、关闭和查看
admin
2023-03-03 04:42:12
0

CentOS7.X下:

1.防火墙

防火墙状态查看:
[root@localhost sunan]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

其中Active为inactive (dead)为关闭状态,active (running)为开启状态

关闭防火墙命令:
[root@localhost sunan]# systemctl stop firewalld.service 
开启防火墙命令:
[root@localhost sunan]# systemctl start firewalld.service
永久禁用防火墙命令(开机不自启动)
[root@localhost sunan]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
永久启动防火墙命令(开机自启动)
[root@localhost sunan]# systemctl enable firewalld.service   
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.

CentOS6.X下:

1.防火墙

防火墙状态查看:
[root@localhost ~]# service iptables status
关闭防火墙命令:
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
开启防火墙命令:
[root@localhost ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
永久禁用防火墙命令(开机不自启动)
[root@localhost ~]# chkconfig iptables off
永久启动防火墙命令(开机自启动)

[root@localhost ~]# chkconfig iptables on

2.selinux(CentOS7.X同CentOS6.X)

查看selinux状态:
[root@localhost sunan]# getenforce 
Enforcing

selinux状态有三种模式:
enforcing:强制模式,代表selinux运行中,且已经正确的开始限制domain/type了。
permissive:宽容模式,代表selinux运作中,不过仅会有警告信息并不会实际限制domain/type的访问。这种模式可以用来作为selinux的debug之用
disabled:关闭,selinux没有实际运行。
命令设置SELinux,前提不能是disabled状态:

[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce  
Permissive

其中setenforce 0|1
0:设置为premissive状态;
1:设置为enforcing状态;
此设置:重启系统后无效。
修改配置文件,设置selinux为disabled状态:

[root@localhost ~]# vim /etc/selinux/config

SELINUX=disabled
SELINUXTYPE=targeted

保存,重启系统生效。

相关内容

热门资讯

农田边毒水直流,比排污更刺眼的... 5月7日,总台《焦点访谈》曝光了徐州贾汪区农谷大道路边沟存在水体污染问题。全长12公里的路边沟满是污...
28岁女子坠亡,施工方谎报 近日,深圳龙岗区应急管理局公布了《龙岗龙城香港中文大学(深圳)医学院项目Ⅰ标“12·26”一般高处坠...
中国没有表演场地,高市早苗不必... 【文/观察者网专栏作者 吕超】56年前,时任西德总理的勃兰特在华沙犹太隔离区起义纪念碑前自发下跪,因...
卢希望当选为信阳市人民政府市长 信阳市第六届人民代表大会公告(第十九号)信阳市第六届人民代表大会第五次会议于2026年5月8日选举卢...
中坚科技及董事长被出具警示函 【大河财立方消息】5月8日消息,浙江证监局对浙江中坚科技股份有限公司及相关人员采取出具警示函措施的决...
今年河南首场高温来袭!淮河以北... 今年首场高温来袭受高空西北气流控制,近期我省以晴好天气为主,由于太阳辐射较强,全省将进入快速升温通道...
极氪回应“低价代购极氪新车”信... 【大河财立方消息】5月8日,极氪法务部发布关于保障用户购车安全及权益的重要提醒。极氪表示,“关注到网...
云南燃气灶维修价格表 燃气灶在日常使用中,由于长期受到高温和燃气的腐蚀,会出现各种故障,如火力不足、起火困难、火苗不稳等问...
涉及眼镜、电视、耳机等 人工智... 工业和信息化部、国家市场监督管理总局、商务部等部门今天(5月8日)联合发布《人工智能终端智能化分级》...
上门维修电视价格表 上门维修电视价格表因地区、品牌、型号等情况而异,以下是一般参考价格,仅供参考: 1. 电视开机无信...