how subnets communicates using a router
Step by step eh?
Challenge accepted!
First of all you have two host devices. Let's say they have IP addresses 192.168.1.10 and 192.168.2.10. We'll call them device 1 and device 2 respectively.
The router has IP addresses on both networks with last octet being .1 (that's 192.168.1.1 and 192.168.2.1). The physical configuration doesn't matter, as long as the router is connected to both networks.
Device 1 wants to send a packet to 192.168.2.10. It knows it has an address from 192.168.1.0/24 (that 24 is the 255.255.255.0 subnet mask) range, which doesn't contain the address 192.168.2.10. That means it has to send the packet to its default gateway address.
Let's go all in and assume that device 1 doesn't know where its default gateway is. It sends an arp request saying basically "Who has 192.168.1.1?". It will receive an answer from the router along the lines of "I have it, my MAC address is xx:xx:Xx:Xx:Xx:xx." The MAC address/IP address pair is added to ARP table on device 1.
Now device 1 knows where its default gateway is so it sends the packet towards the MAC address the router has provided.
The original packet has the following address info:
Source IP: 192.168.1.10
Destination IP: 192.168.2.10
Source MAC: device 1 MAC
Destination MAC: router MAC corresponding the interface with IP 192.168.1.1.
The router receives the packet and starts going through its routines. There could be various steps like access lists and MAC filters, but for this purpose we'll go straight to routing table.
The destination IP address 192.168.2.10 is checked against the routing table from top to bottom. If there are no hits, the packet is sent to the router's default gateway or dropped if there is no default gateway. The default gateway can also be called 0.0.0.0/0 route.
Now, in this case there is a route towards 192.168.2.0/24 network, and since routers choose the more precise route over the less precise, this one gets chosen even though there might be a default route configured on the router.
Now, let's assume the router does have the route for 192.168.2.0/24 but it doesn't know who has the IP 192.168.2.10. The router sends an ARP request as device 1 did earlier, to which device 2 responds with it's MAC address which then gets added to the router's ARP table like before.
The router now doesn't simply send the packet forward. It has to first change the packet's layer 2 frame source MAC and destination MAC addresses to match the second network.
The packet now has the following address info:
Source IP: 192.168.1.10
Destination IP: 192.168.2.10
Source MAC: router MAC corresponding the interface with IP 192.168.2.1.
Destination MAC: device 2 MAC
The packet is then sent to device 2.
Transaction completed.
This whole process will take up to a few milliseconds.
Hope this helps. ![]()

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now