8 - ARP, Local Subnets and Default Gateways
Reminder that MT is week 6 Wednesday.
How can we go from using an ethernet switch to using an IP address? ARP - Address Resolution Protocol is the process:
Configure PC
What do you need to configure your PC to use a network?
- IP address of the device
- Subnet Mask
- Default Gateway
- DNS server IP address
Recall that the subnet mask says how many bits are the subnet. For example, 129.65.33.2/24
is on the subnet 129.65.33.0
(again, just AND with 24
1s on the left).
Now if you ping 8.5.4.3
, this IP is not on the subnet. So what your PC will do will:
- Compare the subnet of your device vs the IP you're sending it to
- If it's outside this subnet, it sends it to your Wireless Router
Example
Consider again:
Say PC1
calls ping 129.4.3.11
. It will:
- Determine the subnet of the IP being pinged (and determines its own subnet):
- For the example:
PC1
has IP129.4.3.2
with subnet mask/26
, so then our subnet is129.4.3.0/26
.
- For the example:
- Now it'll look at the IP it's pinging (here
129.4.3.11
) and do the same thing:- Here it's
129.4.3.0/26
- Here it's
- Now if they are the same (like in this case) then send it directly to the destination. You can ARP - Address Resolution Protocol for the MAC address if needed.
Let's say PC1
wants to call ping 8.5.7.3
now:
- The subnet of itself is the same.
- The subnet for the destination is
8.5.7.0/26
- These are different, so you send the traffic to the router via the Default Gateway! It'll ARP - Address Resolution Protocol on the default gateway (if needed), then sends the packet once it has the MAC address.
If you don't have a default gateway, the router is gonna say "SOL" to your device, leading to an unresponsive ping
.
But notice the router needs to be on the same subnet! Otherwise, the router will never be able to allow ARP send/requests on the LAN.
For example, if PC1
wants to ping PC3
it will:
- Determine it's own subnet (same as before:
129.4.3.0/26
) - Determine the destination subnet (
129.4.3.128/26
) - These are different, so then it's going to use the default gateway to forward that to the router (again ARP - Address Resolution Protocol for the default gateway if needed).
You cannot ARP - Address Resolution Protocol over a different subnet!
When PC1
tries to ping PC3
via the Default Gateway, the only entry in the ARP table will be the Default Gateway. That's because it only needed the MAC address for the router, since it's only dealing with that router in that subnet.
A Worked Example
Say PC1
calls ping 1294.3.11/26
:
PC1
's subnet:129.4.3.0/26
PC2
's subnet (same as `PC1)- They're the same, so ARP - Address Resolution Protocol on the subnet. This is a broadcast request. "Who has
129.4.3.11
? Give me your MAC!":
- Both
PC1
andPC2
will see this, and write down these MAC-IP mappings in their ARP caches. - Now we deal with the
ping
part (see 1 Intro to Networks (Ping, Traceroute, Wireshark) for more info). There's two parts:
First,PC1
will make an echo request frame.
Second, it hits the switch, and forwards to PC2
. It sees it and sends an echo reply frame (very similar to the one above, just flipped MAC
addresses.
A Different Example
Say it's the same example, but now PC1
will ping 8.2.3.4
:
PC1
finds its own subnet: (129.4.3.0/26
)- Finds the IP's subnet:
8.2.3.0/26
- These are different, so look at the Default Gateway. It is
129.4.3.18
. It'll ARP - Address Resolution Protocol for the MAC of the router. - The router
R1
sees this, and responds with it'sMACR
MAC address (see the other example for the header information). - Both
PC1
andR1
note these in their ARP cache. Note that nowPC1
has info on bothPC2
andR1
, whileR1
only knows aboutPC2
. - The
ping
happens, doing the echo request toR1
:
which gets sent to the internet by R1
via it's own request. It then sends that forward to :
Writing the Commands
Notice here that the ARP cache will only have one entry, since all ping
's will only query for the default gateway's MAC address.
What is the Default Gateway used by the routers? It's usually just the ISP (Internet Service Provider)'s. Note that if two routers are connected on a subnet and then have each other has gateways of last resort, then the traffic will just loop forever since they will redirect to each other.