Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to setup /etc/hosts to lookup DHCP client in the same subnet

Reply
Thread Tools Display Modes

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

 
 
Wonder
Guest
Posts: n/a

 
      09-12-2006, 07:43 PM
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
 
 
 
 
Andrew Schulman
Guest
Posts: n/a

 
      09-12-2006, 07:55 PM
> 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
 
Wonder
Guest
Posts: n/a

 
      09-12-2006, 08:07 PM
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
 
Andrew Schulman
Guest
Posts: n/a

 
      09-12-2006, 08:53 PM
> 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
 
Wonder
Guest
Posts: n/a

 
      09-12-2006, 09:22 PM
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
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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access hosts in other subnet lovecreatesbea...@gmail.com Linux Networking 7 07-29-2008 08:55 PM
How to setup DHCP option 35 on XP client Moondoggy Windows Networking 0 01-23-2008 05:59 PM
DNS lookup for a system on the same subnet Jay Linux Networking 5 01-12-2005 05:45 AM
Client subnet mask wrong when using Windows Server 2003 DHCP Tim R Windows Networking 2 01-02-2004 07:13 PM
Linux DHCP Client will not collect IP but can see other hosts :-( Lee Farrant Linux Networking 6 11-19-2003 06:36 PM



1 2 3 4 5 6 7 8 9 10 11