Jump to content

problem with /etc/hosts and /etc/resolv.conf


Guest phil3k
 Share

Recommended Posts

Guest phil3k

hello everybody,

i'm using mandrake 10.0 official and i have a weird networking problem:

 

although my /etc/hosts seems to be alright, i can't ping any machines in my network by hostname and, whenever my router is down or the network cable is unplugged, programs take very long to start up.

 

here's my /etc/hosts:

127.0.0.1  localhost
192.168.1.201	hal9000  # my ip-address and my hostname
192.168.1.2	homer  #ip-address and hostname of another pc in my LAN

 

strangely, pinging one of the machines in /etc/hosts by hostname gives an 'unknown host'-error, whereas 'ping localhost' and pinging by ip-address work.

even more strangely, this problem only occurs when i have specified a nameserver in /etc/resolv.conf - when this file is empty, i _can_ ping myself by hostname (of course, internet doesn't work then *g*).

 

what can i do to fix this? any help apprecciated :-)

Edited by Qchem
Link to comment
Share on other sites

Just to clarify, when you ping by IP address, can you ping any other system. Or can you just ping yourself?

 

Do you have any firewall software on the other machines (or even this one) which might be blocking icmp (ping) requests?

 

Also, how do you access the internet? Via a DSL router or some other means?

Edited by ianw1974
Link to comment
Share on other sites

Guest phil3k

i can ping other systems in my LAN by IP address, but not by their hostname (although it is specified in my /etc/hosts). internet works just fine, via a DSL router.

 

i have no firewall software installed, neither do any other machines in my LAN.

Link to comment
Share on other sites

Do you have all machines using the DSL as the default gateway?

 

I have a similar setup (different IP addresses), but a handful of machines, a DSL router and a hardware firewall in between the internet connection. I had an icmp ping problem earlier because the Windows firewall was on one of the machine I tried to contact.

 

As you don't have the firewalls, this shouldn't be a problem for you.

 

When you configured the network, did you configure the following items:

 

IP

Subnet

Gateway

DNS entries

Hostname for your machine

 

I left zeroconf blank as it's not normally needed. I also left the fully qualified domainname blank when I configured the hostname, as it's not really needed anyhow.

Link to comment
Share on other sites

Have a look in /etc/nsswitch.conf - mine has a line

hosts:      files nisplus nis dns

 

This tells the machine to look at the hosts file first (files) then nis etc. when doing hostname lookups.

 

If yours is different, i.e no files entry, or dns is listed first, this may be the problem.

 

Chris

Link to comment
Share on other sites

Guest phil3k

yes, all machines use the DSL router as default gateway. my network configuration seems to be ok - i set my IP address, gateway, DNS, and hostname (no localdomain).

 

to me, the problem seems to be that, when i send a 'ping' command, mandrake looks up the specified hostname at the nameserver set in resolv.conf, instead of searching my /etc/hosts first. thus, when no nameserver is set, pinging by hostname does work.

 

do you have any idea how i can change the order in which mandrake looks up the hostnames?

Link to comment
Share on other sites

Guest phil3k
Have a look in /etc/nsswitch.conf - mine has a line
hosts:      files nisplus nis dns

 

This tells the machine to look at the hosts file first (files) then nis etc. when doing hostname lookups.

 

If yours is different, i.e no files entry, or dns is listed first, this may be the problem.

 

Chris

 

thank you - that solved my problem :-)

Edited by phil3k
Link to comment
Share on other sites

Glad it's all OK, I was about to say that the only other time I've seen this a problem is when a network card has been forced to a speed/duplex setting and the switch/hub was on auto-negotiate (or vice versa).

 

But as you're OK now, you won't need to worry about this! :P

Link to comment
Share on other sites

Guest phil3k

thank you everybody - so my pinging problem is now solved.

 

but i just discovered that another issue still persists:

when my network connection is down (e.g. cable unplugged *g*), programs take a lot longer to start up - i also held my hostname problem responsible for that, since this usually seems to be caused by missing entries in /etc/hosts.

 

any ideas?

Link to comment
Share on other sites

Guest phil3k

ok, forget about my last post; after rebooting, this seems to be solved, too (although i did "service network restart" before...) - sorry!

 

thanx again for your quick help :-) !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...