0

I host an ubuntu server at a data center and worked well for years till last night the server can not ping itself by host name. No config has been changed. Here are what it can/can not do now.

  • From outside, I can ping the server both by its static IP, and by its hostname.
  • From server, I can ping any website (google, yahoo, ...).
  • From server, I can ping localhost, and can ping the IP of server itself.
  • From server, I can not ping sever itself by its hostname.

Here is /etc/network/interfaces:

source /etc/network/interfaces.d/* 

auto lo
iface lo inet loopback

auto enp5s0

iface enp5s0 inet static
address xxx.xxx.xxx.134
netmask 255.255.255.128
broadcast xxx.xxx.xxx.255
gateway xxx.xxx.xxx.129
dns-nameservers 192.168.1.1 8.8.8.8 8.8.4.4

and /etc/resolv.conf:

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4

and /etc/resolvconf/resolv.conf.d/head:

nameserver 8.8.8.8
nameserver 8.8.4.4

and the output of route -n is:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         xxx.xxx.xxx.129 0.0.0.0         UG    0      0        0 enp5s0
xxx.xxx.xxx.128 0.0.0.0         255.255.255.128 U     0      0        0 enp5s0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0

These configs worked for years. Wondering what happened? Thanks.

  • Just put your servers IP + the hostname(s) into your /etc/hosts file. x.x.x.x somehostname.com hostname – Michael D. Apr 10 at 20:48
  • When you run the ping command, what IP address does it say it’s using? – G-Man Apr 10 at 20:56
  • @G-Man ping stalls. – Sia Apr 11 at 3:05
  • @Michael D, that worked, thank you! Wondering how come I did not need it before. – Sia Apr 11 at 3:05
0

Check /etc/hosts. Probably there's a line with the name of the server and an incorrect IP

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.