PDA

View Full Version : [ubuntu] Strange HOSTS behaviour



giambolo
August 9th, 2009, 09:46 AM
Hi everyone. I've just installed Ubuntu Jaunty on my new notebook. It seems that /etc/hosts is not working properly. E.G. /etc/hosts contain 127.0.0.1 myself 192.168.1.100 myselfagain 192.168.1.1 myrouter >pinging these addresses I get the message PING myself (62.210.183.39) 56(84) bytes of data. Any suggestion from the community? Thanks in advance to everyone.

giambolo
August 9th, 2009, 10:08 AM
I think I'd better add my /etc/nsswitch
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd: compat
group: compat
shadow: compat

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
networks: files

protocols: db files
services: db files
ethers: db files
rpc: db files

netgroup: nis

dmizer
August 9th, 2009, 11:04 AM
Actually, it would help if you posted your actual /etc/hosts file rather than trying to explain what's in it. There's no risk in revealing LAN information unless you don't trust your router's firewall.

giambolo
August 9th, 2009, 02:29 PM
Well, I've reboot the machine and hosts works like it should. I'll be checking if this happens again. Please, consider this thread closed. Thank you again for ypur reply.

giambolo
August 9th, 2009, 03:38 PM
No, again it doesn't work. As soon as the wireless network gets connected I only have the two DNSs of my provider. I don't know how to force /etc/hosts to be queried before the DNS servers. The following tries to describe my configuration, feel free to ask for more details.
/etc/hosts
127.0.0.1 www.joomla1.onme
127.0.0.1 www.joomla2.onme
127.0.0.1 www.joomla3.onme
127.0.0.1 www.joomla4.onme

192.168.1.1 gw
192.168.1.1 dhcp

127.0.0.1 www.didaco.rock


# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

/etc/resolv.conf
# Generated by NetworkManager
nameserver 193.70.152.15
nameserver 193.70.152.25

dmizer
August 9th, 2009, 04:10 PM
All your hosts on 127.0.0.1 should be on the same line, like so:

127.0.0.1 localhost joomla1.onme joomla2.onme joomla3.onme joomla4.onme didaco.rock

192.168.1.1 gw dhcp

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

I'm not sure I understand the line I've highlighted in red. I can think of no reason to include a DHCP server or GW in your hosts file.

Edit:
"www" is assumed and not needed in the hosts file.

giambolo
August 9th, 2009, 04:54 PM
Thank you dmizer. Your suggestions do not bring me elsewhere. My problem is that Ubuntu doesn't read /etc/hosts and keep asking any name to the DNS server defined in the wireless network configuration of networkmanager. Which should be the standard for Ubuntu. I think I am to investigate the latter package. Thanks again.

dmizer
August 10th, 2009, 12:39 AM
Please post the output of:

ls -la /etc/hosts

giambolo
August 10th, 2009, 08:19 AM
elio@gazelle:~$ ls -la /etc/hosts
-rwxr----- 1 root root 368 2009-08-10 09:13 /etc/hosts

giambolo
August 10th, 2009, 08:23 AM
dmizer, you got the point. I've changed the hosts file with chmod o+r /etc/hosts and it works now. It all started from the fact that I copied many files (as root) from the /etc of my previous pc to the /etc of this pc.
Many many thanks. It simply was too obvious

dmizer
August 10th, 2009, 09:13 AM
It simply was too obvious

It's always the simple things that cause the most trouble ;)