centos ping: www.baidu.com: Name or service not known

ping www.baidu.com

报:
ping: www.baidu.com: Name or service not known

需要配置网卡和DNS

1:网卡配置

查看网卡名

[root@peiqi ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:4f:d1:a4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.50.129/24 brd 192.168.50.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::535f:310:8ec7:adeb/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:01:ab:1d:fd brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
[root@peiqi ~]#

配置网卡

[root@peiqi ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="76b3f408-ef3d-48c2-b745-ade75d659ac1"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.50.129
PREFIX=24
GATEWAY=192.168.50.2
DNS1= 192.168.50.2
DNS2 = 114.114.114.114
[root@peiqi ~]# 

2:配置DNS

[root@peiqi ~]# cat /etc/resolv.conf
search com 
nameserver 192.168.50.2
nameserver 114.114.114.114
[root@peiqi ~]# 

注意:

我使用NAT模式,网段需要和vm8网卡保持一致,下面截个图给大家看一下

下图是我的vm8网卡配置

centos ping: www.baidu.com: Name or service not known

 

 

 

下图是虚拟机的虚拟网卡编辑器

centos ping: www.baidu.com: Name or service not known

 

 经过这些修改后就可以配置网卡了

 

上一篇:架构的基本概述


下一篇:Codeforces Round #722 (Div. 1) / CF1528C Trees of Tranquillity(DFS序)