---
title: "centos配置固定IP， 网卡重启及DNS配置"
author: "mukeliang728"
date: "2021-10-07T12:33:59Z"
tags: []
categories: ["操作系统"]
slug: "centos-ip-dns"
draft: false
lastmod: "2021-10-11T11:49:23Z"
id: 2521127
url: "https://mukeliang.iteye.com/blog/2521127"
---

# [VirtualBox最小安装cetnos7后配置固定IP](https://blog.csdn.net/sunt2018/article/details/103684856)

 

**centos8重启网止和7不同，具体如下：**

查看网卡设备详细信息

 

nmcli device show / nmcli device show eth0

 

2-1-3、查看网卡设备状态

nmcli device status

 

2-3-1、查看网卡具体信息

nmcli connection show eth0

 

3-1、启动

nmcli connection up eth0

 

3-2、停止

nmcli connection down eth0（可被自动激活）

nmcli device disconnect eth0（禁止被自动激活）

 

3-3、重启

nmcli connection reload

 

 

**配置DNS**

dns如果没有配置，只能ping通IP地址，无法ping通域名，会报ping:www.baidu.com:Name or service not known.

2种解决方案如下：

 

**1.直接在/ect/syconfig/network-scripts/ifcfg-ens0s3里面添加:**

DNS1=8.8.8.8  
DNS2=114.114.114.114

然后运行命令:

cat /etc/resolv.conf   
就会出现:

\[root@localhost hadoop]# cat /etc/resolv.conf  
\# Generated by NetworkManager  
nameserver 8.8.8.8  
nameserver 114.114.114.114

 

**2. 添加dns服务器**

vi /etc/resolv.conf

在文件中添加如下两行：

nameserver 8.8.8.8  
nameserver 8.8.4.4