Beginner · Ethernet, MAC addresses and the Cisco CLI · topic 9 of 57 · 30 min
ARP, the default gateway and ping
Explanation
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.
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")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
- 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.
- Every device also notes the sender IP and MAC from the request, if it already has an entry or is the target.
- 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".
- 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.
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 staticRouter# 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/0ICMP 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 result | What it usually means |
|---|---|
| Reply from 8.8.8.8: time=24ms | The host is reachable and answering |
| Request timed out | No 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 unreachable | Your 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 failed | A 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.
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
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)
How is an ARP request sent?
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.
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- The Cisco IOS command lineEthernet, MAC addresses and the Cisco CLI · same module
- Troubleshooting tools and common faultsTroubleshooting and the CCNA exam
- Layer 2 security: port security, DHCP snooping, DAINetwork security
- Validating addresses and checking the same subnetIPv4 addressing
- IPv6 address types, EUI-64, SLAAC and NDPSubnetting practice and IPv6
- DHCP: automatic addressesIP services: DHCP, DNS, NAT and more
Questions people ask about this
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).
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.
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.
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.
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 more topic in “Ethernet, MAC addresses and the Cisco CLI” before its exam: The Cisco IOS command line.
- 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.
- Then the next module, IPv4 addressing. 57 topics left in the course before the final exam.