Wednesday, November 01, 2006

Tip: Setting a gateway preference on a multihomed XP workstation

I seem to be getting this question frequently, so I thought I'd do a post as a tip on setting the preferred gateway on a multihomed Windows XP workstation.

How often are you in a situation where your workstation is connected to more than one LAN segment... maybe you have a lab - or something - that runs on 10.0.0.x, and a production network that runs on 192.168.1.x. The two networks aren't bridged, but it's handy to connect your workstation to both sometimes so you can bounce between the two and do work. The problem of course... the 10.0.0.x network doesn't have an internet connection that you want to use (for whatever reason). No problem, just set the default gateway that you want to use to the lowest metric (you really only have 1 default gateway... hence the default part, but you can set multiple gateways).

First check the routing table of your workstation from the command prompt...

"c:>route print"

You'll see your default gateway listed at the bottom, as well as a metric for your gateway further up under Network Destination. It probably has a metric of 20. The smaller the metric number the higher the priority. Great. So now we want to specify what our prefered gateway should be - you can do this by specifying a lower metric. You can either use the GUI or the command prompt to change this.

From the GUI, open up your network connections and select the connection that you want to use for outbound traffic. Go into the advanced settings, and specify the gateway address and turn off auto-asignment of the metric. Give it a low metric - say 2. Then save your settings and exit. Wait a few seconds, and do another route print... you should see that the prefered gateway has a lower metric. Next do a "tracert ExternalDestionationIP" and make sure the first hop is what you want it to be.

Or from the addressing example above, you could use the command prompt... something like...

"route change mask metric 2 if 2".

Just make sure you understand what the route command will do ("route ?") before using the command I specified.

That's all... I told you it was just a tip.

No comments: