How to setup /etc/hosts to lookup DHCP client in the same subnet

This is a discussion on How to setup /etc/hosts to lookup DHCP client in the same subnet within the Linux Networking forums, part of the Linux Forums category; Hello, I have two machines (myboxA & myboxB) in the same subnet, and both are assigned IP addresses by a ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-12-2006
Wonder
 
Posts: n/a
Default How to setup /etc/hosts to lookup DHCP client in the same subnet

Hello,

I have two machines (myboxA & myboxB) in the same subnet, and both are
assigned IP addresses by a DHCP router. MyboxA is installed RedHat 9.2.

Since the IP addresses are dynamicly assigned, I'm wondering how to
config
/etc/hosts (or any other files) in myboxA, to make it connect to myboxB
by
its name instead of IP address?

Thanks.

Wonder

Reply With Quote
  #2 (permalink)  
Old 09-12-2006
Andrew Schulman
 
Posts: n/a
Default Re: How to setup /etc/hosts to lookup DHCP client in the same subnet

> Hello,
>
> I have two machines (myboxA & myboxB) in the same subnet, and both are
> assigned IP addresses by a DHCP router. MyboxA is installed RedHat 9.2.
>
> Since the IP addresses are dynamicly assigned, I'm wondering how to
> config
> /etc/hosts (or any other files) in myboxA, to make it connect to myboxB
> by
> its name instead of IP address?


The way I do it is to have my DHCP server tell my DNS server about its
leases and hostnames, then configure DNS to try to answer queries from DHCP
(as well as /etc/hosts) before resolving from the WAN.

This is especially easy to do if you use dnsmasq for your DHCP and DNS
servers. dnsmasq is both servers, so DNS automatically knows all of the
DHCP leases, and resolves hostnames from them. You're done.

Good luck,
Andrew.

--
To reply by email, change "deadspam.com" to "alumni.utexas.net"
Reply With Quote
  #3 (permalink)  
Old 09-12-2006
Wonder
 
Posts: n/a
Default Re: How to setup /etc/hosts to lookup DHCP client in the same subnet

Andrew Schulman wrote:
>
> The way I do it is to have my DHCP server tell my DNS server about its
> leases and hostnames, then configure DNS to try to answer queries from DHCP
> (as well as /etc/hosts) before resolving from the WAN.
>
> This is especially easy to do if you use dnsmasq for your DHCP and DNS
> servers. dnsmasq is both servers, so DNS automatically knows all of the
> DHCP leases, and resolves hostnames from them. You're done.
>
> Good luck,
> Andrew.
>
> --
> To reply by email, change "deadspam.com" to "alumni.utexas.net"


Andrew, thank you.

Actually, I don't have a DNS server in this home network. It's just a
Belkin 4-port wireless router, which is DHCP server for the two
machines, and it gets the DNS and IP settings automatically from my
ISP.

So, from my understanding, you don't need to add any lines in
/etc/hosts of your myboxA (for example), with the DHCP and DNS
configged correctly, am I right?

Reply With Quote
  #4 (permalink)  
Old 09-12-2006
Andrew Schulman
 
Posts: n/a
Default Re: How to setup /etc/hosts to lookup DHCP client in the same subnet

> Andrew Schulman wrote:
> >
> > The way I do it is to have my DHCP server tell my DNS server about its
> > leases and hostnames, then configure DNS to try to answer queries from DHCP
> > (as well as /etc/hosts) before resolving from the WAN.
> >
> > This is especially easy to do if you use dnsmasq for your DHCP and DNS
> > servers. dnsmasq is both servers, so DNS automatically knows all of the
> > DHCP leases, and resolves hostnames from them. You're done.
> >
> > Good luck,
> > Andrew.
> >
> > --
> > To reply by email, change "deadspam.com" to "alumni.utexas.net"

>
> Andrew, thank you.
>
> Actually, I don't have a DNS server in this home network. It's just a
> Belkin 4-port wireless router, which is DHCP server for the two
> machines, and it gets the DNS and IP settings automatically from my
> ISP.
>
> So, from my understanding, you don't need to add any lines in
> /etc/hosts of your myboxA (for example), with the DHCP and DNS
> configged correctly, am I right?


Right. But since you don't have that option with your router, maybe just a
simple static setup is best for you. You can configure your router to
assign fixed IP addresses to each of your two hosts, and then set up
/etc/hosts on each. That will work just fine, although you have to update
all of the /etc/hosts files if you ever add hosts to your LAN.

If you still want your hosts to get their IP addresses by DHCP (e.g. because
they're laptops and you want them to be able to grab IP addresses when you
take them on the road), then maybe you can configure your router's DHCP
server to assign some fixed IP addresses by DHCP. dnsmasq can do that, and
I don't know about the Belkin routers, but the Linksys routers run dnsmasq
under the hood.

--
To reply by email, change "deadspam.com" to "alumni.utexas.net"
Reply With Quote
  #5 (permalink)  
Old 09-12-2006
Wonder
 
Posts: n/a
Default Re: How to setup /etc/hosts to lookup DHCP client in the same subnet

Andrew Schulman wrote:
>
> Right. But since you don't have that option with your router, maybe just a
> simple static setup is best for you. You can configure your router to
> assign fixed IP addresses to each of your two hosts, and then set up
> /etc/hosts on each. That will work just fine, although you have to update
> all of the /etc/hosts files if you ever add hosts to your LAN.
>
> If you still want your hosts to get their IP addresses by DHCP (e.g. because
> they're laptops and you want them to be able to grab IP addresses when you
> take them on the road), then maybe you can configure your router's DHCP
> server to assign some fixed IP addresses by DHCP. dnsmasq can do that, and
> I don't know about the Belkin routers, but the Linksys routers run dnsmasq
> under the hood.
>
> --
> To reply by email, change "deadspam.com" to "alumni.utexas.net"


Yeah, as you said, I have to use DHCP on the router, since one of the
laptops is always moved. There is no dnsmasq on Belkin routers, it
sucks! Fortunately, I find that I can set the lease period on the
router to "Forever", to keep the IP addresses "static". Then I can set
up /etc/hosts on each as you said.

Thanks.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:07 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0