Static Route


R

Robbie

How can I set a static route on my local PC that sends
traffic out of one gateway if the destination IP address
is 10.0.0.0 and out of a second gateway if the
destination IP is on any other subnet? Thanks for the
help.

Robbie
 
Ad

Advertisements

H

Herb Martin

How can I set a static route on my local PC that sends
traffic out of one gateway if the destination IP address
is 10.0.0.0 and out of a second gateway if the
destination IP is on any other subnet? Thanks for the
help.
Jerome gave you "the answer" -- here's a bit more.

Creating a static route to 10.0.0.0 will send traffic using
that route if NO BETTER route can be found. (We'll
discuss "no better" down below.)

The Default Gateway settings on a machine get translated
into a static route in fact -- it's usually called "default" or
"minimal" routing but these are intimately related to "static"
routes (and all these differ and are distinct from "dynamic"
routing.)

If you view a routing table you will (almost) always see the
default gateay entry -- only it's not labeled. You can pick it
out by noting: Destination 0.0.0.0 mask 0.0.0.0 (anywhere,
don't care) and an interface and gateway to use. In fact,
this "gateway" to use is the THING we call the "default
gateway.

Ok, so you add a persistent route:
route add /p 10.0.0.0 mask 255.0.0.0 different_gateway_IP_number

You machine now has two "competing" routes -- one default through
the original "Default Gateway" and a new one to net 10 through the
"different_gateway_IP_number".

How does it decide which to use?

General rule: MOST SPECIFIC is preffered over more general.

A mask of 255.0.0.0 indicates a match of the first 8 bits (only) but
the default gateway mask is always 0.0.0.0 or a match of "no bits"

Well, an 8-bit match is MORE SPECIFIC than a no-bit match, right?

[Re-read the above -- it is a major key to managing static routes.]

Suppose you need ANOTHER, stil-different route to a branch office
that usess 10.224.0.0? (all the 10.224)

Just add another static route:
route add /p 10.224.0.0 mask 255.255.0.0 branch_gateway_IP_number

Ok, that's a 255.255.0.0 or 16 bit match which is better than 8 or, of
course,
0 (no bits.)

So, 10.224 traffic goes through one router, other 10-net traffic through
another, and everything else through the "default gateway".

Note: Default Gateways can perhaps be better understood if you
realize the are the "router of last resort."

But wait.... What if you don't want just traffic for 10.224.0.0 to go to
that branch gateway but only the traffic between 10.224.0.0 and
10.239.255.255? (It's not an just an office, it's the whole European
subsidiary.)

Well notice that 239 is almost 240 and that is an increment from 224
of 16 -- this shouldn't be an accident, we would DESIGN our nets this
way so that the following trick will work.

Ok, so 16 is 2^4 or the idea of masking 4-bits.

Delete that last route we added (mask 255.255.0.0) and replace it with:

route add /p 10.224.0.0 mask 255.240.0.0 branch_gateway_IP_number

Why 240? because that represenst 4-bits. Repeat: BECAUSE a mask
of 240 extends the mask 4-BITS.

So if 255 adds 8 bits to a mask, and 240 adds 4-bits. 4-bits (or 8+4=12
total) is less specific than 8 (8+8=16) so MORE destinations are matched
and that gateway will be preferred for this larger set.

What if two matche and their mask are the same size? You can add a
metric (measure) -- lowest metric breaks the tie.

route add /p 10.224.0.0 mask 255.255.0.0 branch_gateway1_IP_number 5
route add /p 10.224.0.0 mask 255.255.0.0 branch_gateway2_IP_number 4

What if the metrics match? There is an algorythm for checking first
gateway, first NIC -- finally the ORDER matters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Static Routes 1
Static route 1
Static routes 3
Static routing 2
Static Route 4
Static Route Question 0
RRAS Static Route 2
RRAS static route 4

Top