That simply this for home use and you can tell me what I'm not understanding.That say there are three computers IP address 192.168.0.2 ,192.168.0.3 , 192.168.0.4 and the IP address of the router or also know as gateway address of the router is 192.168.0.1.The router must know the gateway address of the ISP . So the router will forward it to the gateway address of the ISP.
Actually, the router[hardware] only knows the devices attached to it and the
gateway address. If the target address
is not attached to this router (ie has an address matching the subnet), then it logically says "
heck if I know - - punt the data out the gateway and see what happens".
Now bit more complex . Say there is three computers down stars IP address 192.168.0.2 ,192.168.0.3 , 192.168.0.4 and the IP address of the router 192.168.0.1. Well up stars ( three more computers ) IP address of 192.168.1.2 ,192.168.1.3, 192.168.1.4 and the IP address of the second router 192.168.1.1. So the second router must know the IP address of the first router and the first router must know the IP address of the ISP gateway to send data out. Well incoming data the first router must know the IP address of the second router.
No, routerA(192.168.0.1) knows nothing of routerB(192.168.1.1)
This is what I thought how it works......
The solution is in the routing table.
take this:
ISP===routerA---------------[W]routerB(192.168.1.1)---- devices attached
(192.168.0.1) showing gateway is 192.168.1.1
|
|
devices attached all report gateway is 192.168.0.1
notice that
[W](the wan side of routerB). Every router has two addresses,
1) the uplink for output leaving the subnet
2) the lan ports belonging to this router (aka this subnet)
Looking from inside routerA, routerB [W] has an address belonging to routerA's subnet (eg 192.168.0.254).
With only the information stated above, a PC trying to access a routerB device will fail, as,
all 192.168.1.x addresses are not part of routerA's devices and "
heck if I know - - punt the data out the gateway and see what happens" - - the data goes UPSTREAM to the ISP and fails.
When properly configured, the ROUTING table solves this dilemma with a line
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.5 20
192.168.1.0 255.255.255.0 On-link 192.168.0.254
The BLUE line is known as the default route and says to reach the gateway, send packets on the NIC address 192.168.0.5
The RED line says, to reach any 192.168.1.* address, send the packets to the address 192.168.0.254 (the [w] side of routerB). Once inside routerB, it's his job to find the device
[sorry for the reedit - - fumble fingered moused the wrong button]