How to change preferred path selection via OSPF?

ospf

#1

I have the following situation:

Router A and router B are advertising the subnet 192.168.0.0/24 on loopback interface. Router C selects router A by default as the preferred path.

I want to change the preferred path by changing the cost on the Router A interface eth0 and loopback. I assume Router C should choose Router B as the preferred path, but unfortunately it doesn’t.

Here are the configuration:

Router A:

interfaces {
    ethernet eth0 {
        address 172.16.1.254/16
        ip {
            ospf {
                cost 100
            }
        }
    }
    loopback lo {
        address 192.168.0.1/24
        ip {
            ospf {
                cost 100
            }
        }
    }
}
protocols {
    ospf {
        area 0.0.0.0 {
            network 172.16.0.0/16
        }
        parameters {
            router-id 172.16.1.254
        }
        redistribute {
            connected {
            }
        }
    }
}

Router B:

interfaces {
    ethernet eth0 {
        address 172.16.2.254/16
    }
    loopback lo {
        address 192.168.0.1/24
    }
}
protocols {
    ospf {
        area 0.0.0.0 {
            network 172.16.0.0/16
        }
        parameters {
            router-id 172.16.2.254
        }
        redistribute {
            connected {
            }
        }
    }
}

Router C:

interfaces {
    ethernet eth0 {
        address 172.16.0.254/16
    }
    loopback lo {
    }
}
protocols {
    ospf {
        area 0.0.0.0 {
            network 172.16.0.0/16
        }
        parameters {
            router-id 172.16.0.254
        }
    }
}

show ip route@Router C:

O>* 192.168.0.0/24 [110/20] via 172.16.1.254, eth0, 00:04:47
  *                         via 172.16.2.254, eth0, 00:04:47

Any help is welcome.


#2

Hmm the calculated cost from C’s perspective is the sum of costs of each egress interface to the destination prefix.

Modifying the cost eth0 should have no effect on C’s choice of path.

Can you show the output of ‘show ip ospf interface lo’ on router A and see what the cost is reporting as? That is the only interface that will effect the path.


#3

Hello cgb,

Thank you for your help.

Router A:

$ show ip ospf interface lo
lo is up
  ifindex 1, MTU 65536 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
  OSPF not enabled on this interface

#4

Hm, try including Lo in the area instead of redistributed the connected routes. Redistributed will cause the ospf process to ignore the cost on Lo as it’s imported from an external routing source.

Consider reading https://supportforums.cisco.com/discussion/11960566/ospf-redistribute-connected and https://supportforums.cisco.com/discussion/11652556/ospf-redistribute-connected-vs-network-statement.

HTH

Chris


#5

I’ve changed the configurations.

Router A:

interfaces {
    ethernet eth0 {
        address 172.16.1.254/16
        duplex auto
        smp_affinity auto
        speed auto
    }
    loopback lo {
        address 192.168.0.1/24
        ip {
            ospf {
                cost 100
                dead-interval 40
                hello-interval 10
                priority 1
                retransmit-interval 5
                transmit-delay 1
            }
        }
    }
}
protocols {
    ospf {
        area 0.0.0.0 {
            network 172.16.0.0/16
            network 192.168.0.0/24
        }
        parameters {
            abr-type cisco
            router-id 172.16.1.254
        }
    }
}

Router B:

interfaces {
    ethernet eth0 {
        address 172.16.2.254/16
        duplex auto
        smp_affinity auto
        speed auto
    }
    loopback lo {
        address 192.168.0.1/24
    }
}
protocols {
    ospf {
        area 0.0.0.0 {
            network 172.16.0.0/16
            network 192.168.0.0/24
        }
        parameters {
            abr-type cisco
            router-id 172.16.2.254
        }
    }
}

Router C:

interfaces {
    ethernet eth0 {
        address 172.16.0.254/16
        duplex auto
        smp_affinity auto
        speed auto
    }
    ethernet eth1 {
        address dhcp
        duplex auto
        hw-id 08:00:27:eb:dd:fb
        smp_affinity auto
        speed auto
    }
    loopback lo {
    }
}
protocols {
    ospf {
        area 0.0.0.0 {
            network 172.16.0.0/16
        }
        parameters {
            abr-type cisco
            router-id 172.16.0.254
        }
    }
}

And this is the result.

Router C:

$ show ip route ospf
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       I - ISIS, B - BGP, > - selected route, * - FIB route

O   172.16.0.0/16 [110/10] is directly connected, eth0, 00:04:10
O>* 192.168.0.1/32 [110/20] via 172.16.2.254, eth0, 00:04:10

The route of Router A is gone because of the cost in the loopback interface.


#6

I can’t tell whether you are happy that it has gone or whether you though that was unexpected?


#7

When I disable the interface eth0 of router B. I get the following:

Router C:

$ show ip route ospf
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       I - ISIS, B - BGP, > - selected route, * - FIB route

O   172.16.0.0/16 [110/10] is directly connected, eth0, 00:22:44
O>* 192.168.0.1/32 [110/110] via 172.16.1.254, eth0, 00:00:38

It works. Great! :slight_smile:

But is there a command to see all the backup routes, including the routes that has cost in the interface?
[/code]


#8

Excellent :slight_smile:

Yeah what you are observing is only the best, or equal, routes get installed in the rib.

The command you’re looking for is ‘show ip ospf database’, and specifically, ‘show ip ospf database router’. It’s less useful though because it’s a dump of the topology, and I’m not aware of a command that can ask it to only print out topology information for one prefix.


#9

Hello Chris,

Thank you very much for your help. :slight_smile:


#10

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.