Using names instead of IP on LAN

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Using names instead of IP on LAN

Post by alex.barylski »

By LAN I mean my home network which sits behind a NAT router.

I have two windows machines and one linux box...each have syste names like:

spectra-desktop
spectra-mobile
spectra-server

Right now each has several services or daemons which other systems might contact occasionally, like SVN for example or FTP or Apache, etc...

Up until now I've used IP addresses cause I was lazy...now my wireless router is acting up and constantly reassign's new IP to each node in the network (there are 4 other computers behind this same NAT which I do no use but others do).

What do I have to do to each computer node (which configs, etc) so that I may refer to the computer names given above and NOT the IP's as this constant changing requires me to then update all my other programs, which is annoying to do year a day never mind once a day or more.

I assume this is possible?

Lets start for example with SSH and putty on my desktop

I connect to 192.168.1.103 which is spectra-server but might be something different in half an hour if I need to reboot the router again. :(

Ideally I make the computer names available to all on the network and voila...problme solved :P

I have tried entering spectra-server insteadof IP and I get an error as expected... :(

Cheers,
Alex
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Using names instead of IP on LAN

Post by alex.barylski »

EDIT | Apparently hosts is disabled by XP :( Ack....one thing after another with system administration...I just wanna write my code :P

I just realized that this is where the hosts files would come in handy, correct?

So I found my Linux and Windows host files and added a simple IP to name map:

Code: Select all

192.168.1.102    spectra-server
Is what I added to my desktop's host file...I rebooted the system...and tried to access the HTTP server on my spectra-server using the name instead of IP

Code: Select all

http://spectra-server/blah
Didn't work... :(

What did I miss?
Last edited by alex.barylski on Mon Dec 01, 2008 3:58 pm, edited 1 time in total.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Using names instead of IP on LAN

Post by VladSun »

PCSpectra wrote:...now my wireless router is acting up and constantly reassign's new IP to each node in the network (there are 4 other computers behind this same NAT which I do no use but others do).
Configure you router to use DHCP with static MAC/IP pairing ;)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Using names instead of IP on LAN

Post by VladSun »

PCSpectra wrote:I just realized that this is where the hosts files would come in handy, correct?
Correct
PCSpectra wrote:So I found my Linux and Windows host files and added a simple IP to name map:

Code: Select all

192.168.1.102    spectra-server
Is what I added to my desktop's host file...I rebooted the system...and tried to access the HTTP server on my spectra-server using the name instead of IP

Code: Select all

http://spectra-server/blah
Didn't work... :(

What did I miss?
Maybe this IP has been assigned to another machine with no WWW service running on it.

Try

Code: Select all

ping spectra-server
and see whether the IP is resolved.
Last edited by VladSun on Mon Dec 01, 2008 5:18 pm, edited 1 time in total.
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Using names instead of IP on LAN

Post by alex.barylski »

Ok. So appreantly Winblows XP (Home or Pro) disables their hosts file...lots of Google results about that issue...

Next best bet is to setup a DNS server locally I suppose...probably on my Spectra-Server machine as it's probably less painful on Debian than Windows.

That...each of my Window machines would need to what:

1. Use the Spectra-Server as a proxy to access the outside world?
2. Somehow use Spectra-Server DNS first then the default?

Funny because while I have experienced anything but grief with this...I think it really made DNS and it's purpose click. So it's not all for nothing. :P

p.s-I did ping each machine and made sure the IP's were good
p.p.s-My router does DHCP I think it's on the way out though...unstable connections and now wonky IP assignments.

Its why IP's have worked for the last 3-4 years I have had a wireless...IP's were pretty much static...I assumed that IP's were uniquely assigned to nodes using MAC address because no matter which port I plug my laptop into it's always the same IP until now...

Cheers,
Alex
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Using names instead of IP on LAN

Post by VladSun »

PCSpectra wrote:Ok. So appreantly Winblows XP (Home or Pro) disables their hosts file...lots of Google results about that issue...
I have no issues with Win XP ...
PCSpectra wrote:Next best bet is to setup a DNS server locally I suppose...probably on my Spectra-Server machine as it's probably less painful on Debian than Windows.
You may setup a local DNS server on your Debian server - it will be a caching DNS and an "authoritive" DNS for your "local zone". It will be good thing for you to learn ;)
In fact, if you setup it, you may also setup it as a router - with DHCP server, etc. ;) It will be fun - I promise ;)
PCSpectra wrote:1. Use the Spectra-Server as a proxy to access the outside world?
No. There is a huge difference between a router and a DNS.
PCSpectra wrote:2. Somehow use Spectra-Server DNS first then the default?
Default. Use IP.
PCSpectra wrote:p.s-I did ping each machine and made sure the IP's were good
So ... it works! You should search for other issues - it's not a DNS issue.
PCSpectra wrote:p.p.s-My router does DHCP I think it's on the way out though...unstable connections and now wonky IP assignments. Its why IP's have worked for the last 3-4 years I have had a wireless...IP's were pretty much static...I assumed that IP's were uniquely assigned to nodes using MAC address because no matter which port I plug my laptop into it's always the same IP until now...
There is a "lease time"... after it is reached a new (in general) IP is assigned. Use static MAC/IP pairing in router DHCP setup to solve this issue.
Last edited by VladSun on Mon Dec 01, 2008 5:19 pm, edited 1 time in total.
There are 10 types of people in this world, those who understand binary and those who don't
Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: Using names instead of IP on LAN

Post by Doug G »

If you're trying to access a web server on a windows machine, don't forget to open http through the windows firewall on the server machine. If you can ping by name but can't open a web page, either http is blocked or the web server really isn't running.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Using names instead of IP on LAN

Post by alex.barylski »

It will be good thing for you to learn
Probably...one of those things as a web developer I should probably be intimate with.
In fact, if you setup it, you may also setup it as a router - with DHCP server, etc. It will be fun - I promise
I dunno about that. I have a NAT router already and wouldn't want to break anything. It might be an interested learning experience though.
No. There is a huge difference between a router and a DNS.
I realize that. (as I understand)A NAT router is fairly simple in what it does:

1. Checks incoming request
2. Checks whether it was requested by anyone in it's own network.
3. Checks port and former step and if either are not allowed packets are dropped
4. Forward request onto node which made request

Isn't this why NAT routers are innately secure? Unless you explicitly request or allow something, it's dropped by the router. Which is why I asked my last question...unless Imisunderstand something???
So ... it works! You should search for other issues - it's not a DNS issue.
Yes they work...I never said it was a DNS issue at least I didn't mean too.

I think the issue is actually with Apache. :oops: :banghead:

I've managed to connect SSH, etc using host names...it's just HTTP now...

I'm not totally sure how to map internal server names to directories though...
There is a "lease time"... after it is reached a new (in general) IP is assigned. Use static MAC/IP pairing in router DHCP setup to solve this issue.
That is how I thought it was done already...so if I use static assignment do I pick which router ports get what IP's or is this automated based on MAC?

Interesting in any case...I think I have much clearer idea as to what DHCP and DNS are all about.

Cheers,
Alex
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Using names instead of IP on LAN

Post by alex.barylski »

f you're trying to access a web server on a windows machine, don't forget to open http through the windows firewall on the server machine. If you can ping by name but can't open a web page, either http is blocked or the web server really isn't running
Windows firewall isn't enabled...nor do I have ZoneALarm...the Apache server is running because I can access the pages via the IP...but the server name fails or reuslts in a gateway error I think...

I believe it has to do with mapping the server name to the directory in which apaches defaults to...but I"m not sure.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Using names instead of IP on LAN

Post by Eran »

What about adding something like the following to your httpd.conf:

Code: Select all

 
<VirtualHost 192.168.???.??? //ip here>
     ServerName Spectra-Server
     DocumentRoot /path/to/root
     ErrorLog /path/to/errorlog
</VirtualHost>
 
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Using names instead of IP on LAN

Post by alex.barylski »

Ahhh...maybe thats hows it's done...I'll give it a try, thanks :)
Post Reply