On the web, we use the names of computers or providers such as Facebook, Twitter, and Google. Even when you’re using Facebook’s app, it is also using a computer’s name. This is because we remember names much better than numbers.
But the internet runs on numbers. They’re called internet addresses. The original IPV4 internet addresses are often written like this: 188.8.131.52, 184.108.40.206, and 220.127.116.11. (Those are the internet addresses for Facebook, Twitter, and Google.)
Note: The “newer, bigger, better” internet using IPV6 addressing is pretty much here, but for our purposes, they accomplish the same thing as the old. So, I’ll stick to the old “dotted decimal” notation herein.
To communicate on the internet, something has to translate the human names we know into their corresponding internet addresses.
That’s what a Domain Name Server (DNS) does, it translates names to numbers.
Here’s how it is used.
- Let’s say you to visit this website so you type in “flat5.net” to your browser and press the <Enter> key.
- Your computer first looks to see if it already knows the IP (number) address. If so, it skips to step #5 below.
- If it doesn’t, your computer will ask a DNS, “What is the IP address of the computer named flat5.net?”
- That DNS sends back the answer: 18.104.22.168.
- Your computer then sends a message to 22.214.171.124 saying, “Please send me your web page.”
- If everything works, you get flat5.net’s opening page from the web server I rent at cheap-domainregistration.com.
The DNS lookup (steps #3 and 4) needs to be very quick. This is because a website indirectly references several other websites for things like style sheets, scripts, common icons, and linked images. These indirect references mount up very quickly and, if the DNS is slow, web pages will take a long time to load.
Please notice that, once translated, your computer remembers the name–>address translation. This speeds up your access to a given website, and cuts down on the overall traffic on the network.
Storing a local copy of something from the internet is called caching. Your computer caches the answers from DNS—the internet names and addresses—as well as the web page contents from the web server at that address.
But there’s a contradiction here. To translate a computer’s name to an internet address (number), you have to ask a DNS, and you have to do so without knowing the DNS’s name (because that would, of course, require a DNS).
So, how does your computer learn the address of a DNS?
It has to be told.
- It can get the DNS address from another computer, or
- It can be configured into a computer by hand.
The first answer, getting the DNS address from another computer, is what happens most of the time. For example, if I have my tablet with me and I “connect” to the free wireless network at McDonalds, the answer–the internet address of the DNS name server to use–comes from the wireless server in the restaurant.
The obvious question is, “How does McDonalds know what DNS to use?”
Uhm, because they’re also hooked to a network. They were told what to use, and then they passed it on to my tablet.
Imagine a heap of computers all piled up in the shape of a pyramid. Your computer is on the bottom row. When first turned on and connected to this network, it asks, “Hello, somebody? What DNS address(es) should I use?”
And one of the computers already there will give the answer. (This is part of the service provided by DHCP. I’ll mention that again at the end.) Each computer, unless it has reason to do otherwise, gets the answer from a computer that was started earlier.
In theory, at the pinnacle of this pyramid there would be one computer that knows everything, and who told the first row beneath it, who told the second, and so forth. But having every computer in the world use the same DNS would be an enormous burden on that system.
Instead, it makes a lot more sense to distribute the load.
So, imagine instead a bunch of little pyramids, each with their own DNS. All requests from computers in that little pyramid ask their local DNS for answers.
Now, take a few of those pyramids and scrunch ’em up real tight to each other. Then, take some more of the little pyramids and stack them on top of the first bunch forming a new layer. Continue stacking little pyramids, each layer on top of the one below, until you have a huge pyramid of little pyramids.
When everything is up and running, that’s what it looks like: a giant pyramid built from lots of smaller pyramids. Each small pyramid gets its configuration from above, and then has its own little DNS. (Don’t take this too far because some DNSes, 126.96.36.199 for example, are very big and used by a great many computers.)
And if the DNS in your pyramid doesn’t know the answer, it knows the internet address of the DNS in the pyramid above it. How did it get that? Remember: when the computers first turn on, they are told what DNS to use? The new (littler) DNSes remember that internet address, but they don’t tell their underlings. Instead, the new DNSes pass down their own internet address. By doing so, they start a new (little) pyramid.
This propagation and proliferation of DNS machines down through the pyramid happens very smoothly. It’s one of the key elements in the design of the internet. It’s very simple, and very clever. (Programmers would call this an elegant solution. The internet has many such elegant solutions.)
But let’s say you want to be a rebel!
Just for the hell of it, you might say, “My computer was told to use the DNS at 188.8.131.52, but I know from reading Ed’s blog post that Google is providing that DNS. I don’t trust big corporations, so I want to hand-configure my computer(s) to use a different DNS. How do I do that?”
Not only is it possible, it’s also very practical in certain situations.
For example, in my household, I have added my own local DNS. I did this for performance reasons—a nearby DNS makes web page loading much faster—and to reduce or eliminate certain kinds of websites. (More on what’s being eliminated in a moment.)
My local DNS runs on a small Raspberry Pi 4 computer. For the technically adept, you can set one up for about a hundred bucks. It’s tiny and is shoved to the back corner on the top shelf in our laundry room. It runs 24/7 and is hard-coded to the internet address 192.168.165.71. (It can only be accessed if you’re connected to our local network.)
But the initial reason I wanted my own DNS was for ad-blocking, not for performance.
Running a piece of software named pi-hole, my local DNS blocks advertisements on web pages. Instead of rectangles filled with pictures and moving images about products someone wants us to click and buy, we see just an empty box on the web pages we view. The pi-hole software in our DNS contains what’s called a black-list of domain names that send out most of the advertising on the internet. When a computer attached to our house network downloads a web page, and therein it references one of those ad-providers, pi-hole sends back a special IP address that, when the “advertisement” is fetched, shows on the screen as an empty box. It never fetches the advertisement. As a result, our network traffic is reduced by about 35%, web pages load considerably faster, and we don’t have to see the advertising.
If you want to muck about with this, you’ll need to consult Google or a similar service. You’ll need to know answers to several questions.
- “How can I change my DNS setting?” — The answer will depend on what operating system you are using (Windows, MacOS, Linux, iPhone, Android, etc.).
- “What are the public, free dns servers?” You’ll get a link and can read all about them.
- “Which are the fastest DNS servers?” Again, you’ll get a list, but these may or may not be right for your location.
- “How can I measure DNS response time?” The answer will show you one or more ways to actually probe a DNS server and see how fast it is.
If you’re a command-line person, the dig program is a good tool. It queries the DNS of your choosing and tells you how long it takes to get an answer. You want fast, so less is good.
I will leave the details of dig‘s usage to you. You may need to install and then figure out how to use it. All of this should be adequately documented by dig‘s provider for your operating system.
So, which DNSes do I use?
- My private DNS server, 192.168.165.71, is first in the list; it’s our primary DNS.
- Our second DNS is the firewall configured by our network provider. It’s at 192.168.165.1.
All the computers in our house are on the 192.168.165.X network. The number 192.168.X.X is common for in-house networks, and the next element, the 165, is the street address of the house where I grew up in Memphis. The final X is unique for each computer in our household. For the X, there are 254 numbers to choose from (0 and 255 are forbidden for technical reasons), so there is little danger of using them all up.
The firewall computer, by the way, provides the service that’s used when a computer is plugged into or connects to our house network by wireless. Something called the DHCP or Dynamic Host Configuration Protocol tells the new arrivals what IP address to use on the local network—it makes up that final X value—and also what DNS addresses to use. Thus, when I set up pi-hole, I also configured the firewall to tell all computers to use 192.168.165.71 as their preferred (first) DNS, then 192.168.165.1 [the firewall itself], and if that fails, they should then try 184.108.40.206 [Google], or finally, try 220.127.116.11 [Cisco].