Skip to content

Beginner · Ethernet, MAC addresses and the Cisco CLI · topic 9 of 57 · 30 min

ARP, the default gateway and ping

Explanation

To send a frame, a PC needs the MAC address that goes with an IP address. ARP finds it: a broadcast request asks "who has this IP?" and the owner sends a unicast reply. If the destination is on another network, the PC sends the frame to its default gateway (router) instead. Ping uses ICMP echo request and echo reply to test whether a host can be reached.

Why ARP?

Applications use IP addresses, but an Ethernet frame needs a destination MAC address. ARP (Address Resolution Protocol) is the bridge between them: it finds the MAC address that belongs to an IPv4 address on the local network. (IPv6 uses a different method, Neighbor Discovery, covered later.)

Local or remote? The first decision

Before sending, a PC compares the destination IP address with its own IP address and subnet mask. If the destination is in the same network, it delivers the frame directly to that host. If not, it sends the frame to its default gateway, the router that leads out of the local network, and the router carries the packet onward.

python
import ipaddress

me = ipaddress.ip_interface("192.168.1.10/24")
for dst in ["192.168.1.55", "8.8.8.8"]:
    if ipaddress.ip_address(dst) in me.network:
        print(dst, "is local: ARP for", dst)
    else:
        print(dst, "is remote: ARP for the gateway 192.168.1.1")
The decision every PC makes before each packet. The ipaddress module does the subnet maths.

So for a remote destination, the PC ARPs for the MAC of the gateway, not the far server. The frame carries the gateway MAC, while the packet inside still carries the far server IP address.

How ARP works

  1. ARP request: the PC broadcasts a frame to ffff.ffff.ffff saying "Who has 192.168.1.1? Tell 192.168.1.10". Every device in the LAN receives it.
  2. Every device also notes the sender IP and MAC from the request, if it already has an entry or is the target.
  3. ARP reply: only the owner of 192.168.1.1 answers, with a unicast frame straight back: "192.168.1.1 is at 0011.2233.4401".
  4. The PC stores the answer in its ARP cache (ARP table) so it does not have to ask before every packet.

Entries expire after a while: Cisco routers keep them for 4 hours by default, while Windows and Linux keep them for much less (seconds to minutes). Gratuitous ARP is an ARP that a device sends about its own address, for example when it boots, so others update their caches.

output
C:\> arp -a
Interface: 192.168.1.10 --- 0x7
  Internet Address      Physical Address      Type
  192.168.1.1           00-11-22-33-44-01     dynamic
  192.168.1.255         ff-ff-ff-ff-ff-ff     static
Windows: arp -a shows the ARP cache. Linux uses ip neigh.
output
Router# show ip arp
Protocol  Address        Age (min)  Hardware Addr   Type   Interface
Internet  192.168.1.1         -     0011.2233.4401  ARPA   GigabitEthernet0/0
Internet  192.168.1.10        3     00aa.bbcc.dd10  ARPA   GigabitEthernet0/0
Cisco IOS: show ip arp. A dash in Age means the address belongs to the router itself.

ICMP and ping

ICMP (Internet Control Message Protocol) carries error and test messages for IP. Ping sends ICMP echo request messages and waits for echo replies. It reports whether replies came back and the round trip time. Traceroute (tracert on Windows) also uses ICMP replies to show each router on the path.

Ping resultWhat it usually means
Reply from 8.8.8.8: time=24msThe host is reachable and answering
Request timed outNo reply came back in time. The host may be off, a firewall may block ICMP (Windows Firewall often blocks incoming ping by default), or the reply has no route back
Reply from 192.168.1.10: Destination host unreachableYour own PC (the address shown) could not deliver it, usually because ARP got no answer for a local host. If a router address is shown, that router has no way to reach the destination
General failure or transmit failedA local problem: no network connection, or a bad adapter setting

On a Cisco device, ping shows one character per probe: ! for a reply, . for a timeout and U for unreachable. The first ping to a new neighbour often shows .!!!! because the first probe was lost while ARP did its work.

Careful: Common mistakes: thinking a PC ARPs for the far server MAC address when the server is on another network (it ARPs for the gateway), forgetting to set a default gateway (local pings work but nothing outside does), and deciding "the server is down" just because ping times out (many servers and firewalls block ICMP). Test with the real service too, for example by opening the web page.
Tip: A quick home test from the bottom up: ping your own gateway, then ping 8.8.8.8, then ping a name like google.com. The first failure tells you where to look: local LAN, the ISP path, or DNS.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

ARP, the default gateway and ping · 1/7

ARP: IP to MAC

Frames need MAC addresses, but apps use IP addresses. ARP finds the MAC address for an IP address on the local network.

Prefer a video by a teacher? Find free videos on “ARP explained default gateway ping ICMP CCNA” on YouTube ↗

In real life: Two clinics, one missing gateway

A diagnostic lab in Lucknow adds a new reporting PC. It can print to the printer in the same room but cannot reach the head office server in another city. ipconfig shows the right IP address and mask, but the default gateway is blank. Without a gateway, the PC has nowhere to send remote packets. The technician sets the gateway to the router address 10.20.1.1, and the server opens at once.

Practice (0/3 done)

Task 1 · Question

How is an ARP request sent?

Task 2 · Code · Python

Write next_hop(my_ip, prefix, dst_ip, gateway) that returns the IP address a PC should ARP for. If dst_ip is in the same network as my_ip (with prefix length prefix, such as 24), return dst_ip. Otherwise return gateway. Use the ipaddress module.

Task 3 · Question

A user pings 192.168.1.77 and gets "Reply from 192.168.1.10: Destination host unreachable". 192.168.1.10 is the user's own PC. What is the most likely cause?

Quick quiz

Question 1

1.How is an ARP reply normally sent?

Question 2

2.A PC at 192.168.1.10/24 sends a packet to 172.16.5.5. Which MAC address will the frame carry as its destination?

Question 3

3.Which command shows the ARP cache on a Cisco router?

Question 4

4.Which ICMP messages does ping use?

Question 5

5.A PC can ping printers in its own network but nothing outside. What should you check first?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

How is an ARP reply normally sent?

Answer: As a unicast to the device that asked

Only the owner answers, directly to the sender.

A PC at 192.168.1.10/24 sends a packet to 172.16.5.5. Which MAC address will the frame carry as its destination?

Answer: The MAC of the default gateway

172.16.5.5 is in another network, so the frame goes to the gateway.

Which command shows the ARP cache on a Cisco router?

Answer: show ip arp

show ip arp lists IP-to-MAC mappings on IOS; arp -a is the Windows command.

Which ICMP messages does ping use?

Answer: Echo request and echo reply

Ping sends echo requests and expects echo replies.

A PC can ping printers in its own network but nothing outside. What should you check first?

Answer: The default gateway setting

Local traffic works without a gateway; anything remote needs one.

A PC can ping 8.8.8.8 but not www.irctc.co.in. What is the most likely problem?Related

Answer: DNS

Reaching an IP address proves routing works. Failing on a name points to name resolution (DNS).

From Troubleshooting tools and common faults

Dynamic ARP Inspection checks ARP messages against what?Related

Answer: The DHCP snooping binding table

DAI compares the IP and MAC in each ARP message with the bindings learned by DHCP snooping.

From Layer 2 security: port security, DHCP snooping, DAI

What is the Ethernet broadcast MAC address written in Cisco format?Related

Answer: ffff.ffff.ffff

Broadcast is all ones. 255.255.255.255 is the IPv4 broadcast, not a MAC address.

From Ethernet frames and MAC addresses

Users report that connections drop at random, and Windows shows an "IP address conflict" warning. What is the most likely cause?Related

Answer: Two devices have the same IP address

An IP conflict means two devices use the same address, often a static address that is also in the DHCP pool.

From Validating addresses and checking the same subnet

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 1 more topic in “Ethernet, MAC addresses and the Cisco CLI” before its exam: The Cisco IOS command line.
  2. Module 2 exam: Ethernet, MAC addresses and the Cisco CLI · 13 questions · 20 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, IPv4 addressing. 57 topics left in the course before the final exam.

← Previous: How a switch learns and forwards