I have a small dedi server on which I have installed Ubuntu 12.04. I access it via x2go since I have a desktop installed.

All worked fine until 2 days ago when, after a reboot, I lost any Internet access and started getting "Can't Resolve Hostname" errors.

If I try to ping google I get:

ping: unknown host google.com

To access some sites I added them to the hosts file and it works for most of them but not all. Of course this is just a temporary solution.

If I look into "System Settings - Network", I get this:

I am not very competent, so I don't know what other info to post but please ask anything you wish me to find out.

Thank you.

share|improve this question
    
Please check the output of ps -ef | grep -i "network" - this is to check if the networking process is running at all. If its not running then do sudo service networking start and see what happens afterwards. – heemayl Dec 8 '14 at 19:21
    
Hi heemayl thank you for your help, I executed both of your commands since I couldn't interpret the results of the first one. This is the result: prntscr.com/5eoi78 Thank you – Threshold Dec 8 '14 at 21:00
    
Did you change any network related settings recently? Give the output of ifconfig -a. Do you use static IP or DHCP? – heemayl Dec 8 '14 at 21:11
    
Could you please post the output of nm-tool. Also, can you ping 8.8.8.8 (Google DNS, to make sure your internet connection is working at all). I suspect some faulty DNS config... – Benjamin Maurer Dec 8 '14 at 21:27
    
@Benjamin Maurer Hi Benjamin, this is the output: prntscr.com/5epvgv Thank you – Threshold Dec 8 '14 at 22:38
up vote 5 down vote accepted

The problem is purely related to DNS. As there was no DNS nameserver entries in the /etc/resolv.conf file so the name resolution was failing while pinging by hostname to hosts outside your /etc/hosts entries.

In Ubuntu 12.04 the Network Manager package provides the network related functionality (rather than the old networking program), with the resolvconf (and dnsmasq to some extent) program providing the mass DNS functionality. But surprisingly in your case the resolvconf is not installed so we have to manually update the /etc/resolv.conf file.

So by running the command

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

we are basically setting the Google's free DNS server (8.8.8.8) as the nameserver.

This command will insert the text "nameserver 8.8.8.8" into the "/etc/resolv.conf" file and display the text on the screen too. In this way we have a working name resolver that will resolve the hostnames we give into IP addresses.

One very important thing to note here, we are using google's DNS which is not ideal, you should use your ISP's DNS here. Ask your ISP to give you their DNS address (can be multiple) and add the address as the nameserver. Although you can keep the Google's DNS as the backup in case your ISP's one fails for some reason. Let's assume that your ISP's DNS is vv.xx.yy.zz , so you need to run the following commands to make it as the primary DNS and keeping the Google's DNS as a backup.

echo "nameserver vv.xx.yy.zz" | sudo tee /etc/resolv.conf && echo -e "nameserver 8.8.8.8" "\nnameserver 8.8.4.4" | sudo tee -a /etc/resolv.conf

See the -a switch in tee command, that is used to append rather than overwrite. Here 8.8.4.4 is also Google's DNS.

You can add as many nameservers as you want in /etc/resolv.conf but that would be overkill. Just keep it simple yet compact.

share|improve this answer
    
Thanks a lot for your help and detailed answer. I actually understood what we did, instead of just pasting code in terminal, and should be able to repeat it myself should the problem arise again. I found my isp dns range so will try to set it as the primary one.In the code you posted at one point you write "nnameserver": is this a typo like I think or intentional? Thank you again. – Threshold Dec 9 '14 at 14:34
    
No problem. Thats intentional. Let me break this up for you. "\nnameserver 8.8.4.4" has two portions: One is \n that merely means "new line" and the other is literal nameserver 8.8.4.4. Here tee command will see the first portion (\n) and create a new line and then the second portion will be put at the start of the new line. This is to comply with the configuration file format which suggests that we must put the entries separately in a line by line manner. – heemayl Dec 9 '14 at 16:41
    
Ah, got it. I will try using my isp's dns in the coming days and report the results. Thank you very much. – Threshold Dec 10 '14 at 4:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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