medowlock
By:
medowlock

Ping: unknow host but can ping IPs

January 30, 2016 2.7k views
DNS DigitalOcean Ubuntu

After restarting my droplet [Ubuntu 15.10 x64], I keep getting "unknown host" message. Pinging IPs though works fine.

I cannot cat resolv.conf, it says "No such file or directory" although on ls -l it does appear as a linked file to /run/resolvconf/resolv.conf. which I cannot access either - no resolvconf folder in run dir.

In /etc/network/interfaces, I have dns-nameservers 8.8.8.8 8.8.4.4 under eth0.

Sorry if any of the above information is irrelevant, I am a Linux noob.
Any help would be greatly appreciated!

7 comments
  • Note: your system probably requires you to use 'sudo' in front of your privilege access commands, or need to issue 'su root' to gain full root access. Try

    sudo cat /etc/resolve.conf 
    

    So, reboot cleared out your DNS cache and now your DNS servers have gone dark. Can you ping IP address 8.8.8.8 or 8.8.4.4 ?

  • I always log in with root, but tried sudo cat /etc/resolve.conf anyway. The result is the same "No such file or directory".

    I can ping both 8.8.8.8 and 8.8.4.4. I can also ping the gateway.

    One additional note though, I was playing around with ufw before restarting the droplet. However, after discovering this issue, I have inactivated it, but the problem persists.

  • @medowlock - Does your system have a /var/run/resolvconf/resolv.conf
    If it's there, for diagnostic purpose, create a link to it in etc

    ln -s /var/run/resolvconf/resolv.conf /etc/resolv.conf
    

    Then try ping digitalocean.com

  • This is where it gets really weird, at least for me. When listing the contents of /etc I can see there is a file resolv.conf symlinked to /run/resolvconf/resolv.conf. However

    root@ubuntu-512mb-fra1-01:/run# cd /run/resolvconf
    -bash: cd: /run/resolvconf: No such file or directory
    

    And running the command you mentioned gives

    root@ubuntu-512mb-fra1-01:~# ln -s /var/run/resolvconf/resolv.conf /etc/resolv.conf
    ln: failed to create symbolic link ‘/etc/resolv.conf’: File exists
    root@ubuntu-512mb-fra1-01:~# cat /etc/resolv.conf
    cat: /etc/resolv.conf: No such file or directory
    
    root@ubuntu-512mb-fra1-01:~# ping digitalocean.com
    ping: unknown host digitalocean.com
    

    Thanks for all your answers and patience!

  • @medowlock - Oops, need to remove the existing file before the link command:

    mv /etc/resolv.conf /etc/resolv.conf.hold
    ln -s /var/run/resolvconf/resolv.conf /etc/resolv.conf
    
  • @gndo No luck.

    But I did manage to get it working again. What I did was remove the symlink altogether and created the resolv.conf file manually and added to its contents:

    nameserver 8.8.8.8
    nameserver 8.8.4.4
    
  • @medowlock - So that means that the program (resolvconf) that dynamically creates that file, had failed and probably wrote something in your system logs. At some point you will want to look for that and fix the root cause since a future update could mess you up again.

1 Answer

This question was answered by @medowlock:

@gndo No luck.

But I did manage to get it working again. What I did was remove the symlink altogether and created the resolv.conf file manually and added to its contents:

nameserver 8.8.8.8
nameserver 8.8.4.4

View the original comment

Have another answer? Share your knowledge.