How does a PC with two network cards idenitfy the source IP address for IP packet construction ?

Bookmark and Share
Assume that a PC has been configured for two networks, 192.168.1.0/24 and 192.168.2.0/24 network. The IP address of Network card 1 is 192.168.1.1, and IP address of Network card 2 is 192.168.2.1.
Suppose the user on the PC pings an IP adddress 192.168.2.3 and later 192.168.4.1 from the command prompt of the PC.  Which IP address would be used as the source IP address in the IP packet ?
The following set of events happen when the command is issued.
Destination IP address on the same network (192.168.2.3)
1. The destination IP address ( 192.168.2.3) is compared with the routing table on the PC. A sample routing table on Windows XP with one network card is given below
===========================================================================
Active Routes:
Network Destination        Netmask                          Gateway               Interface          Metric
0.0.0.0                               0.0.0.0                           192.168.2.1        192.168.2.2        25
127.0.0.0                          255.0.0.0                        127.0.0.1            127.0.0.1             1
192.168.2.0                      255.255.255.0                192.168.2.2         192.168.2.2       25
192.168.2.2                      255.255.255.255             127.0.0.1            127.0.0.1           25
192.168.2.255                  255.255.255.255             192.168.2.2        192.168.2.2       25
224.0.0.0                          240.0.0.0                        192.168.2.2          192.168.2.2       25
255.255.255.255              255.255.255.255            192.168.2.2          192.168.2.2       1
255.255.255.255              255.255.255.255            192.168.2.2               2                   1
Default Gateway:       192.168.2.1
------------------------------------------------------------------------------------------------------------------------
2. The destination IP adddress in this case is 192.168.2.3 would be "ANDED" with all the netmask entries corresponding to the routing entries on the PC.
3. The "Anding" process would yield the network address corresponding to the IP address.
4. The network address would now be compared with the exisitng network destination address on the routing table of the PC. After the destination network match is identified, the interface IP adddress corresponding to the network entry would be selected as the source IP address of the IP packet. In this case the IP address 192.168.2.1 would be selected and the packet constructed with the destination IP address as 192.168.2.3.
Destination IP address on different network. (192.168.4.1)

Assume that the PC pings a different IP address 192.168.4.1
1.The destination IP adddress in this case is 192.168.4.1 would be "ANDED" with all the netmask entries corresponding to the routing entries on the PC.
2. The network corresponding to the  address would not be found on the routing table since none of the IP address configured correspond to the network address.
3. The default route entry would eventually be selected.
4. The interface IP address corresponding to the default route entry would be selected as the source IP address
P.S When there is more than one IP address configured on the PC, the default gateway should be configured only on one adapter. Or this might create multiple default routes and eventually would route the packets to incorrect network
If two default route entries exist (in some cases), the correct entry should be configured with a lower metric value.

{ 0 comments... Views All / Send Comment! }

Post a Comment