centos 网卡重启/防火墙/selinux/hosts-
更新:HHH   时间:2023-1-7


1、centos6网卡重启:service network restart
centos7网卡重启:systemctl restart network
[root@centos7 ~]# systemctl restart network
网卡配置文件:
[root@centos7 network-scripts]# cat -n ifcfg-ens33
[root@centos7 network-scripts]# pwd
/etc/sysconfig/network-scripts
1 TYPE=Ethernet
2 PROXY_METHOD=none
3 BROWSER_ONLY=no
4 BOOTPROTO=dhcp
5 DEFROUTE=yes
6 IPV4_FAILURE_FATAL=no
7 IPV6INIT=yes
8 IPV6_AUTOCONF=yes
9 IPV6_DEFROUTE=yes
10 IPV6_FAILURE_FATAL=no
11 IPV6_ADDR_GEN_MODE=stable-privacy
12 NAME=ens33
13 UUID=8bfc7f02-2ae1-42e2-8c97-a0bc98135071
14 DEVICE=ens33
15 ONBOOT=yes
网卡配置文件:
设备类型:TYPE=Ethernet
地址分配模式:BOOTPROTO=static
网卡名称:NAME=ens33
是否启动:ONBOOT=yes
IP地址:IPADDR=192.168.30.102
子网掩码:NETMASK=255.255.255.0
网关地址:GATEWAY=192.168.30.1
DNS地址:DNS1=192.168.30.1

2、DNS配置文件:cat /etc/resolv.conf
主机和IP绑定:cat /etc/hosts
主机名:cat /etc/hostname

3、关闭防火墙并设置开机不启动
centos 7

查看防火墙状态:systemctl status firewalld
关闭:systemctl stop firewalld
开启:systemctl start firewalld
开机自动关闭:systemctl disable firewalld
开机自动启动:systemctl enable firewalld

centos6
关闭防火墙
chkconfig iptables off
开启防火墙
chkconifg iptables on

查看开机是否启动:chkconfig --list|grep network(centos 6 )
chkconfig iptables --list

4、临时和永久关闭Selinux
临时关闭:
getenforce
[root@centos7 ~]# getenforce
Enforcing

setenforce 0
[root@centos7 ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]

setenforce:SELinux is disabled

修改配置文件:
vim /etc/selinux/config

返回云计算教程...