Can one set a link's cost to zero in OSPF?
This could be desirable to force load-balancing in certain cases.
For example, suppose there are four routers A, B, C, and D, and two hosts X and Y, with the following connections:
/----A-----10Mbps-----C----\
/ | | \
X-1Gbps 1Gbps 1Gbps 1Gbps--Y
\ | | /
\----B-----10Mbps-----D----/
X and Y are workstations, so they are only configured with static routing. Say A is X's default gateway and C is Y's default gateway. Between the four routers, OSPF is used.
Now X initiates two flows to Y, each of which needs 9Mbps. With OSPF, we get the A-C link selected as the best path and the B-C link goes unused. I would like to administratively set the A-B and C-D links as zero cost so that OSPF will load-balance across the two lower-speed 10Mbps links.
Best Answer
Yes and no... you can't manually set a link's cost to 0, but if you have a Designated Router election on the network, the cost from the DR to any attached router on the same Broadcast / NBMA network is considered 0.
As such, be sure that the A-B and C-D links are OSPF broadcast networks; this forces a DR election and will make the cost of A-B and C-D zero. The DR is sometimes referred to as a pseudonode in OSPF.
Once you make the A-B and C-D links zero cost in OSPF (by virtue of a DR election), A-C and B-D links should be set to the same cost if you want equal-cost load-balancing.
If you want a generalized solution to this problem (without dependencies the topology or type of OSPF network involved), you are making one of the classic cases for MPLS TE; OSPF supports MPLS TE (see RFC 3630).
Let's assume:
Topology
Assume all IP addresses in the diagram are taken from 10.1.x.x...
MPLS TE Tunnels
Build the following tunnels so we can use ECMP to meet your requirements. Each tunnel interface will have the same OSPF cost.
Tunnel0
: Path A -> CTunnel1
: Path A -> B -> D -> CTunnel0
: Path C -> ATunnel1
: Path C -> D -> B -> ALoopbacks
Router A's configuration (you can derive all others from this example)
Reference links: