Categories
Computers

Revisiting dnsmasq

Due to some friendly ribbing in the comments in my post about dnsmasq, I thought I would make an attempt to explain some of the alphabet soup. All of this stuff is readily available on the web and can be found with a little googling, but I’ll try to give a one cent synopsis. Obviously, if you’re net savvy there’s not going to be anything beyond this point that you don’t know already.

DNS is an acronym for Domain Name System. DNS is the means by which a computer name is turned into an IP (Interent Protocol) address. In networking, names are meaningless to computers because by themselves they provide nothing useful for communicating with other computers. The IP address, in contrast, provides a hierarchical numbering system that allows computer software to find another computer anywhere on a network. Computers are really good at crunching numbers.

By comparison, people, generally, aren’t so good with numbers; but we are good with names. DNS is often analogized to a phone book. In this case, a computer is essentially a phone book where another computer can request the IP address of another computer based on a name. These “phone book” computers are called DNS servers. So, for instance, when you go to www.google.com, a request is made to a DNS server for the name www.google.com. The DNS server returns the IP address 208.67.217.231 to your computer and then you’re computer can communicate with the computers at www.google.com.

DHCP is an acronym for Dynamic Host Configuration Protocol. It defines a means by which a computer on a network can get configuration information that allows that computer to work on the network it is connected to. Typically, that means an IP address, the IP address of a gateway, a subnet mask, and the IP address of a DNS server. There is much more configuration data that can be provided, but these are typically what’s required on a simple network.

An IP address is just a means for uniquely identifying a computer on a network.

A “subnet mask” is a special number that allows a computer to determine if an IP address might exist on a local network. If an IP address is determined to not be on the current network, then any communication with this off-network IP is sent to the “gateway.”

A “gateway” is the IP address of another computer, or network device, that provides a connection to other networks. In a home network situation, it’s typically a router nowadays. In large networks, it’s oftentimes another computer dedicated to the purpose of routing- that is, moving network communication between networks. A gateway is not required for simple networking, such as moving files, but is essential for web browsing. Without it, a user could not visit websites.

So, armed with these definitions, what is dnsmasq?

It’s a piece of software that makes a computer into a DNS server and a DHCP server. Using it, a computer on a network can accept DNS requests from other computers so that a name can be resolved into an IP address. Additionally, a computer using dnsmasq can serve configuration information to other computers using DHCP so that new computers or transient computers (think laptops) on a network can work on the local network.

When dnsmasq is installed and configured, other computers get their network configuration from dnsmasq. This includes telling these other computers that their network’s DNS server is the computer running dnsmasq.

How does dnsmasq work? In a nutshell, for local computer names (think computers on the home network) dnsmasq already has IP/ name information through it’s configuration file. For names not on the local network, it performs the DNS request to a DNS server(which it knows about again, through the configuration file), stores the returned IP address for future requests, and returns the IP address to the requesting computer.

By now, you’re probably totally confused. But since you’ve come this far, we might as well go the whole nine yards and explain why dnsmasq has an integrated DHCP server.

When computers get network configuration information from a DHCP server, there is no guarantee that the IP address assigned to the computer will be the same every time, creating a problem for a DNS server. If a computer’s IP address changes, and the DNS server is unaware of the change, the computer becomes unreachable through it’s name because when a request comes in the wrong IP address will be returned by the DNS server.

By combining DNS services with DHCP services, dnsmasq can automatically update its DNS server with new IP address information. So local computers that are turned on and off on the network are always reachable using a name.

So there it is. Clear as mud?

One reply on “Revisiting dnsmasq”

Leave a Reply

Your email address will not be published. Required fields are marked *