In addition to Yamakaja's answer, this is how you setup a local DNS server.
First, you need a computer you want to run the DNS server on. This can be one of your normal computers (if they run Linux and are on most of the time) or for example a Raspberry Pi. The advantages of such a device are that it's cheap, does not need much power and it's small.
Setting up the DNS server
I decided to set up the DNS server on a Raspberry Pi using
dnsmasq, which is a small DNS server tool, ideal for use in small networks. You could also use
bind, the de facto standard DNS tool, but this is probably a little too mighty for a small home network.
dnsmasq using the package manager, on Debian-based systems (e. g. Raspbian), the command would be
sudo apt-get install dnsmasq
I now assume you already have set up a static IP address allocation (i.e. the IP addresses you mention in your question don't change). If you haven't,
dnsmasq can be also used as a DHCP server, but I haven't done that yet.
dnsmasq fetches the host names from the
/etc/hosts. Edit this file as follows:
# IP address Host name
The host name
router is now assigned to
Now, you've set up your own DNS server, but the computers in your network don't use it yet. To make them use this server, you have to do one step of preparation:
Find the IP address of your dnsmasq device using
ip address (let's assume it's
192.168.1.42). Open the
/etc/dnsmasq.conf and append the following lines:
dnsmasq it should listen to requests to it when they are addressed either to
127.0.0.1 (i.e. when itself wants to use its DNS server) or
192.168.1.42 (i.e. when other computers want to use its DNS server).
Using the DNS server
You have to tell each computer in your network it should (also) use
192.168.1.42 as DNS server.
The way you do this depends on your operating system.
You can look this up for your specified operation system on the internet easily (just search "Change DNS server on <OS>", or something like that).
For Windows 7, you could follow this tutorial: https://www.opennicproject.org/configure-your-dns/how-to-change-dns-servers-in-windows-7/.
On my system (Arch Linux), I had to append the following line to
Note the file you have to use depends to your network manager configuration.
Add the DNS server IP on each computer you want to use your DNS.
You'll probably have to restart the devices if it does not work immediately.
That's it, you're done. You can now access all devices you've entered in
/etc/hosts of the dnsmasq server simply using the host name you've given it.
(Optional) Checking functionality
If you want to check whether the DNS resolve works correctly, install
dnsutils (Linux) on the system that should use your server. Then execute
$ dig router
This should return something like this
; <<>> DiG 9.10.4-P1 <<>> router
;; global options: +cmd
;; Got answer:
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;router. IN A
;; ANSWER SECTION:
router. 0 IN A 192.168.1.1
;; Query time: 14 msec
;; SERVER: 192.168.1.42#53(192.168.1.42)
;; WHEN: So Jun 26 10:43:18 CEST 2016
;; MSG SIZE rcvd: 50
It shows you the host name you wanted to resolve, the IP address it got resolved to and the DNS server used. As you see, everything is fine.
(Optional) Specifying a TLD
If you want to access the devices not just with
printer but with
printer.home, add the following lines to your
expand-hosts # Tells dnsmasq to add a TLD to each host name
domain=home # The TLD
You may need to restart again.
Sources / further reading
bind (if you're interested in it):