dual nic access to 2 networks

How does an application decide which nic to go out when going to an external IP or network?

I have a home router going to internet with 192.168.1.0/24

I also have a home lab with 3 routers connected together and routing between them.  The ethernet networks on these 3 routers are:
192.168.101.0/24
192.168.24.0/24
192.168.20.0/24

Then I have an Windows XP home box w/ 2 nics.
Nic 1 is connected to 192.168.24.0/24 default gateway is 192.168.24.1 (router connected to 192.168.20.0 and 192.168.101.0)
Nic 2 is connected to 192.168.1.0/24 default gateway is 192.168.1.1 router connected to internet.

If I try and ping 192.168.101.1 it fails.
If I disable Nic 2, then ping 192.168.101.1 it works.

Why does it try to go out Nic 2?  How do I configure it to go out Nic 1 for 192.168.20.0 and 192.168.101.0 and go out Nic 2 for everything else?

gfarnhamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cagriCommented:
Hi Gfarnham,

This is the routing table of windows XP deciding on which network to push packets throug. You can see your routing table via the command

route print
or
netstat -rn

on the command prompt.

Ok, as you may see from your output the list has 2 directly connected networks 192.168.24.0/24 and 192.168.1.0/24 and a DEFAULT route noted as 0.0.0.0

So you can reach two KNOWN networks and all packets for other directions are routed through the default network 0.0.0.0 which is directing your Internet network.

Windows unable to get information about other networks unless you use a "routing protocol" (like RIP, OSPF) or enter them manually. The first is not a simple task on XP environment (needs extra software) and second is the way you shold follow.

Back to command prompt, type the commands:

route add 192.168.101.0 mask 255.255.255.0 192.168.24.1
route add 192.168.20.0 mask 255.255.255.0 192.168.24.1

Do a route print do confirm your setup

So you simply instruct your network stack to forward packets for 192.168.101.0 and 192.168.20.0 VIA 192.168.24.1

Thats it.

You may add the two lines in a start up script to avoid doing it every time.

Hope this helps.


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stevenlewisCommented:
the only thing I might add to the good advoce above, is  you can use the -p switch to make the route persistent (to avoid the startup script or batch file)
0
stevenlewisCommented:
OK, I lied LOL some more info on multi homed machines



http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;Q262397

When two network adapters are present in a computer (multihomed), a default gateway should only be assigned

to one of the network adapter's TCP/IP properties. If one of the network adapters is used to connect

to the Internet, the default gateway should be assigned to that network adapter. In many cases, the

default gateway, as well as the other necessary TCP/IP information is assigned automatically by the

Internet Service Provider by using Dynamic Host Configuration Protocol (DHCP). This can be confirmed

by using the IP Configuration utility (Winipcfg.exe) to view the TCP/IP properties for the network adapter

you are using to connect to the Internet.

For the network adapter that is connected only to the Local Area Network (LAN), such as a home or corporate

network, a static routing entry must be entered into the computer's routing table if the computer needs

to obtain access to network resources across a router or multiple routers. For example, if the router

interface on the same subnet has an IP address of 192.168.1.1 and the router is connecting the 192.168.1.0

network to a 201.115.1.0 network, the following command would need to be entered either at a command

prompt within Windows or from a batch file:

ROUTE ADD 201.115.1.0 MASK 255.255.255.0 192.168.1.1

This command instructs Windows to send all traffic that is destined for the 201.115.1.0 network to the

192.168.1.1 interface on the router. To verify that the ROUTE ADD command was successful, use the ROUTE

PRINT command to view the current routing table. If multiple routers are being used on the LAN segment,

a separate ROUTE ADD is needed for each router.

Note that the routing entry is not persistent in Windows 98/95, even with the -p switch, and is lost

after you restart the computer. To have this entry automatically added for every Windows session, create

a batch file with the necessary ROUTE ADD command(s) and place it in the Windows StartUp folder to be

executed each time Windows starts.

If DHCP is used to assign IP addresses on the LAN, the DHCP server should be configured to not provide

a default gateway.


0
gfarnhamAuthor Commented:
Thank caqri, great answer.
stevenlewis, I used -p since I'm on XP probably is ok, your 2nd message says not supported in 98/95.
0
stevenlewisCommented:
It means the -p (persitent) switch is not supported in 9x, but the route add command is :-)
so you have to use a batch file on 9x and put it in the startup folder, and then it will run and add the routes on startup
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.