Can one set a link's cost to zero in OSPF?
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.
This could be desirable to force load-balancing in certain cases.
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:
- You are running Cisco IOS
- You only need load-balancing in a single OSPF area
- You are not trying to deal with NIC-level failovers on the hosts (which can still be managed with MPLS TE, but I'm not illustrating here for brevity)
- My configuration below has no errors (caveat emptor: I did not lab test my config below, and it's been close to a decade since I seriously needed MPLS TE); however, even if I have to fix an error in the config, the concept of solving your problem with equal-cost load-balancing through MPLS TE tunnels is correct.
Topology
Assume all IP addresses in the diagram are taken from 10.1.x.x...
1.1/30 1.2/30
g1/1 g1/1
A-------------C
g1/2| |g1/2
2.253/24| |3.253/24
| |
| |
2.252/24| |3.253/24
g1/2| |g1/2
B-------------D
g1/1 g1/1
1.5/30 1.6/30
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.
- Tunnels from head-end Router A
Tunnel0
: Path A -> C
Tunnel1
: Path A -> B -> D -> C
- Tunnels from head-end Router C
Tunnel0
: Path C -> A
Tunnel1
: Path C -> D -> B -> A
Loopbacks
- A:Lo0 10.0.0.1/32
- B:Lo0 10.0.0.2/32
- C:Lo0 10.0.0.3/32
- D:Lo0 10.0.0.4/32
Router A's configuration (you can derive all others from this example)
Reference links:
!
mpls traffic-eng tunnels
!
interface Loopback0
ip address 10.0.0.1 255.255.255.255
!
interface Tunnel0
ip unnumbered Loopback0
tunnel destination 10.0.0.3
tunnel mode mpls traffic-eng
tunnel mpls traffic-eng autoroute announce
tunnel mpls traffic-eng bandwidth 10000
tunnel mpls traffic-eng path-option 1 explicit name A_C
!!! NOTE: Keep the tunnel up if path-option 1 fails
tunnel mpls traffic-eng path-option 2 dynamic
!
interface Tunnel1
ip unnumbered Loopback0
tunnel destination 10.0.0.3
tunnel mode mpls traffic-eng
tunnel mpls traffic-eng autoroute announce
tunnel mpls traffic-eng bandwidth 10000
tunnel mpls traffic-eng path-option 1 explicit name A_B_D_C
!!! NOTE: Keep the tunnel up if path-option 1 fails
tunnel mpls traffic-eng path-option 2 dynamic
!
interface GigabitEthernet1/1
description [A -> C]
mtu 1524
mpls mtu 1524
ip mtu 1500
ip address 10.1.1.1 255.255.255.252
ip rsvp bandwidth 10000 10000
mpls traffic-eng tunnels
!
interface GigabitEthernet 1/2
description [A -> B]
mtu 1524
switchport
switchport mode access
switchport access vlan 10
!
interface Vlan10
mtu 1524
mpls mtu 1524
ip mtu 1500
ip address 10.1.2.253 255.255.255.0
standby 10 ip 10.1.2.254
standby 10 priority 105
standby 10 timers msec 200 750
ip rsvp bandwidth 1000000 1000000
mpls traffic-eng tunnels
!
router ospf 10
router-id 10.0.0.1
log-adjacency-changes
network 10.0.0.0 0.255.255.255 area 0
mpls traffic-eng router-id Loopback0
mpls traffic-eng area 0
!
ip explicit-path name A_C enable
next-address 10.1.1.2
!
ip explicit-path name A_B_D_C enable
next-address 10.1.2.252
next-address 10.1.1.6
next-address 10.1.3.253
!