Naked Science Forum

Non Life Sciences => Geek Speak => Topic started by: chris on 22/08/2008 13:11:08

Title: How to establish a DNS on a LAN?
Post by: chris on 22/08/2008 13:11:08
I have discovered that when computers on my LAN go looking for other machines on that LAN, they first end up being referred to my ISP's DNS before coming back to the LAN.

This seems hopelessly inefficient. Is there a way to set up a local LAN DNS which identifies all the computers on that network and only refers IPs not known locally out to the ISP?

Chris
Title: How to establish a DNS on a LAN?
Post by: LeeE on 23/08/2008 09:54:26
Are the machines on your lan assigned their IP addresses via DHCP or have you configured each machine's IP address manually?

If you've configured the network interfaces for them manually then you can match each machine's IP address to it's name in the 'hosts' file on each system.  In Linux this is:

  /etc/hosts

and on a Windows XP Home system I have here it's:

  C:\WINDOWS\System32\drivers\etc\hosts

In that file, and below the line that says:

  127.0.0.1         localhost

add the IP addresses and names for your other systems, so it looks something like:

  127.0.0.1         localhost
  10.0.0.10         tom
  10.0.0.20         dick
  10.0.0.30         harry

etc.

Of course, you need to use the actual IP addresses and names from your lan.

Note that if you only assign localhost to 127.0.0.1, which should be sufficient, you only need to create this file once and then copy it to the other systems.

If the IP addresses are assigned via DHCP you should be able to set it up so that it always assigns the same IP address to the same MAC (ethernet hardware) address, and then use the hosts files mentioned above to do the name resolution.

If you've got lots of systems on your lan i.e. > 100 you may be better off setting up a local lan DNS server but I've never done that, so you'll need to google for a tutorial.

Incidentally, you can block access to web-sites i.e. add-servers etc. using this technique by adding the hostname as an alias to the localhost i.e:

  127.0.0.1        local host www.adserver.com

So that whenever you visit a web-page that contains a link to www.adserver.com your system will look for it at 127.0.0.1 (your local machine) and simply not find it.  Obviously, this is only practical for blocking just a few sites.
Title: How to establish a DNS on a LAN?
Post by: chris on 23/08/2008 10:22:25
Thanks LeeE - and can I assign an IP address as an alias.

In other words, if I use your example above:

127.0.0.1        local host www.adserver.com

Instead of writing "www.adserver.com" can I write their IP address?

Chris
Title: How to establish a DNS on a LAN?
Post by: LeeE on 23/08/2008 16:20:46
Hmm...  not sure - never tried it.
Title: How to establish a DNS on a LAN?
Post by: chris on 23/08/2008 21:11:21
Right, I'll give it a go...