| « HOWTO Sort out kvm | Network Time Protocol (NTP) HOWTO » |
This description shamelessly take from the dnsmasq home page.
Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP server. It is designed to provide DNS and, optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS. The DHCP server integrates with the DNS server and allows machines with DHCP-allocated addresses to appear in the DNS with names configured either in each host or in a central configuration file. Dnsmasq supports static and dynamic DHCP leases and BOOTP/TFTP for network booting of diskless machines.
...
Use the command line below . You will need the universe repository in your software sources list.
The server where dnsmasq is running its DNS and DHCP services is called linux60 (192.168.0.7), The Router is IP 192.168.0.1. There are a mixture of real and virtual machines all using these services. All machines are in the local domain example.com. The client machines will have names like linux12 or kvmubuntu.
Start by making a copy of the files we will be changing so you can always go back to a know starting point.
Looking at the file /etc/dnsmasq.conf first. Below is a good starting point to get things up and running. The lines are listed in the same order as they appear in the default file. Just uncomment and amend them as necessary. (Remove the '#' from the beginning of the line)
domain-needed
What these lines will do for you.
Dnsmasq will, set or find out automatically, lots of common networking and connection values. These do not need to be set unless you are paranoid or like to specifically set these things. Which is rather nice of dnsmasq, don't you agree?
The /etc/hosts file on the example server will look like this. Leave the IPv6 stuff as it was.
127.0.0.1 localhost
One last thing to do it set the localhost or loop device on the server as a nameserver so it can use the DNS service that it is running. Add the nameserver line below to the top of the list in /etc/resolv.conf.
Start by making a copy of the files we will be changing so you can always go back to a know starting point.
The /etc/hosts file on the client machines should look similar to this. Leave the IPv6 stuff alone.
127.0.0.1 localhost
In the example setup our server is linux60 or 192.168.0.7 it is the only machine with a static IP address. This is necessary as we need to tell the other machine were to look for the DNS service. So we need to tell the other machines were to get their DNS service from to take advantage of our shiny new server. We do this by adding a line to /etc/resolv.conf. I put it as the first nameserver in the file.
Only two small changes to make here. We need to make sure that when the host requests an IP address it passes its own hostname to the DHCP server. So the other machines can use its name to look up the IP address it was just given. So for example if we are setting up our workstation called linux12 that is in our fictitious domain example.com we would add the following line to /etc/dhcp3/dhclient.conf
The second is to make sure that the main network interface is set to use DHCP.
Edit the interfaces file and set the NIC to be dhcp as below:
You can now reboot linux12. During which time it will talk to our new DHCP server request a new IP address. The server will remember which IP address it gave out to linux12 and it and other machines on the network will be able to ping linux12. No more needing to know which machine has which IP address.