View Full Version : How to deal practically with /etc/hosts ?

28th November 2011, 11:12 PM
My fedora15 desktop is in a LAN managed by my DHCP router.
I am loathe to add host names to my /etc/hosts file, since the
local IP addresses can change. I have looked at dnsmasq, but
am not sure if this is the solution to the following: How can I
reliably use various pcs' symbolic names without manually keeping
the various /etc/hosts files up-to-date wrt dynamic IP addresses?

Do I need to turn off my router's DHCP server and use dnsmasq as
both a dhcp and dns server?

Thank you.

28th November 2011, 11:38 PM
If your DHCP server is dynamically assigning IP numbers then it must (it isn't meeting standards) have a way to specify which IP to which name is to be used. It is also possible that the DHCP server is also a name server, if only for the IP numbers it passes out.

28th November 2011, 11:40 PM
Dear Normcvr,

Depends on your router. You can try a reverse DNS lookup of your IP address. My router gives the
hostname + dot + "lan" for both Linux and Windows, and I get sensible "search" parameter in
/etc/resolv.conf. No configuration necessary in Fedora, Ubuntu, and Windows

If this fails, DNSMASQ is an excellent option. Switch off DHCP in the router, and define dnsmasq as DHCP+DNS server. Of course, dnsmasq should contact the routers name server for non-local addresses.

Good luck!

29th November 2011, 12:53 AM
My /etc/resolv.conf contains the address of my router, so I assume that my router is not able to be a local DNS server. The router is "Actiontec V1000H", which I got as part of a telus Optik TV installation. My experience with telus routers is that they are dumbed down. Last time, I returned the router for a plain modem, and ended up using my own DHCP router, but which also did not have its own DNS server.

I don't know of any way of getting at the DHCP information that is in the router. Which spec are you referring to wrt DHCP routers, please? I suppose I must delve into dnsmasq. Thanks for the feedback and hints.

29th November 2011, 02:26 PM
My /etc/resolv.conf contains the address of my router, so I assume that my router is not able to be a local DNS server.

No that means nothing. Your router may server local LAN names visa DNS and/or forward your DNS requests. Either way you'll get the router IP in your resolv.conf.

The datasheet on your actiontec v1000h shows it can act as a DNS server.

I suggest you see how to configure/enable DNS service on the router. Looks like you need to point your browser at the router IP (maybe requires a wired connection), then you get a config screen. The actiontec website seems to only have a quick setup guide - no detailed manual.

The alternative is to run dnsmasq on one Linux system - but that system then has to be up before any other system,

29th November 2011, 04:03 PM
Thank you for the pointer to the data sheet. Indeed, it claims that the V1000H does/can act as a DNS server. Oddly, the user manual does not mention it:


and I am not able to find the option in the router's on-line web configuration pages.

Given your caveats on the practicality of using dnsmasq (I also double boot my machine to XP), my better solution is to exchange the V1000H for a plain modem with telus, and get hold of a properly functional router, supporting being a local DNS server and a full suite of access control. The V1000H is also awkward in the latter respect -- an entry in an access table must be deleted (there is no option to make the entry inactive).

Any router recommendations for a wireless N DHCP router with LAN DNS server and well-designed access control?

I have sent Actiontec a support request to clarify the DNS server functionality of the router. Will keep you guys in the loop ...

29th November 2011, 09:26 PM
That the address of your router is in /etc/resolv.conf is fine. That means that the router advertises itself as DNS server. Just try


or nslookup - <address of your router> and check whether hostnames resolve to addresses and whether addresses resolve to hostnames.
Check whether your IP address resolves to some hostname. May be it just works.....

Indeed, dnsmasq is good, but you must have a Linux system permanently on line to serve as DHCP/DNS
server. A router should be able to do that.

Good luck!

30th November 2011, 04:31 AM
Here are the results of a couple of nslookup commands. If this gives
you any insight, I would appreciate the feedback.

Thank you.

My router is

melodic:~/Temp> nslookup
;; Got recursion not available from, trying next server
;; Got recursion not available from, trying next server

** server can't find NXDOMAIN
============================================== is the correct name server for my ISP.

another (melodic is the fedora machine I am working on):

melodic:~/Temp> nslookup melodic

** server can't find melodic: NXDOMAIN

30th November 2011, 07:30 AM
That looks not that promising....

My router (Speedtouch with legacy firmware) is

Address: name = dsldevice.lan.

All hosts get the .lan suffix, and are accessible by simply typing the name because /etc/resolv.conf gets via

cat /etc/resolv.conf
# Generated by NetworkManager
domain lan
search lan

I'm afraid, if you do not want a permanent-on system with dnsmasq, you should set your DHCP lease time as infinite as possible, and enter the IP addresses/names in /etc/hosts and C:\windows\system32\drivers\etc\hosts.

Good luck!