creating /etc/hosts

DJ Lucas dj at lucasit.com
Sun Nov 23 17:11:16 PST 2003


Pascal J.Bourguignon wrote:
> llista writes:
> 
>>Hi,
>>
>>I'm going to create this file but i have a doubth.
>>
>>I'm using an ADSL line with a router configured like if i was a only one 
>>net computer  ( in spanish this configuration is called  MULTIPUESTO).
>>
>>I mean that i have a gateway with a static IP (that is my router) and my 
>>computer have an DCHP assigned IP adresss  (192.168.1.x).
>>
>>When i intalled linux , all net configuretion was automatically 
>>downloaded by linux itself from the router.
>>
>>So.. my question is...  
>>
>>Must I create hots file (in net card version) or is there anyelse way to 
>>get it from the router...
>>
>>Can i follow the kind of configuration that is teached in book or with 
>>my configuration, I have to consider some more things...
>>
>>
>>
>>Sorry if my english and my net level isn't good enough but i trying to 
>>improve.  :)
> 
> 
> 
> If the  IP address is  allocated by the  DHCP server (in  the router),
> then it can be different each time it's allocated. The D in DHCP means
> Dynamical, and that means that it can change.
> 
> /etc/hosts,  like DNS,  is  merely  a mean  to  make a  correspondance
> between IP addresses and human readable names.
> 
> If your  DHCP server allocates  addresses in the range  192.168.1.0 to
> 192.168.1.255, then  you can  put names to  these addresses,  but note
> that the  name will change  accordingly when the adresse  allocated to
> your computer changes.
> 
> 
> You could  put the following lines  in the /etc/hosts of  each of your
> computers:
> 
> 192.168.1.1 uno.mi-red
> 192.168.1.2 dos.mi-red
> 192.168.1.3 tres.mi-red
> 192.168.1.4 quatro.mi-red
> # etc
> 
> then you'll be able to refer them  by name.  But while you keep a DHCP
> configuration, the computer  named uno.mi-red can be one  or the other
> of your LAN.
> 
> 
> What I would do is:
> 
> 1- check the configuration  of the router.  You may  keep a DHCP range
>    for when you want to connect a laptop or "visitor" computer on your
>    LAN, but make it smaller than the whole subnet.
> 
> 2- have a range of your LAN addresses reserved for fixed adresses that
>    you'll allocate statically to your computers.
> 
> 3- either run  a DNS on your  LAN, or copy the same  /etc/hosts on all
>    your computers with the mapping name <-> fixed IP you want.
> 
> So you may  call each of your resident computers  with fixed names and
> fixed addresses  192.168.1.x, and still have  "visitor" computers with
> dynamically allocated addresses 192.168.1.y.
> 
> 

I wrote an apended bit to the dhcp client scripts for this a long time 
ago just because it didn't seem right to have the incorrect IP in the 
hosts file.  Wether or not it's actually needed by anything is still up 
in the air....and the bug is still open.  320

-- DJ




More information about the lfs-support mailing list