Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, An Introduction to Computer Networking for Teachers. Join the course to learn more.

Finding destination addresses with DNS and ARP

As you know, we don’t use IP addresses to access websites, even though the underlying technology needs them. You don’t often hear people speak about a great website they looked at with an address like 143.15.201.11! We use a name, such as www.bbc.co.uk, and this maps to an IP address. How does that work? And how is the MAC address for the Ethernet frame found?

This step explores these issues and the protocols that provide solutions.

Web servers themselves have IP addresses, and these addresses are necessary if a device wants to send IP packets to a specific destination. However, a set of numbers is not a user-friendly way to interact with such resources.

The names we use are called domain names, and the databases that we access to map the domain names to IP addresses are domain name servers (DNS). The Internet Corporation for Assigned Names and Numbers (ICANN) runs the Domain Name System, a series of DNS which map user-friendly names to their corresponding IP addresses.

The URL "http://raspberrypi.org/education" with "http://" labelled as "Protocol", "raspberrypi.org/" labelled as "Domain", and "education" labelled as "Path".

We all use these user-friendly names. The name is often prefixed with the type of service we are requesting and the protocol to access it, such as http://www or smtp://mail. It may have the path to a particular file added onto the end. The official name for one of these complete addresses is a Uniform Resource Locator (URL). The structure of a URL indicates what type of resource is at the address, what company or group it is from and possibly where in the world it is located.

ICANN’s DNS link to other DNS around the world. So if you are looking for a URL and it is not listed on your local DNS, that server will pass the request on until a DNS somewhere replies.

You can ask DNS to look up a URL on the whois website.

When you want to set up a new website on the internet, you need to find an unused URL and register it with a DNS authority. You need to supply the IP address of the website’s location. The DNS authority will then load the URL and IP addres into the DNS database, and your website will be globally available.

Finding the destination Ethernet address

When we send data to another device on our local LAN, we have usually found the IP address via another service, such as file or print sharing. This happens in the background, and we don’t see these addresses.

A laptop is connected to a switch, which is also connected to a printer and a router to the internet. The computer asks "I know the printer is at 192.168.1.10, but what is the MAC address?" Both the printer and laptop are labelled with both an IP address and a MAC address.

The sending device can encapsulate the request into an IP packet because it knows the source and destination addresses. However, when it comes to encapsulate the packet in an Ethernet frame, it does not know the Ethernet address of the NIC in the destination device. It has to first learn this by broadcasting a frame to all local devices, asking for the one with the specific IP address to reply with its Ethernet address. This process is called Address Resolution Protocol (ARP). A device keeps an ARP table of other devices’ IP addresses and corresponding Ethernet addresses that it has uncovered through this process.

To see the ARP table on your computer, open the command line application, type in arp -a and press Enter.

This works well for devices on the LAN because the broadcast request is sent to them all. However, what about IP addresses that are not on our LAN?

The default gateway, and why we need it

A laptop is connected to a switch, which is connected to a router, which is connected to the internet. A particular website (www.raspberrypi.org) and its IP address (212.49.63.212) are shown as part of the internet. The router has an IP address and MAC address shown. The laptop is asking "I want to get to the Raspberry Pi website. I need to send an Ethernet Frame to the default gateway - what is its MAC address?"

To send an IP packet to a different LAN, the sending device encapsulates the packet in an Ethernet frame. This frame only carries the IP packet to the end of the link, which is the local router. So to form the frame to carry the IP packet, the sending device needs the Ethernet address of the local router. This router has a special IP address that’s called the default gateway, because it is the default route from the local LAN to the rest of the network (in most cases this is the internet). So when a device wants to send an IP packet outside the local LAN, it sends an ARP request using the default gateway. The router replies with its MAC address, and the device uses this as the destination address for the Ethernet frame in which it has encapsulated the IP packet. Thus the IP packet arrives at the local router, which routes it to the internet.

Without a default gateway, IP packets would not be able to leave their local LAN.

Next up

In the next step, you’ll take a quiz to consolidate the knowledge you’ve gained.

Questions

  1. How does a device know the destination is not on the local LAN?
  2. Why do some URLs end in .com, while others are country-specific, such as .co.uk?
  3. What happens if you change the NIC in your computer and plug the computer back into the network?

Join the conversation and share your answers and ideas in the comment section.

Share this article:

This article is from the free online course:

An Introduction to Computer Networking for Teachers

Raspberry Pi Foundation