Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Cannot resolve host name

Tue Apr 23, 2013 8:36 pm

I am trying to setup a new rasberry pi and I get the message "cannot resolve hostname." I have edited the /etc/resolv.conf file.
nameserver 8.8.8.8
The /etc/network/interfaces file reads
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface default inet dhcp

I set up the network/interfaces file with a static ip at one point but that did not work either. Could someone please tell me what I am missing. I am a newbie at all of this.

Thanks very much in advance.

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Cannot resolve host name

Tue Apr 23, 2013 9:01 pm

If you use DHCP the resolv.conf file gets overwritten.
Try this;

Code: Select all

sudo nano /etc/dhcp/dhclient.conf
Add a line saying this (below) after the line that says #supersede domain-name

Code: Select all

prepend domain-name-servers 8.8.8.8, 8.8.4.4;

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Tue Apr 23, 2013 10:00 pm

Thanks. I tried that and still not able to resolve host name.

aaa801
Posts: 428
Joined: Mon Jun 04, 2012 9:06 pm
Location: Berkshire

Re: Cannot resolve host name

Wed Apr 24, 2013 9:22 am

Dsosb wrote:Thanks. I tried that and still not able to resolve host name.
ping 8.8.8.8 ?

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Cannot resolve host name

Wed Apr 24, 2013 10:54 am

I think the first port of call would be to test that you can contact machines locally by IP address. So try and ping your router with ping 192.168.0.1 for instance. Also check that you get link lights on the Pi's strip of LEDs.

If you type

Code: Select all

cat /etc/resolv.conf
...and you see the two google DNS server IP addresses are shown then you know the edit I suggested has worked.

Code: Select all

nameserver 8.8.8.8
nameserver 8.8.4.4
However what address are you trying to ping?
If ping www.google.com works but the specific one you're trying to ping doesn't then it may be a problem with that specific host. Is this host that you're trying to resolve a local machine on your network? If so, and the machine is running Windows then you might need to install something called Winbind to be able to ping it by name. Just a guess :)

Code: Select all

sudo apt-get install winbind

User avatar
morphy_richards
Posts: 1603
Joined: Mon Mar 05, 2012 3:26 pm
Location: Epping Forest
Contact: Website

Re: Cannot resolve host name

Wed Apr 24, 2013 2:06 pm

I've had some similar issues to this but had some success by adding

dns-nameservers x.x.x.x

to a line in my /etc/network/interfaces

That seemed to over-ride the settings in resolv.conf

Don't know if that would be helpful in your case?

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 2:28 pm

Tried to get back into /etc/network/interfaces and get the message
E325 Attention
Found a swap file named /etc/network/.interfaces.swp.
How do I delete that file? I try to get back to the prompt but when I hit enter it takes me into the interfaces file. If I save it and then try to go back in I get the same message. I don't know how to delete the swap file.
Thanks for your help and attention to this!

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 2:50 pm

Please ignore my last question. I found out how to delete the swp file. I tried to ping 8.8.8.8 and got the message Network is unreachable. I get the same message when I ping my router. I think I will try putting in a static IP address again and see if that will work. Any other suggestions?

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 2:51 pm

I also tried adding the line dns-nameservers 8.8.8.8 to the /etc/network/interfaces file. That also did not work.

User avatar
rpdom
Posts: 15005
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Cannot resolve host name

Wed Apr 24, 2013 3:35 pm

Please post the output from the following commands:

ip route

ip addr

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 4:01 pm

Ip route

Default via 198.248.36.254 dev eth0
198.248.36.0/24 dev eth0 proto kernel scope link src 198.248.36.36

IP addr
1: lo: <loopback, up, lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000
2: eth0 <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up ql en 1000
Iink/ether b8:27:eb:4f:fo:0e brd ff:ff:ff:ff:ff:ff
Inet 198.248.36.36/24 brd 198.248.36.255 scope global eth0

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 4:08 pm

I forgot to say that I changed from DHCP to a static address to see if that would work. It doesn not. Host is still unreachable.

/etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

User avatar
rpdom
Posts: 15005
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Cannot resolve host name

Wed Apr 24, 2013 4:57 pm

Something is very odd if you can't ping 8.8.8.8. Pings could be blocked by your network, I suppose.

198.248.36.36 is a public IP address. Did your network admin allocate that for you?

Most people will be behind a NATed firewall/router and get 192.168.x.y, 172.16.x.y or 10.x.y.z addresses.

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 8:54 pm

Yes that is the ip I was given.

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 8:56 pm

Pings are not blocked by our network. I can ping all over the place on a windows machine.

phoenix127
Posts: 5
Joined: Wed Apr 24, 2013 9:08 pm

Re: Cannot resolve host name

Wed Apr 24, 2013 9:14 pm

Can you provide the output from an ipconfig /all on your windows machines that are working. This will tell us lots about your network configuration including correct entries for your router address, LAN addresses etc.

The problem is that you are using a public IP address on an internal network. This is incorrect, an internal address from RFC1918 is what you should be using on your LAN - per a previous posting. This is why you can't get to the Internet from your Pi.

User avatar
rpdom
Posts: 15005
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Cannot resolve host name

Thu Apr 25, 2013 5:37 am

phoenix127 wrote:The problem is that you are using a public IP address on an internal network. This is incorrect, an internal address from RFC1918 is what you should be using on your LAN - per a previous posting. This is why you can't get to the Internet from your Pi.
Some organisations do this. It means they only need a firewall but no NAT. I've worked at two places at least where I've had a class-B public address on my systems/desktop.

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Thu Apr 25, 2013 2:51 pm

I am out of town right now. Will post more when I get back. However, it may help you to know that a previous version of This software worked just fine. I had it on a 4 gig sd card and I had no problem getting the network when I gave it a static IP. When I got the new preloaded SD card from a different company I then had this problem.

Dsosb
Posts: 11
Joined: Tue Apr 23, 2013 8:19 pm

Re: Cannot resolve host name

Fri Apr 26, 2013 1:22 pm

Any other ideas?

TonyInOz
Posts: 8
Joined: Tue Apr 30, 2013 10:24 am
Location: Adelaide, Australia

Re: Cannot resolve host name

Tue Apr 30, 2013 10:54 am

Hi, had the same problem with the NameServer not working but fixed the problem by reverting back to a previous version of Wheezy.

I am currently using Wheezy-Raspbian 2013-02-09

/etc/network/interfaces is set to include

iface eth0 inet static
address 172.21.10.251
netmask 255.255.240.0

also set /etc/resolv.conf to contain
nameserver 172.21.3.1

the following URL in Midori (on the same network) could not resolve the name
http://PC1118/Dashboard.aspx

However substituting "PC1118" in the URL with its IP address did work!

After trying a number of different options I found reverting back to the previous version of the operating system Wheezy-Raspbian 2012-12-16 fixed the problem.

Any ideas?

Return to “Beginners”