All OSPF interfaces have a cost, which is a routing metric that is used in the link-state calculation. Routes with lower total path metrics are preferred over those with higher path metrics.
When several equal-cost routes to a destination exist, traffic is distributed equally among them.
The cost of a route is described by a single dimensionless metric that is determined using the following formula:
- cost = reference-bandwidth/bandwidth
reference-bandwidth is the reference bandwidth. Its default value is 100 Mbps (which you specify as 100,000,000), which gives a metric of 1 for any bandwidth that is 100 Mbps or greater.
To modify the metric for routes advertised from an interface, include the metric statement:
- (ospf | ospf3) {
-
- area area-id interface interface-name {
-
metric metric;
- }
- }
To modify the reference bandwidth, include the reference-bandwidth statement:
- (ospf | ospf3) {
-
reference-bandwidth reference-bandwidth;
- }
For a list of hierarchy levels at which you can configure these statements, see the statement summary sections for these statements.
For example, if you set the reference bandwidth to 1 Gbps (that is, reference-bandwidth is set to 1,000,000,000), a 100-Mbps interface has a default metric of 10.
By default, the loopback interface (lo0) metric is 0. No bandwidth is associated with the loopback interface.