Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How NIC know the Router IP?(Urgent Help!) 2

Status
Not open for further replies.

JethroWong

Technical User
Apr 24, 2003
5
0
0
HK
Assume

computer A is in subnet A
computer B is in subnet B
two routers are beteen A and B

Computer A send packet to B
the packet must throught a router A then router B then computer B recieve

Computer A must
1.know the router A IP first
2.then use ARP to get the MAC of router A
3.then start to send the packet(router A's MAC and computer B's IP as destination) to B.
4. ............


The problem is how the computer A know the router A's IP(1st step)?

Apart from DHCP/RARP/BOOTP and static routing table?

Thanks!
 
Because router A's IP is given to Computer A as the Gateway address by the DHCP service.

But it really does not even need that information, per se. When the Computer B address is placed on the wire the router identifies it as belong to a non-LAN network segment and it routes it the only way it knows how, by placing it on the WAN side of the router. If dynamic routing is enabled, or a static route assigned, it is given alternatives to more efficiently route the package, but in the default case it simply places it on the WAN side and goes back to work.

 
Yes I know

Then if the router disable the DHCP service and we don't set the gateway of computer A, can computer A find router A/router A's IP?
 
If you statically assign Computer A the address 192.168.2.1 and Router A 192.168.2.254 (subnet masks of 255.255.255.0), Computer A can find the router by using ARP.

For example: Ping 192.168.2.254

Computer A immediately realizes that this address is local (within 192.168.2.xxx). This will cause Computer A to do an ARP broadcast (Who is 192.168.2.254? Tell 192.168.2.1). Router A will respond "192.168.2.254 is at MAC address xx-xx-xx-xx-xx-xx". Computer A now sends an ICMP packet addressed to MAC address xx-xx-xx-xx-xx-xx and the ping succeeds.

However, if you statically give Router A the address 192.168.10.254 (subnet 255.255.255.0) you will have a problem. When you try to PING 192.168.10.254, Computer A recognizes that this address is not local (not within 192.168.2.xxx). If no default gateway is set up then Computer A will give you an error because you have not told it where to send packets that are outside the 192.168.2.xxx range.

In order for Computer A and Router A to talk to each other, you would need to manually insert Router A's MAC address to each packet (through some software) or make a static entry in the ARP cache that tells the computer that 192.168.10.254 is MAC xx-xx-xx-xx-xx-xx.

Now, you may wonder why couldn't Computer A do a "super-broadcast" that basically says "Is anybody out there? If so, tell me your MAC address". I believe there is a protocol that does this (called HELLO). However, even if the router did respond, Computer A would need some software that would record the MAC address and statically add it to the ARP cache.

When Computer A makes ANY packet it ALWAYS consults the ARP cache for the MAC address. If the entry is there, great! The packet is made. If there is no entry saying that 192.168.10.254 is at MAC xx-xx-xx-xx-xx-xx then Computer A cannot make a packet. Computer A cannot do an ARP request to 192.168.10.254 because it is not in the 192.168.2.xxx range.

You could get around this by using the subnet mask of 255.255.0.0 which would put both addresses within the "local" range. Computer A can do an ARP request and Router A will respond.

So, in answer to your question, Computer A MUST be assigned a default gateway (address of Router A) either statically or through DHCP in order to have any chance of talking to Computer B.
 
Open a command prompt ...

Type "Route print", this way you will see on the top line:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.254 192.168.1.25 1

Your Ip = .25
Gateway = .254

The network 0.0.0.0 with mask 0.0.0.0 = a remote network, wich means that you will use the default gateway as the adress and you will use the NIC with .25 to reach the gateway.

Good luck

Jörgen Hjärtenflo
MCT 2003
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top