Jump to content

how subnets communicates using a router

Go to solution Solved by U.Ho,

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. :)

They wouldnt be able to since they are on separate subnets. They would have to be on 2 different routers and you would need to link the 2 routers together with a physical ethernet cable and then setup a static route between the 2 so they could talk. 

 

Community Standards

Please make sure to Quote me or @ me to see your reply!

Just because I am a Moderator does not mean I am always right. Please fact check me and verify my answer. 

 

"Beast Mode"

Ryzen 7 9800x3d | Arctic Liquid Freeze 3 Pro 360 | MSI X870 Tomahawk Wi-Fi | MSI RTX 5080 Gaming Trio OC | Gskill Flare X5 6000MT/s CL30

1tb WD Black SN850x NVMe | 4tb WD SN850x NVMe | Antec Flux Pro | Be Quiet Pure Power 13 M 1000w | OWC 10gb NIC

 

Dedicated Streaming Rig

 Ryzen 7 3700x | Asus B450-F Strix | 32gb Gskill Flare X 3200mhz | Corsair RM550x PSU | MSI Ventus 3060 12gb | 250gb 860 Evo m.2

Phanteks P300A |  Elgato HD60 Pro | Avermedia Live Gamer Duo | Avermedia 4k GC573 Capture Card

 

Link to post
Share on other sites

The goal of a router is to forward packets between different networks. I'd imagine the router could have an IP address on each network, similar to how you would use a router to connect to the Internet. It'd need a separate NIC for each network, of course.

Link to post
Share on other sites

1 hour ago, Kavawuvi said:

The goal of a router is to forward packets between different networks. I'd imagine the router could have an IP address on each network, similar to how you would use a router to connect to the Internet. It'd need a separate NIC for each network, of course.

Basically yes except needing a different NIC for each network. A router NIC/interface can have multiple IP addresses also being on different subnets.

 

Routers and computers have routing tables which tell them where to send packets based on destination networking.

Link to post
Share on other sites

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. :)

Link to post
Share on other sites

19 hours ago, U.Ho said:

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. :)

my friend you are a hero wish every one was as challenging as you saved my ass thanks 

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×