localhost or LAN addresses in /etc/hosts

NoOp glgxg at sbcglobal.net
Tue Dec 16 03:58:21 UTC 2008


On 12/15/2008 04:30 PM, Chris G wrote:
> On Mon, Dec 15, 2008 at 01:57:50PM -0800, NoOp wrote:
>> On 12/15/2008 11:50 AM, Chris G wrote:
>> 
>> > 
>> > My /etc/hosts now has:-
>> > 
>> >     127.0.0.1       localhost.localdomain   localhost
>> > 
>> >     192.168.1.1 vigor 2820n
>> >     192.168.1.4 home.isbd.net isbd 84-45-228-40.no-dns-yet.enta.net chris.isbd.net
>> >     192.168.1.5 home
>> >     192.168.1.6 maxine
>> >     192.168.1.7 garage
>> >     ... plus more lines.
>> > 
>> > 
>> > If I say 'host isbd' on the garage system see what happens:-
>> > 
>> >     chris at garage:~$ host isbd
>> >     isbd has address 192.168.1.4
>> >     chris at garage:~$ 
>> > 
>> > The garage system has a default /etc/hosts, I've added nothing to it.
>> > 
>> > 
>> > So it seems to me I'm getting exactly what I need, a DNS system that
>> > gives me valid LAN addresses for local names.
>> 
>> Question: what happens when the single machine with dnsmasq is
>> down/off-line etc? Wouldn't you be better off putting the IP's in the
>> /etc/hosts files of each machine (adjusted accordingly of course)?
>> 
> Er, the same as happens when the router is down - not much!  :-)
> 

Yes, but then you must keep the dnsmasq machine up at all times - what
ever happend to 'green'... :-)

However if the router is still up but the dnsmasq machine is down you
will still have the ability to ping by name if you configure each
/etc/host file to include the appropriate IP addresses and name for each
device. For example with 'garage':

127.0.0.1       localhost
127.0.1.1	garage

192.168.1.1 vigor 2820n
192.168.1.4 home.isbd.net isbd 84-45-228-40.no-dns-yet.enta.net
chris.isbd.net
192.168.1.5 home
192.168.1.6 maxine

garage would still be able to easily find 'home' or maxine' (I'm not
sure about the isbd.net stuff).

Or maxine:

127.0.0.1       localhost
127.0.1.1	maxine

192.168.1.1 vigor 2820n
192.168.1.4 home.isbd.net isbd 84-45-228-40.no-dns-yet.enta.net
chris.isbd.net
192.168.1.5 home
192.168.1.7 garage

maxine would still be able to easily find 'garage'.

You may have the luxury of being able to keep a machine fully powered on
all of the time just for dnsmasq purposes, but I'm not sure that doing
so is the best option IMO. I'd just leave the current static IP settings
(this is what I do for my local networks), populate the few /etc/hosts
files that you have for each machine, isolate those addresses in the
router as static, and let anything else connect via DHCP on the
addresses I allow for DHCP on the router.

It's pretty simple (Karl has it right this time). The only
pain-in-the-ass (PITA) is that you need to check/modify the /etc/hosts
settings on each machine each time you add a new static IP device. But
for 5 or 6 (I have 10) devices it's not that difficult. It's certainly
easier than fiddling with the router to add MAC addresses for 'fixed'
DHCP addresses IMO.

For others that advocate DHCP on a small local network:

The advantages of static IP's in a small local network are even more
evident when you use VPN's, VNC, or a central printer - particularly if
you use IPP to connect to the printer.

  Case in point: I have a central printer that can be used from both a
wired and wireless router. All of the Ubuntu wired and wireles
connections are _very_ easy to connect as they just use ipp://IPADDRESS
etc. Enter a DHCP Vista laptop on the wireless... couldn't find the
printer; however once I told it the IP address I was able to have it
print to the printer without any difficulty.

BTW: the printer doesn't just come up and provide a 'printer name' on
the network, it's not possible. I'm sure that someone will come along
and show me wrong and how to do it with DHCP & that's quite OK, but
using static IP's on a small local lan shouldn't require dnsmasq or any
other special requirements other than defining the host names in /etc/hosts.

 Another case in point: I VPN into a remote network that has maybe 5 or
6 machines on site. If the machines are DHCP I need to find a way to
find out what their current IP's are so that I can connect to them for
updates etc. In nearly all cases this is simply impossible with a
standard VNC or VPN link; unless I've taken the trouble to define their
MAC addresses in the remote router to assign those machines the same IP
address each time. In that case I need to rely on a dns discover utility
that may or may not be working on the remote end.
  So why even bother? Just reserve a block of IP's on the router to be
static, reserve a block to be DHCP, and leave it at that. You have your
machines/printers/etc on static, friends visit & connect and get a DHCP
address and can access the necessary services (including your printer if
you give them the IP address) and off you go. Basically Karl was/is
correct for the most part on this one. Oh *please* Karl don't blog about
your network settings on the list just because I commented that you are
*basically* right on this...








More information about the ubuntu-users mailing list