how to route n.n.n.n -> default DHCP route or n.n.n.n -> e.e.e.e when no default set (AD=253/254)

Answered Question
Dec 21st, 2009
User Badges:

I would like to reach n.n.n.n over the internet with the default route in place
or with a static route when the default route is not set:


ip dhcp-client default-router distance 253


interface FastEthernet 0/0 ... internet gateway
ip address dhcp


... makes a default route like: ip route 0.0.0.0 0.0.0.0 FastEthernet 0/0 253


... now if I place:


ip route n.n.n.n 255.255.255.255 FastEthernet 0/1 e.e.e.e 254


... I suppose n.n.n.n will be reached with the default route (AD=253) if set or via the second interface (Fa0/1) if no default route is present right ?


... well; it's not working, it attempts to reach n.n.n.n via the second interface no matter whether a default route is set or not


show ip route is clearly showing both routes with proper ADs


what am I doing wrong ?


PS: what came first to mind was to use ip sla tracking for the default route to install the alternate but on second thought this seemed a simple and better solution

Correct Answer by ohassairi about 7 years 7 months ago

the router uses the best route (not in sens of metric but in sens of the nearest) to route your traffic.

in your case the best route is n.n.n.n 255.255.255.255 even if it has a bad metric.

the router only use 0.0.0.0 route if no better route exists


for example:


if you have this in your ip route table


ip route 10.0.0.0 255.0.0.0  int s0

ip route 10.1.0.0 255.255.0.0  int s1    50

ip route 10.1.1.0 255.255.255.0  int s2    100


if your router will route one packet with IP destination 10.1.1.5 it will use the third route (via s2) because it is the nearest and the most close to the IP address


now if you have


ip route 10.0.0.0 255.0.0.0  int s0

ip route 10.1.0.0 255.255.0.0  int s1    50

ip route 10.1.1.0 255.255.255.0  int s2    100

ip route 10.1.1.0 255.255.255.0  int s3    150


if s2 fails then it will use s3

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
ohassairi Mon, 12/21/2009 - 20:50
User Badges:
  • Silver, 250 points or more

the router uses the best route (not in sens of metric but in sens of the nearest) to route your traffic.

in your case the best route is n.n.n.n 255.255.255.255 even if it has a bad metric.

the router only use 0.0.0.0 route if no better route exists


for example:


if you have this in your ip route table


ip route 10.0.0.0 255.0.0.0  int s0

ip route 10.1.0.0 255.255.0.0  int s1    50

ip route 10.1.1.0 255.255.255.0  int s2    100


if your router will route one packet with IP destination 10.1.1.5 it will use the third route (via s2) because it is the nearest and the most close to the IP address


now if you have


ip route 10.0.0.0 255.0.0.0  int s0

ip route 10.1.0.0 255.255.0.0  int s1    50

ip route 10.1.1.0 255.255.255.0  int s2    100

ip route 10.1.1.0 255.255.255.0  int s3    150


if s2 fails then it will use s3

Actions

This Discussion

Related Content