If a Linux (CentOS) server is pinged to the domain name, the following prompt is displayed:
# Ping www.sina.com
Ping: unknown host www.sina.com
If the network is correct, follow these steps:
1) Confirm that the Domain Name Server is set
# Cat/etc/resolv. conf
Nameserver 8.8.8.8# (Google's public DNS Service)
Nameserver 8.8.4.4# (Google's public DNS Service)
2) Confirm that the gateway has set/confirmed that the route table is normal
# Netstat-rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.10.10.1 0.0.0.0 UG 0 0 0 eth0
If not, add the gateway as follows:
# Route add default gw 10.245.75.1
# Grep GATEWAY/etc/sysconfig/network-scripts/ifcfg *
/Etc/sysconfig/network-scripts/ifcfg-eth0: GATEWAY = 10.245.75.1
3) confirm that dns resolution is available
# Grep hosts/etc/nsswitch. conf
Hosts:Files dns
The above 1) 2) 3) Just confirm the problem. I like to manually write the configuration file to solve the problem once.
After configuring the/etc/sysconfig/network-scripts/ifcfg-eth0 file, restart the network service:
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = "eth0"
NM_CONTROLLED = "yes"
ONBOOT = yes
TYPE = Ethernet
BOOTPROTO = static
IPADDR = 10.245.75.240
# PREFIX = 24
GATEWAY = 10.245.75.1
DNS1 = 8.8.8.8
DNS2 = 8.8.4.4
DEFROUTE = yes
20174_failure_fatal = yes
IPV6INIT = yes
NAME = "System eth0"
UUID = xxxxxxxx-xxxx-xxxxxxxxxxxx # uuid
HWADDR = xx: xx# Hwaddr
NETWORKING = yes
# Service network restart