linux防火墙和selinux和主机名

        防火墙顾名思义就是保证安全性的机制,把一些操作拦截没保证计算机的安全程度。

安全级别大致有这么几种A1 B1、B2、B3、C1、C2、D级别。从安全程度高到低。

linux的防火墙firewall有一些操作。

查看防火墙状态:

[root@nullpointerexception ~ ]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2019-10-23 17:33:13 CST; 1min 37s ago
     Docs: man:firewalld(1)
  Process: 975 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 975 (code=exited, status=0/SUCCESS)

Oct 23 16:18:35 nullpointerexception systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 23 16:18:39 nullpointerexception systemd[1]: Started firewalld - dynamic firewall daemon.

Active: inactive (dead) 这个是活动情况,dead表示没开启防火墙。

暂时关闭防火墙

[root@nullpointerexception ~ ]# systemctl stop firewalld

永久关闭防火墙

[root@nullpointerexception ~ ]# systemctl disable firewalld

开启防火墙

[root@nullpointerexception ~ ]# systemctl restart firewalld

查看防火墙规则

[root@nullpointerexception ~ ]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination      

清空防火墙规则

[root@nullpointerexception ~ ]# iptables -F

selinux 这个是redhead公司和美国的国安局公共制作的加强linux安全性的东西,他能给每个文件定下一个签名权限,如果签名不匹配那么这个文件就不能被人然看到。

查看selinux 状态

[root@nullpointerexception ~ ]# getenforce
Disabled

disable 没启动。

查看selinux设置

[root@nullpointerexception ~ ]# sestatus
SELinux status:                 disabled

临时关闭selinux

[root@nullpointerexception ~ ]# setenforce 0

永久关闭selinux
修改配置文件,将SELINUX后的属性改为disable

[root@nullpointerexception ~ ]# vi /etc/sysconfig/selinux 
SELINUX=disabled

主机名及主机名的hosts解析文件。

[root@nullpointerexception ~ ]# hostnamectl set-hostname sssss

也可以修改/etc/hostname配置文件,也是永久生效的,但是Fedora的不是修改这里。

在hosts文件里加上一行IP和主机名作为解析,当然前两行是不能改动的。

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.12.4 nullpointerexception

hosts是linux中作为IP地址和域名快速解析的文件,其中包含了ip和主机名之间的映射,主机别名。在没有配置域名服务器时,系统上所有网络相关的程序都是通过读取hosts文件来进行的。

优先级:DNS缓存>hosts>DNS服务

CentOS初始化:
当拿到一台CentOS系统的服务器时先做几个操作。
1、修改主机名

[root@nullpointerexception ~]# hostnamectl set-hostname nullpointerexception
[root@nullpointerexception ~]# cat /etc/sysconfig/network
# Created by anaconda
[root@nullpointerexception ~]# cat /etc/hostname 
nullpointerexception

2、关闭防火墙

[root@nullpointerexception ~]# systemctl disable firewalld
[root@nullpointerexception ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

3、关闭selinux
修改配置文件

[root@nullpointerexception ~]# vi /etc/sysconfig/selinux 
SELINUX=disabled
[root@nullpointerexception ~]# reboot

重启才能生效

4、配置IP地址
修改ens33网卡配置文件设置IP、子网掩码和网关

[root@nullpointerexception ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 
//IPADDR  NETMASK  GETWAY  DNS 等等。。

5、修改hosts配置文件
在其中增加IP和主机名的映射

[root@nullpointerexception ~]# vi /etc/hosts
172.16.12.4 nullpointerexception

6、DNS服务

[root@nullpointerexception ~]# vi /etc/resolv.conf 
nameserver 8.8.8.8
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值