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).