You are not logged in.

#1 2008-07-31 18:18:25

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

/etc/hosts & DHCP

Hi,

My router is set to assign my archlinux server an IP address on the LAN. I have setup the HOSTNAME in the rc.conf file, however I now need to know how to bind it to the DHCP-assigned address in /etc/hosts. Is there some variable I can use to have /etc/hosts assign the hostname to the current IP address of the eth0 NIC?

For example:


/*lookup eth0 IP address*/ server.foo.com server

This way, when I instruct my router to assign a new IP address to my server, using the "server" domain name still works because it always maps to the DHCP assigned address.

Offline

#2 2008-07-31 20:24:52

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: /etc/hosts & DHCP

Perhaps I'm asking the wrong question? What I really want to do is to be able to access my server from any other computer on my LAN via a domain name and not an IP address. I simply assumed /etc/hosts was how this was to be done. Is there an alternative that works well with DHCP?

Offline

#3 2008-07-31 23:21:34

jleach
Member
Registered: 2008-07-24
Posts: 27

Re: /etc/hosts & DHCP

void.pointer wrote:

Perhaps I'm asking the wrong question? What I really want to do is to be able to access my server from any other computer on my LAN via a domain name and not an IP address. I simply assumed /etc/hosts was how this was to be done. Is there an alternative that works well with DHCP?

The simplest solution would be to configure your router so that the linux machine always gets assigned the same IP address. Most routers will allow this kind of address reservation based on the MAC address.  Then you could modify the windows machines hosts file to give the linux machine a name.

The more involved solution would be setting up a DNS server and configuring all the clients to access it.

Offline

#4 2008-07-31 23:27:08

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: /etc/hosts & DHCP

So if I reserve the IP on the router and then set that IP in the /etc/hosts file on my linux machine, that will work fine?

Offline

#5 2008-07-31 23:46:29

jleach
Member
Registered: 2008-07-24
Posts: 27

Re: /etc/hosts & DHCP

void.pointer wrote:

So if I reserve the IP on the router and then set that IP in the /etc/hosts file on my linux machine, that will work fine?

You'd need to add that IP to the hosts files for the windows machines too, should be in %SystemRoot%\system32\drivers\etc\

The format is the same I believe.

Offline

#6 2008-07-31 23:49:31

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: /etc/hosts & DHCP

jleach wrote:

You'd need to add that IP to the hosts files for the windows machines too, should be in %SystemRoot%\system32\drivers\etc\

The format is the same I believe.

Back when I used Ubuntu Server, I didn't have to do anything to my windows machines. I simply was able to access the machine via their domain name. I want to do the same thing Ubuntu Server is doing.

Offline

#7 2008-08-01 00:08:47

jleach
Member
Registered: 2008-07-24
Posts: 27

Re: /etc/hosts & DHCP

void.pointer wrote:
jleach wrote:

You'd need to add that IP to the hosts files for the windows machines too, should be in %SystemRoot%\system32\drivers\etc\

The format is the same I believe.

Back when I used Ubuntu Server, I didn't have to do anything to my windows machines. I simply was able to access the machine via their domain name. I want to do the same thing Ubuntu Server is doing.

Ubuntu Server comes preconfigured with Bind9, a DNS server, as well as a DHCP server... you can install and setup both of those (pacman -S bind; pacman -S dhcp) in Arch as well to get similar functionality.  These are not typical packages for desktop users, hence why they're not default packages for many distros.

If you're talking about the Network Neighborhood, then you'd be needing to install and configure Samba on the linux machine.

Offline

#8 2008-08-01 04:46:14

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: /etc/hosts & DHCP

Sorry but I'm still not understanding something. My printer, my router, and several other devices on my LAN can be assigned a hostname and I can "magically" use it instead of the actual IP address to reach that device/router. I'm not a big network guru, but is my printer actually hosting a DNS server? Does it really have to be so complicated? Can you explain to me how a printer would do this so easily?

Offline

#9 2008-08-01 06:21:02

Phineas
Member
From: New Zealand
Registered: 2008-03-15
Posts: 17

Re: /etc/hosts & DHCP

I have archlinux setup as a server (web only so far) which I can access from another computer connected to my router. I reserved a static IP address for it via the web interface on the router. I then used the DNS features of the router to assign it a domain name. Now, I type in the domain name as a web site address in a browser on another computer connected to the router and it loads the page hosted. My router isn't anything flash, it's a dynalink RTA1320 - an ADSL router.

Offline

#10 2008-08-01 08:27:26

abhidg
Member
From: City of Kol
Registered: 2006-07-01
Posts: 184
Website

Re: /etc/hosts & DHCP

Avahi link-local addressing can also be used as a simple
DNS solution for those who don't want the hassle of
setting up a DNS server:

http://wiki.archlinux.org/index.php/Avahi

Offline

#11 2008-08-01 09:50:40

jleach
Member
Registered: 2008-07-24
Posts: 27

Re: /etc/hosts & DHCP

void.pointer wrote:

Sorry but I'm still not understanding something. My printer, my router, and several other devices on my LAN can be assigned a hostname and I can "magically" use it instead of the actual IP address to reach that device/router. I'm not a big network guru, but is my printer actually hosting a DNS server? Does it really have to be so complicated? Can you explain to me how a printer would do this so easily?

The short answer is that while every windows machine is not running a DNS server, they are running a different kind of nameserver to automatically find each other.  Setting up samba on the linux server is analagous to this.

Windows machines mainly use the NetBIOS protocol to communicate to each other and with this protocol they lookup names from WINS servers. When you go to a Windows machine and look at its "network name" and its "workgroup", it is showing you the NetBIOS name, not the DNS name. NetBIOS is stacked on top of TCP/IP, so it may seem like the windows computers are finding each other over TCP/IP without running a DNS server, but the reality is that they each are running a WINS server, and discovering each other using WINS.  This is actually what the "Client for Microsoft Networks" and "File and Printer Sharing for Microsoft Networks" are in your Network configuration, now you can see why those two services install themselves automatically on just about every Windows machine in the world.

A Linux kernel doesn't come with a "Client for Microsoft Networks", and communicating over NetBIOS is not supported by common linux networking commands, as they're designed to work on plain vanilla TCP/IP.  So you can't "ping" a server using only its NetBIOS name.  The samba utilities can provide netbios name resolution ('nmblookup') and allow you to share files on the linux machine with the network neighborhood. 

Just by running samba server, your linux machine will get a netbios name (should match your 'hostname' if you don't modify smb.conf), and this should enable you to go to a nearby windows machine and do a "ping linuxname" or "telnet linuxname" and have it resolve the IP address.  This might be sufficient for your needs.

It can be messy yes, and that's why people have created things like "ZeroConf" networking. I've never used avahi but it doesn't impress me, seems like getting it setup properly and then adding windows machines to the mix (windows lacks a native mDNS responder) requires about as much configuring as traditional solutions.

Hope this helps some.

Offline

Board footer

Powered by FluxBB