11-18-2008 02:00 AM - edited 03-06-2019 02:32 AM
Can anyone tell me, how a router deals with IP and MAC adresses when routing?
Lets imagine, there is a router with 2 interfaces: 192.168.1.14 and 192.168.2.14 with MAC addresses A and B respectively. There are two computers C and D with ip addresses 192.168.1.10 and 192.168.2.10, connected to the router's appropriate interfaces. What happens, when computer C ping computer D?
How I understand it, computer C takes routers mac address B as a destitanation MAC and computer's D IP for destination IP. Router, in its turn, replaces source IP address (192.168.1.10) with its interface address (192.168.2.14) and sends the packet to computer D with source MAC address of computer C.
When computer D returns ping, the packet is sent to the router's 192.168.2.14 interface, as the packet was received with this IP address in the source field. How does router know, how to send this packet to computer C? By inspecting destination MAC address field?
11-18-2008 02:36 AM
Hi,
computer c issue a ping with its own IP address as the source address.
Computer C , ARPs for the Destination address (192.168.2.10) which is computer D.
Router A, tells computer C to send the data to its Own Mac-address (Mac address of Router A).
Router A receives the Packet, does routing lookup by consulting its routing table, finds a route to (192.168.2.10) through router B.
Router A sends the Packet to RouterB Phisical media address (Mac address of router B) with the Source and Destination addresses unchanged.
Router B receives the Packet , consults its routing table, finds the host (192.168.2.14) whis is directly connected host and sends the packet to the host.
Likewise, The same process happens for the returned path.
Keep in mind that during this process the (Source and Destination IP Address remains unchanged, Only Phisical media address is changed).
HTH
mohamed
11-18-2008 03:02 AM
Thank you.
Now tell me why do I have to configure NAT, if one interface on the router is LAN, another is assigned a global IP for internet connection?
11-18-2008 03:08 AM
Got it myself lol thank you ))
11-18-2008 03:14 AM
Simply because private addresses are not routable through the Global Internet.
As defined in (RFC 1918), the bellow addresses are private addresses that should be translated to a public addresses in order to be routed to the internet:
1- 10.0.0.0/8
2- 172.16.0.0/12
3- 192.168.0.0/16
HTH
Mohamed
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: