关于Linux6/7系关闭SElinux和防火墙,配置网络IP地址
关闭SElinux
什么是SElinux?
SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是 Linux历史上最杰出的新安全子系统。
笼统来说,就是我的电脑我做主,默认关闭。
1.getenforce
命令查看SELinux状态,显示enforcing表示SElinux未关闭。
[root@localhost ~]# getenforce
Enforcing
2.setenforce 0
命令关闭SELinux,显示permissive表示SElinux关闭。
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
3.关闭SELinux自启动,编辑vim /etc/selinux/config
,将SELINUX=enforcing
修改成SELINUX=disabled
,保存退出wq!
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
4 getenforce
命令查看SELinux状态,显示Disabled表示SElinux关闭。
[root@localhost ~]# getenforce
Disabled
关闭防火墙
如果不去关闭防火墙,对外部链接用限制,同样,我的电脑我做主
6系、7系关闭指令不同
1.查看防火墙状态
[root@localhost ~]# service iptables status \\6系
[root@localhost ~]# systemctl status firewalld \\7系
2.关闭防火墙
[root@localhost ~]# service iptables stop \\6系
[root@localhost ~]# systemctl stop firewalld \\7系
3.关闭防火墙自启
[root@localhost ~]# chkconfig iptables off \\6系
[root@localhost ~]# systemctl disable firewalld \\7系
配置网络
1.查看网卡
[root@localhost ~]# ifconfig ///显示内容为网卡信息
2.打开cd /etc/sysconfig/network_scripts
,查看文件ls
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
3.编辑vim (根据自己的网卡名来)
,添加IPADDR=
IP地址,NETMASK=
子网掩码,GATEWAY=
网关,将ONBOOT=no
改为yes,BOOTPROTO=dhcp
改为static,其他内容不用改,保存退出wq!
[root@localhost network-scripts]# vim ifcfg-ens192
BOOTPROTO="static"
ONBOOT="yes"
IPADDR="192.168.X.XXX"
NETMASK="255.255.255.0"
GATEWAY="192.168.X.1"
DNS1="8.8.8.8"
4.重启网络service network restart
[root@localhost network-scripts]# service network restart
Restarting network (via systemctl): [ OK ]
5.ping网关是否连通
[root@localhost network-scripts]# ping 192.168.X.1
PING 192.168.X.1 (192.168.X.1) 56(84) bytes of data.
64 bytes from 192.168.X.1: icmp_seq=1 ttl=255 time=1.16 ms
64 bytes from 192.168.X.1: icmp_seq=2 ttl=255 time=2.11 ms
64 bytes from 192.168.X.1: icmp_seq=3 ttl=255 time=1.18 ms
64 bytes from 192.168.X.1: icmp_seq=4 ttl=255 time=1.31 ms
本身也是在学习过程中,记下一笔,希望能有所帮助