LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-24-2011, 05:40 PM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
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.
 
Old 06-24-2011, 05:51 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
hi, what is in:
Code:
[schneidz@hyper world-united]$ cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.1.1
?
 
Old 06-24-2011, 05:54 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
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?
 
Old 06-24-2011, 05:58 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^ worth a shot.
 
Old 06-24-2011, 06:08 PM   #5
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
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.
 
Old 06-24-2011, 06:16 PM   #6
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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
 
Old 06-24-2011, 06:28 PM   #7
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
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 ?
 
Old 06-24-2011, 06:34 PM   #8
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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
 
Old 06-24-2011, 06:49 PM   #9
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
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....
 
Old 06-24-2011, 06:56 PM   #10
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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
 
Old 06-24-2011, 07:34 PM   #11
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
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.
 
Old 06-25-2011, 03:06 AM   #12
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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
 
Old 06-27-2011, 08:07 AM   #13
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by sneakyimp View Post
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.
 
Old 06-27-2011, 11:35 AM   #14
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
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
 
Old 07-06-2011, 05:48 AM   #15
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to resolve hostnames (DNS) from LAN pc's > server > internet KeenAs Linux - Networking 12 01-10-2009 08:17 AM
cannot resolve hostnames ussblade Slackware 5 02-13-2008 08:07 PM
BIND doesn't resolve hostnames information for which is stored on other DNS servers GD_19 Linux - Networking 5 01-03-2006 08:31 PM
Cannot resolve hostnames BobBuchanan Linux - Networking 1 02-12-2005 05:56 PM
Can't resolve hostnames....need help shaggystyle Linux - Networking 2 08-28-2004 02:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration