Using names, not IP addresses, in home network

Brian Norman Wootton Brian.Meg at btinternet.com
Mon Apr 13 07:47:47 UTC 2009


Using names, not IP addresses, in home network

> I have a few computers on a home network, and currently the router
> > assigns them IP addresses with DHCP. However, I find that every few
> > weeks the addresses change. How can I name the machines names such as
> > "laptop" and "ety" instead of useing IP addresses? Everything that
> > I've googled seems quite out of date. Thanks.
> >
> > --
> > Dotan Cohen
> >
> > http://what-is-what.com
> > http://gibberish.co.il
>   
Create a hosts file in your /etc/ directory. Use a text editor. you will 
need to give each system a static IP address instead of using DHCP. The 
hosts file will look something like this: # hosts file for home network 
system

192.68.1.1 router.homedomain router
192.168.1.101 pc1.homedomain pc1
192.168.1.110 pc2.homedomain pc2


Each machine on the network must contain this file, and the addresses 
must be exact. You can use a different sequence of address, but they 
must all be on the same subdomain.
Mark
---------------------------------------------------------------------------------------------------
I have static addresses because much easier to keep track of, and my printer
will only work properly with a solid static IP

Make sure you can log into your router !! I have turned off LAN DHCP on 
my router - you
can't do this on some routers. If you can't turn it off, make sure the 
static addresses you pick
are outside the DHCP range(this info will be on your router somewhere).

this is my /etc/hosts:
#127.0.0.1 localhost
#127.0.1.1 meg
# static addresses for LAN
192.168.1.254 gateway
192.168.1.64 meg localhost
192.168.1.65 nutmeg
192.168.1.66 HP9A8E2A

# 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

note the gateway(router) IP. So far, on different routers I have come 
across, I have
found these various gateway IPs 192.168.2.1 | 192.168.1.1 | 
192.168.1.254. Make
sure you know what yours is.
AS well as all your machines having similar /etc/hosts(note localhost) 
make sure your
router has a matching set. I can edit my router's host table, but on 
some you can't.
Be a little careful, it's possible to wind up with no LAN connections at 
all if you get this
wrong. Like Mark says - exactness and a plan of action are very necessary.
If you do get it wrong unhash the two 127 entries and hash out all the 
'static' entries
leave your linux machine on and reboot the router. And don't blame us if 
it still don't
work. Any body else who wants to add their two penn'orth please do.
brian






More information about the kubuntu-users mailing list