LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   can't resolve hostnames on Ubuntu 11 - no DNS? (https://www.linuxquestions.org/questions/linux-newbie-8/cant-resolve-hostnames-on-ubuntu-11-no-dns-888204/)

sneakyimp 06-24-2011 05:40 PM

can't resolve hostnames on Ubuntu 11 - no DNS?
 
I recently assembled a new computer with both Windows 7 boot and Ubuntu 11.04 boot. For some reason, I can not resolve domain names at all on in Ubuntu while Windows 7 works just fine. I'm wondering if I have improperly configured my network settings. I am trying to configure this machine to have a static IP on my network of 192.168.1.3

The machine definitely has its network card installed properly and in Ubuntu I can access numeric ip addresses anywhere via browser or ssh. When I type in "google.com" in a browser I get an instant 'server not found' error page.

Anything that is described in my hosts file seems to work just fine.

I can ping my router which has a LAN IP of 192.168.1.1 just fine with no packet loss.

Here are the contents of /etc/network/interfaces:
Code:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address 192.168.1.3
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.1

If I type in nslookup commands or dig commands they just time out. Wondering what the story is here.

Also, I am unable to access this machine via ssh from any other machine on the network. Wondering what might be wrong. Any tips are greatly desired.

schneidz 06-24-2011 05:51 PM

hi, what is in:
Code:

[schneidz@hyper world-united]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.1

?

sneakyimp 06-24-2011 05:54 PM

Thanks for your response! /etc/resolv.conf does not have a nameserver directive in it. It has a comment and that is all. Should I add a nameserver directive?

schneidz 06-24-2011 05:58 PM

^ worth a shot.

sneakyimp 06-24-2011 06:08 PM

It worked. Odd that one would need to do that I think. I would imagine the system would be smart enough to derive it from the gateway or something.

markush 06-24-2011 06:16 PM

You're system must run dhcpcd in order to get a correct IP-configuration from the DHCP-server. If you configure for a static IP you must instead tell dhcpcd not to overwrite the nameserver-entry in /etc/resolv.conf. In order to achieve this, you'll have to insert a line
Code:

nohook resolv.conf
in your /etc/dhcpcd.conf file.

Markus

sneakyimp 06-24-2011 06:28 PM

Markush, thanks for the additional information. Unfortunately, I'm not certain whether dhcpcd is active (or even what it is).

When I initially installed Ubuntu from the CD, I don't believe I was prompted for dhcp versus static IP. I followed this how-to document to configure it with a static IP.

Do I still need that line in my /etc/dhcpcd.conf ?

markush 06-24-2011 06:34 PM

mh, if you have the file /etc/dhcpcd.conf (it maybe on another place in Ubuntu) you'll know that dhcpcd is installed. Note that every distribution installs a DHCP-client-daemon by default (there are others than dhcpcd) since without it DHCP will not work and most systems use DHCP at least while installation.

The answer to your question: if you have a dhcpcd.conf file, insert the line I described in my last post and just try it out.

Note also that if you restart the system and don't have the line "nohook resolv.conf" in your dhcpcd.conf file, dhcpcd will overwrite your nameserver again.

Markus

sneakyimp 06-24-2011 06:49 PM

I just did a search for dhcpcd.conf :
Code:

jaith@ubuntu64:/$ sudo find * -name 'dhcpcd.conf'
[sudo] password for jaith:
jaith@ubuntu64:/$

...and nothing was found

I'll try a reboot and see what happens....

markush 06-24-2011 06:56 PM

If your system doesn't use dhcpcd, you can use the command
Code:

apropos dhcp
to find out, which program on your system provides the IP-configuration via DHCP.

Markus

sneakyimp 06-24-2011 07:34 PM

Thanks again for the info. Rep++. I rebooted my machine and it still seems to be working. I can resolve remote hostnames and my resolv.conf file still contains the nameserver bit. This seems safe.

I typed the command you suggested:
Code:

jaith@ubuntu64:/$ apropos dhcp
dhclient-script (8)  - DHCP client network configuration script
dhclient.conf (5)    - DHCP client configuration file
dhclient.leases (5)  - DHCP client lease database
dhcp-eval (5)        - ISC DHCP conditional evaluation
dhcp-options (5)    - Dynamic Host Configuration Protocol options
dnsmasq (8)          - A lightweight DHCP and caching DNS server.

I see there is a file /etc/dhcp/dhclient.conf which looks like the guilty file.

It has a lot of settings that have all been commented out, but the active ones are as follows:
Code:

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name "<hostname>";
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers;

This file does not contain any 'nohook' lines but my system is still working after a reboot. Would that nohook command belong in this file? Is it necessary.

markush 06-25-2011 03:06 AM

nohook is special for the dhcpcd program, but the entry in red
Code:

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name "<hostname>";
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers;

seems to configure that dhclient will configure the nameserver entry in resolv.conf.

I don't know if the "overwriting /etc/resolv.conf" is a speciality of dhcpcd or if it is a general behavior of any dhcpclient. I'd recommend to read the manpages for
Code:

man dhclient
man dhclient.conf

btw, thanks for the reputations, hopefully this thread will help other users as well.

Markus

schneidz 06-27-2011 08:07 AM

Quote:

Originally Posted by sneakyimp (Post 4394995)
I just did a search for dhcpcd.conf :
Code:

jaith@ubuntu64:/$ sudo find * -name 'dhcpcd.conf'
[sudo] password for jaith:
jaith@ubuntu64:/$

...and nothing was found

I'll try a reboot and see what happens....

i think it should be
Code:

sudo find / -name 'dhcpcd.conf'
to search your whole system.

sneakyimp 06-27-2011 11:35 AM

schneidz, my working directory when i ran the search was / so I did indeed search the whole system.

markus thanks for the info. I had to reinstall my OS due to hardware problems and will likely be experiencing this issue again this week :(

salasi 07-06-2011 05:48 AM

Nearly irrelevant, slightly nitpicking, note:

Provided that you are running locate (many distros do this by default) it is easier and more convenient (and faster) to use 'locate' (sometimes, slocate) to perform simple file searches like this

Quote:

locate dhcpcd.conf
'find' is better if you want to do clever stuff, like search by modification date, or whatever, but locate is so fast that I'd have difficulty working efficiently without it.


All times are GMT -5. The time now is 04:04 AM.