1

I just started a new job and we have an intranet with our own top-level domain, such as .abc. Thus, if I want to log in to our "e-benefits site" I would just open up a web browser and go to worklink.abc and login from there.

As a developer who knows too little about DNS and systems IT, I am curious as to how this works, and what I would need to do in order to accomplish something similar at home.

My name is Adam, and I would like to have a home intranet where perhaps all domains ended with a .adm suffix. That way I could develop internal Java web apps to map to, pages like http://mydomain.adm?foo=bar, etc. I'm quite sure this will lead me into a new world of DNS servers and configurations, but that doesn't scare me.

Can one of you "systems guys" give a poor Java developer a high-level, laymen's introduction to how I might be able to accomplish this? At this point I'm not even sure where to start. If you can give me a decent punch list to work with, I can research the details from there. Thanks in advance!

Mara
  • 139
  • 1
  • 11
  • What operating systems are you familiar with? If your intention is to learn DNS, having a play with DNS on a Windows Server is fairly straightforward if you're a Windows guy. If learning DNS is not your intention and you just want the end result, then you may aswell just use your Operating Systems host file to do this. – Dan Dec 23 '11 at 16:08
  • Also, and I'm sure you know this (But for the benefit of Google!) it is not possible to set up your own TLD on the Internet. This can only ever work when using your own DNS servers. – Dan Dec 23 '11 at 16:10
  • Familiar with both Windows and Linux (CentOS, Ubuntu, Debian). Would prefer something in Linux but could go either way. I didn't realize the host file was capable of setting TLDs but will check it out. I do really want to implement this using formal DNS practices, so any encouragement towards that route is appreciated enormously! – Mara Dec 23 '11 at 16:11

1 Answers1

1

As Dan mentioned, you can use your system /etc/hosts file to accomplish what you want. This is not "setting up a TLD" in any meaningful way, since it in fact doesn't have anything to do with DNS. /etc/hosts is (...usually...) referenced by your system before it checks with DNS. The hosts file simply maps names to addresses, and it doesn't know anything about domains. So if you put this in /etc/hosts:

127.0.0.1 localhost apple.com

And then do this:

curl http://apple.com/

curl will try to connect to 127.0.0.1. But if you do this:

curl http://www.apple.com/

Your system will (...probably...) refer to DNS, because www.apple.com was not found in the hosts file. Because most software uses the systems name resolution facilities (as controlled by /etc/nsswitch.conf), this will work for just about everything. It's simple, but there are some disadvantages:

  • If you have more than one machine, you'll need to keep the hosts file up to date on all of them.
  • You can't provide anything other than name-to-address mapping using the hosts file. So, no MX or SRV records, no CNAME records, and so forth.

The next easiest solution is to use dnsmasq, which is a very nifty tool that provides DNS, DHCP, and TFTP services -- in other words, just about everything you need for a small network. Using dnsmasq, you can:

  • Create your own TLD for use on your network,
  • Provide the ip address of your local nameserver automatically to clients via DHCP,
  • Override answers from public DNS servers (so, you can replace "www.google.com" with an internal server of your choice, for example).

dnsmasq is pretty well documented, but if you have specific questions after looking at the documentation come on back and I'll see what I can do.

Here's a really short example...if you run this:

dnsmasq -C /dev/null --local=/localnet/ -s localnet -E

The -C /dev/null is there to make sure we're starting with an "empty" configuration, since I don't know what might be in your local /etc/dnsmasq.conf. Will this command line, dnsmasq will make any entries in your /etc/hosts file available via DNS in the "localnet" domain. So for example, if I had the following in my hosts file:

10.10.10.10 fluff
10.10.10.11 nutella

I could do this on a system that was configured to use my dnsmasq instance for DNS:

$ host fluff.localnet
fluff.localnet has address 10.10.10.10

And I can use unqualified names, too:

$ host nutella
nutella has address 10.10.10.11

You can get quite fancy with dnsmasq, and it's probably more than sufficient for a home network. If you needed to serve a larger population -- and provide redundant DNS service, inside/outside views, ACLs, and so forth -- then you would look at something like BIND, but that's not necessary for what you're doing (or for what I'm doing, for that matter -- I use dnsmasq at home).

larsks
  • 43,623
  • 14
  • 121
  • 180