OSPF MASTERCLASS · CHAPTER 8

Authentication, ECMP and OSPF over Metro Ethernet

Protect your neighbors, decide which way traffic flows and stretch an area to another city across a provider. The masterclass finale.

15 min readVideos: Day 2, parts 6, 7 and 8Level: intermediate

From point A to point B

Point A: your OSPF network converges, but anyone who plugs a router into the segment can talk to your neighbors, traffic goes wherever OSPF decides, and your area ends at the edge of your building. Point B: by the end of this chapter you will authenticate your neighbors with the right method, control the path with cost and stretch an area across a provider's Metro Ethernet network.

What you will see
  1. The three authentication types, seen in Wireshark
  2. The key chain with HMAC-SHA-512 and the mistake that confuses most people
  3. ECMP and maximum-paths with two links between R7 and R12
  4. Cost, reference-bandwidth and how to force a path
  5. OSPF over QinQ: E-Line, E-LAN and the close of the class

Three authentication types

Day 2 enters its final stretch with one item still open: the default route in the NSSA that never showed up (you saw it in chapter 7). Jesús leaves it for later.

He picks the R8–R7 link in area 32, 20.20.20.0/24, because it converges fast. With debug ip ospf hello and Wireshark open, the first thing shows up: the authentication type travels in the OSPF header. Without any configuration, Wireshark already shows Null authentication, type 0.

Where OSPF authentication travels Every OSPF packet, Hello included, carries an authentication type and a 64-bit authentication field in its header. Type 0, null, is the default: the field is not checked. Type 1, simple password, puts the password itself in the field, so anyone with a sniffer can read it; Wireshark shows it as simple password. Type 2, cryptographic, puts a key ID and a sequence number in the header and appends a message digest at the end of the packet; the secret key never travels. Keyed MD5 and the newer HMAC-SHA algorithms configured with a key chain both use type 2. OSPF HEADER · AUTH FIELDS BODY TRAILER TYPE 0 · NULL default on every router AuType 0 not checked OSPF data Wireshark: Null authentication TYPE 1 · PLAIN TEXT ip ospf authentication-key AuType 1 the password itself, in clear OSPF data Wireshark: Simple password · readable by any sniffer TYPE 2 · CRYPTO MD5 or key chain + HMAC-SHA AuType 2 Key ID · crypto sequence number OSPF data digest Wireshark: Cryptographic · the key never travels, only the digest Both ends of a link need the same type, the same key ID and the same key. A mismatch drops the adjacency, and every virtual link that depends on it.

The three authentication types in the OSPF header and what Wireshark shows for each. Diagram: The House of Routing.

RFC 2328 defines three types, and every OSPF packet carries them, not just the Hello: 0, null, the default; 1, simple password; and 2, cryptographic, historically MD5 and today also HMAC-SHA with a key chain (RFC 5709).

On the area or on the interface

Inside the OSPF process, area 32 authentication turns on plain text on every R8 interface in that area, and area 32 authentication message-digest turns on MD5.

! Area-wide: every R8 interface in area 32 uses the same type
R8(config)# router ospf 1
R8(config-router)# area 32 authentication
! type 1, simple password
R8(config-router)# area 32 authentication message-digest
! type 2, MD5 (the key is still set on the interface)
R8(config-router)# do show ip ospf neighbor
! R7 is gone, and so is the virtual link that crosses area 32
R8(config-router)# no area 32 authentication

As soon as R8 changes type, R7 is no longer its neighbor, and the virtual link that crosses area 32 goes down with it. Two more rules: the key is always set on the interface and, according to Cisco, the interface command overrides the area command.

Plain text: the key in plain sight

Jesús moves to the interfaces: Gi0/0 on R8 and Gi0/1 on R7. With only one side configured, the dead timer reaches zero and the neighbor drops; with both sides, it goes back to FULL.

R8(config)# interface GigabitEthernet0/0
R8(config-if)# ip ospf authentication
R8(config-if)# ip ospf authentication-key THOR123

R7(config)# interface GigabitEthernet0/1
R7(config-if)# ip ospf authentication
R7(config-if)# ip ospf authentication-key THOR123
R7(config-if)# do show ip ospf neighbor

In Wireshark, R8's Hello says Simple password and the whole key is readable. RFC 2328 puts it plainly: it keeps a router from joining the domain by mistake, but it does not withstand a passive attack.

MD5: the key no longer travels

With MD5, the key ID and the key must match on both ends:

R8(config)# interface GigabitEthernet0/0
R8(config-if)# no ip ospf authentication-key
R8(config-if)# ip ospf authentication message-digest
R8(config-if)# ip ospf message-digest-key 1 md5 THOR123

R7(config)# interface GigabitEthernet0/1
R7(config-if)# no ip ospf authentication-key
R7(config-if)# ip ospf authentication message-digest
R7(config-if)# ip ospf message-digest-key 1 md5 THOR123

Wireshark no longer talks about MD5 but about Cryptographic authentication, type 2, with its key ID. What travels is not the encrypted key: per RFC 2328, the router computes a message digest from the packet and the secret key and appends it to the end. The key never leaves the router.

Why did people avoid encryption back then? Twenty years ago, the 1700 routers Jesús started with had 4 MB of RAM. Encryption took computing power away from routing. Today you can authenticate on every device.

Key chain and HMAC-SHA

The newest mechanism lives in a key chain, like the one you would use for EIGRP. Inside it goes the key with its number, its key-string and the algorithm. Jesús picks hmac-sha-512.

! The same on R7 (interface GigabitEthernet0/1)
R8(config)# key chain THOR
R8(config-keychain)# key 1
R8(config-keychain-key)# key-string THOR123
R8(config-keychain-key)# cryptographic-algorithm hmac-sha-512
R8(config-keychain-key)# exit
R8(config-keychain)# exit
R8(config)# interface GigabitEthernet0/0
R8(config-if)# ip ospf authentication key-chain THOR
! the key chain NAME goes here, not the key number
R8(config-if)# do show ip ospf neighbor

While R7 is still on null, R8 flags the key as invalid and the neighbor expires. Wireshark shows type 2 packets with "crypto data missing" and malformed packets: one side signs and the other does not.

Then comes a live mistake that teaches more than the theory. Jesús types ip ospf authentication key-chain 1, with the key number, and the neighbor does not come up. The interface expects the key chain name. With key-chain THOR on both routers, the neighbor is back.

  • The key chain name is local. Each router can call it whatever it wants.
  • The key is compared. The key ID travels in the packet; the key-string and the algorithm must be the same.

Per RFC 5709, HMAC-SHA uses the same type 2 as MD5: the key ID tells the receiver which key and which algorithm to apply.

ECMP: two paths, the same cost

For load balancing, Jesús connects R7 and R12 with two GigabitEthernet links in area 32: 192.168.1.0/24 on the Gi0/2 interfaces and 192.168.2.0/24 on the Gi0/3 interfaces.

R7(config)# interface GigabitEthernet0/2
R7(config-if)# ip address 192.168.1.7 255.255.255.0
R7(config-if)# ip ospf 1 area 32
R7(config-if)# no shutdown
R7(config-if)# interface GigabitEthernet0/3
R7(config-if)# ip address 192.168.2.7 255.255.255.0
R7(config-if)# ip ospf 1 area 32
R7(config-if)# no shutdown

R12(config)# interface GigabitEthernet0/2
R12(config-if)# ip address 192.168.1.12 255.255.255.0
R12(config-if)# ip ospf 1 area 32
R12(config-if)# no shutdown
R12(config-if)# interface GigabitEthernet0/3
R12(config-if)# ip address 192.168.2.12 255.255.255.0
R12(config-if)# ip ospf 1 area 32
R12(config-if)# no shutdown
R12(config-if)# do show ip protocols
! Maximum path: 4
R12(config-if)# do show ip route ospf
! each remote prefix: [110/3] via 192.168.1.7 and via 192.168.2.7

Once the second neighbor is up, show ip route changes: each prefix shows up via 192.168.1.7 and via 192.168.2.7, with distance 110 and the same cost. That is ECMP, equal-cost multipath, and OSPF does it on its own. show ip protocols shows the limit: maximum-paths is 4 by default in IOS. A traceroute 8.8.8.8 confirms it: the probes leave through both next hops.

What if you don't want load balancing? Voice over IP needs a symmetric path, not packets split across links. With maximum-paths 1 the alternate routes disappear:

R12(config)# router ospf 1
R12(config-router)# maximum-paths 1
! one next hop per prefix: no more ECMP
R12(config-router)# maximum-paths 4
! back to the default

How OSPF calculates cost

Why does every link cost 1? Cost = reference bandwidth / interface bandwidth, and the default reference is 100 Mbps. Today, 100 Mbps divided by 1, 10 or 100 Gbps gives less than 1, and OSPF uses 1: your 100-Gbps link is worth the same as a 1-Gbps one. If you sell a premium path and don't change the reference, OSPF may share the traffic with a slow path.

The fix is auto-cost reference-bandwidth, in Mbps. With a 100-Gbps reference, a 1-Gbps interface costs 100 and a 100-Gbps one costs 1: a destination two hops away costs 201 over 1-Gbps links and 3 over 100-Gbps links.

! Example: 100 Gbps as the reference, on EVERY router of the domain
R12(config)# router ospf 1
R12(config-router)# auto-cost reference-bandwidth 100000
! value in Mbps: a 1-Gbps interface now costs 100, a 100-Gbps one costs 1
R12(config-router)# do show ip ospf interface GigabitEthernet0/3
! check the Cost field

In the lab, Jesús raises the reference on R12 and the cost of Gi0/3 is no longer 1. IOS warns you: the reference must be the same on every router, or each one will calculate on a different scale.

The question left open. During the live session, someone asked which command shows the reference bandwidth. In IOS, show ip ospf shows it in the line "Reference bandwidth unit is 100 mbps"; show ip ospf interface shows the cost of each interface.

Cost adds up on outgoing interfaces

This is the key idea: the cost of a route is the sum of the outgoing interfaces, seen from the router that wants to reach the destination. You don't add both ends of each link.

Equal-cost paths and the cost to 8.8.8.8 R12 connects to R7 over two GigabitEthernet links in area 32: Gi0/2 on 192.168.1.0/24 and Gi0/3 on 192.168.2.0/24. R7 connects to R8 over Gi0/1 on 20.20.20.0/24, and R8 owns the loopback 8.8.8.8. OSPF adds the cost of each outgoing interface from R12 to the destination. With every cost at 1, R12 reaches 8.8.8.8 with metric 3 through both links: equal-cost multipath, up to maximum-paths, 4 by default. With the loopback cost at 50 the metric becomes 52, and with R7 Gi0/1 cost at 10 it becomes 61. Raising the cost of R12 Gi0/3 to 10 leaves a single path through Gi0/2. R12 Gi0/2 · Gi0/3 cost 1 each R7 Gi0/1 to R8 cost 1 → 10 R8 Lo0 8.8.8.8 cost 1 → 50 Gi0/2 · 192.168.1.0/24 Gi0/3 · 192.168.2.0/24 Gi0/1 · 20.20.20.0/24 AREA 32 · COST = SUM OF OUTGOING INTERFACES SEEN FROM R12 ALL COSTS 1 1 (R12) + 1 (R7) + 1 (Lo0) = 3 two next hops: .1.7 and .2.7 ECMP · maximum-paths 4 LO0 50 · R7 GI0/1 10 1 + 1 + 50 = 52 1 + 10 + 50 = 61 still two equal paths R12 GI0/3 COST 10 via Gi0/2: 1 + 10 + 50 = 61 via Gi0/3: 10 + 10 + 50 = 70 one path: 192.168.1.7 Cost = reference bandwidth / interface bandwidth. Default reference: 100 Mbps, so 1, 10 and 100 Gbps links all cost 1. Raise auto-cost reference-bandwidth on every router.

From R12, the cost to 8.8.8.8 adds the outgoing interfaces of R12, R7 and R8's loopback. Diagram: The House of Routing.

From R12, R8's loopback 8.8.8.8 costs 3: 1 for R12's outgoing interface, 1 for R7's Gi0/1 and 1 for the loopback. Jesús checks it in three steps:

R8(config)# interface loopback 0
R8(config-if)# ip ospf cost 50
R12# show ip route 8.8.8.8
! metric 52 = 1 (R12) + 1 (R7 Gi0/1) + 50 (R8 Lo0)

R7(config)# interface GigabitEthernet0/1
R7(config-if)# ip ospf cost 10
R12# show ip route 8.8.8.8
! metric 61 = 1 + 10 + 50, still through both links

R12(config)# interface GigabitEthernet0/3
R12(config-if)# ip ospf cost 10
R12(config-if)# do show ip route 8.8.8.8
! one path left: via 192.168.1.7 (Gi0/2)
R12(config-if)# do traceroute 8.8.8.8
  1. R8's loopback to 50. The metric goes from 3 to 52.
  2. R7's Gi0/1 to 10. It rises to 61, still over both links.
  3. R12's Gi0/3 to 10. Say Gi0/2 is 10 Gbps and Gi0/3 is 1 Gbps: you penalize the slow one. Through Gi0/3 it would cost 70, so everything leaves through 192.168.1.7, and not only 8.8.8.8: SPF recalculates every prefix.

OSPF over Metro Ethernet

The last exercise takes area 32 across a provider. A site in Panama City and another in a different country see each other as if a cable joined them. Metro Ethernet now fills the place of Frame Relay virtual circuits, with three service models: E-Line (point-to-point), E-LAN (multipoint, widely used) and E-Tree (hub-and-spoke, almost out of use according to Jesús).

Among several techniques (VPLS, L2VPN, L3VPN, GRE), the class uses QinQ. Why isn't one VLAN enough? Because the provider already uses its own VLANs and would mix its customers' traffic. QinQ wraps the customer VLAN inside a provider VLAN, the metro tag.

OSPF over Metro Ethernet with QinQ R12 and R13 are customer routers in area 32. Each one uses subinterface Gi0/0.500 with encapsulation dot1Q 500 and addresses 90.90.90.12 and 90.90.90.13. They connect to the provider switches MLS-01 and MLS-02 on Gi0/0, the UNI, configured as switchport access vlan 2222 and switchport mode dot1q-tunnel, with no cdp enable and l2protocol-tunnel cdp. The provider switches join over an 802.1Q trunk on Gi0/1. The customer frame tagged with VLAN 500 enters the provider network and gets an outer metro tag, VLAN 2222; the far edge removes it and delivers the frame still tagged 500. R12 and R13 see each other as directly connected OSPF neighbors and CDP neighbors. With ip ospf network point-to-point the E-Line has no DR or BDR. For an E-LAN, a third UNI on MLS-02 Gi0/2 in the same metro tag adds R14, and the subinterfaces go back to broadcast. SERVICE PROVIDER · METRO ETHERNET · QINQ R12 Gi0/0.500 90.90.90.12/24 MLS-01 UNI Gi0/0 tunnel · VLAN 2222 MLS-02 UNI Gi0/0 tunnel · VLAN 2222 R13 Gi0/0.500 90.90.90.13/24 Gi0/1 trunk 802.1Q CUSTOMER SIDE C-tag 500 IP · OSPF INSIDE THE PROVIDER S-tag 2222 C-tag 500 IP · OSPF CUSTOMER SIDE C-tag 500 IP · OSPF E-LINE · POINT-TO-POINT ip ospf network point-to-point on both ends no DR, no BDR · LOADING to FULL CDP: R13 sees R12, not the provider switch E-LAN · MULTIPOINT one more UNI: MLS-02 Gi0/2 in VLAN 2222 R14 joins 90.90.90.0/24 network type broadcast: DR/BDR election

The customer frame, tagged with VLAN 500, crosses the provider inside metro tag 2222. Diagram: The House of Routing.

The customer side

R12 and R13 use a Gi0/0.500 subinterface with VLAN 500, in area 32 and on network 90.90.90.0/24:

R12(config)# interface GigabitEthernet0/0.500
R12(config-subif)# encapsulation dot1Q 500
R12(config-subif)# ip address 90.90.90.12 255.255.255.0
R12(config-subif)# ip ospf 1 area 32

R13(config)# interface GigabitEthernet0/0
R13(config-if)# no shutdown
R13(config-if)# interface GigabitEthernet0/0.500
R13(config-subif)# encapsulation dot1Q 500
R13(config-subif)# ip address 90.90.90.13 255.255.255.0
R13(config-subif)# ip ospf 1 area 32
R13(config-subif)# do debug ip ospf adj

The provider side

MLS-01 and MLS-02 are the provider network. First, the metro tag, VLAN 2222. Live, the switch would not create it because it was not the VTP primary server; vtp mode server and vtp version 2 solved it. Then, a regular 802.1Q trunk between the switches.

The key piece is the UNI, the User-Network Interface that faces the customer. With switchport mode dot1q-tunnel, everything that enters that port is wrapped in VLAN 2222.

! Provider side: the same on MLS-02
MLS-01(config)# vlan 2222
MLS-01(config-vlan)# exit
MLS-01(config)# interface GigabitEthernet0/1
MLS-01(config-if)# switchport trunk encapsulation dot1q
MLS-01(config-if)# switchport mode trunk
MLS-01(config-if)# interface GigabitEthernet0/0
! the UNI towards the customer
MLS-01(config-if)# switchport access vlan 2222
MLS-01(config-if)# switchport mode dot1q-tunnel
MLS-01(config-if)# no cdp enable
MLS-01(config-if)# l2protocol-tunnel cdp
MLS-01(config-if)# do show dot1q-tunnel
MLS-01(config-if)# do show interfaces trunk

no cdp enable keeps the switch from becoming the customer's CDP neighbor, and l2protocol-tunnel cdp lets the customer's CDP through the tunnel. With L2PT you can also carry STP or run EtherChannel over Metro Ethernet.

Once MLS-02's UNI is ready, R13's debug shows LOADING to FULL. R13 gets every company route, E2 included, and pings 150.150.150.150, in the EIGRP domain. show cdp neighbors on R13 shows R12, not the switch it is plugged into.

Watch the MTU in production. Each 802.1Q tag adds 4 bytes, and Cisco notes that the provider network needs a larger MTU for the double tag. Remember chapter 4: a different MTU can leave the adjacency stuck in ExStart.

From E-Line to E-LAN

On Ethernet, the subinterface is broadcast, so R12 and R13 elect a DR and a BDR. On an E-Line, with two routers, that is unnecessary: ip ospf network point-to-point on both ends removes it.

R13(config)# interface GigabitEthernet0/0.500
R13(config-subif)# ip ospf network point-to-point
R12(config)# interface GigabitEthernet0/0.500
R12(config-subif)# ip ospf network point-to-point
R12(config-subif)# do show ip ospf neighbor
! FULL/  -  : no DR, no BDR
R13# show cdp neighbors
! R13 sees R12, not the provider switch
R13# ping 150.150.150.150

Want an E-LAN? Put the subinterfaces back to broadcast, add another UNI on MLS-02, Gi0/2 towards R14, with the same metro tag 2222 and l2protocol-tunnel cdp, and turn on OSPF on R14 in 90.90.90.0/24. The two switches behave like a single one, and the DR and BDR election comes back.

Closing the masterclass

After about five hours live, Jesús recaps Day 2: DR and BDR, stub areas and NSSA, the E-bit and P-bit, redistribution, authentication, ECMP and Metro Ethernet. OSPF over MPLS L3VPN and prefix suppression are promised for other videos.

Look at the whole path: you started with five packet types and a point-to-point link. Today you authenticate neighbors, decide which way traffic flows and take an area to another city.

Your next step

  • Build the lab in GNS3 with IOSv routers and switches and repeat the three exercises with Wireshark open.
  • Keep the 100 OSPF commands guide at hand.
  • Move on to the MPLS Masterclass, the natural step after Metro Ethernet.
  • When you want to take your routes to the Internet, the BGP Masterclass is waiting for you.

You are no longer at point A. Choose your next point B and go for it.

Class videos

These are the three Day 2 videos this chapter is based on, the last ones of the masterclass. They were recorded live on February 13, 2021, with Cisco IOSv routers in GNS3, debug and Wireshark. The audio is in Spanish, with subtitles in Spanish, English, French and Portuguese.

Recorded live; Spanish audio with Spanish, English, French and Portuguese subtitles. When you play it, the video loads from YouTube. Day 2 playlist on YouTube

Test what you learned

1. You configure area 32 authentication on R8 and R7 has nothing. What happens?

Answer. R8 moves to plain text, type 1, and R7 stays on null, type 0. The neighbor drops, and so does the virtual link that depends on that adjacency.

2. With MD5, does the encrypted key travel in the packet?

Answer. No. The key ID, a sequence number and a message digest computed from the packet and the key travel. The key never leaves the router.

3. You create key chain THOR with key 1 and type ip ospf authentication key-chain 1 on the interface. Why doesn't the neighbor come up?

Answer. The interface expects the key chain name: ip ospf authentication key-chain THOR. The name is local; the key ID, the key-string and the algorithm must match the neighbor's.

4. From R12, R8's loopback costs 50 and R7's Gi0/1 costs 10. What is the metric to 8.8.8.8?

Answer. 61: 1 for R12's outgoing interface, 10 for R7's outgoing interface and 50 for the loopback. The outgoing interfaces are added from R12's point of view.

5. On a QinQ E-Line, what goes on the UNI and what do you change on the routers to remove the DR?

Answer. On the UNI: switchport access vlan 2222, switchport mode dot1q-tunnel, no cdp enable and l2protocol-tunnel cdp. On the subinterfaces: ip ospf network point-to-point.

Key takeaways

  • Three authentication types: null (0, the default), plain text (1) and cryptographic (2). Both ends must match.
  • Any sniffer reads plain text. With MD5 or HMAC-SHA, only a digest travels.
  • In a key chain, the name is local; the key ID, key-string and algorithm must match. The interface takes the name.
  • OSPF does ECMP on its own, up to maximum-paths (4 by default in IOS). If you need symmetry, tune costs or go down to 1.
  • Cost = reference / bandwidth. Raise auto-cost reference-bandwidth, the same on every router.
  • Cost adds up outgoing interfaces. To force a path, penalize the interface you don't want to use.
  • QinQ carries the customer VLAN inside a metro tag: point-to-point for an E-Line, broadcast and more UNIs for an E-LAN.

Official resources

Source and credits. Chapter written from the OSPF Masterclass that Jesús Espinoza recorded live in 2021. Text drafted with AI assistance and reviewed; original diagrams by The House of Routing. Technical details and configuration were checked against official Cisco documentation and IETF RFCs.

Navigate