The (Unofficial) CCNP-SP Study Guide
  • About
    • About the Author
    • About This Study Guide
  • MPLS
    • LDP
      • LDP Transport Address
      • LDP Conditional Advertisement
      • LDP Authentication
      • LDP/IGP Sync
      • LDP Session Protection
    • MPLS-TE
      • MPLS-TE Basics, Pt. 1 (TED)
      • MPLS-TE Basics, Pt.2 (RSVP)
      • MPLS-TE Basics, Pt.3 (CSPF)
      • MPLS-TE Basics, Pt.4 (Routing)
      • MPLS-TE Fast Reroute (FRR)
      • MPLS-TE with OSPF
    • Unified MPLS
    • Segment Routing
      • Introduction, Theory Pt.1
      • Introduction, Lab (OSPF) Pt.2
      • Introduction, Lab (ISIS) Pt. 3
      • Multi-Area/Level Segment Routing
      • Segment Routing using BGP
      • Migrating LDP to SR
      • LDP/SR Interworking
      • TI-LFA Pt. 1 (Theory)
      • TI-LFA Pt. 2 (Implementation)
      • TI-LFA Pt. 3 (Node and SRLG Protection)
      • SR-TE Pt. 1 (Overview)
      • SR-TE Pt. 2 (Creating an SR-TE Policy)
      • SR-TE Pt. 3 (Using a PCE)
      • SR-TE Pt. 4 (Automated Steering)
      • SR-TE Pt. 5 (On-Demand Nexthop)
      • SR-TE Pt. 6 (Flex Algo)
    • MPLS OAM
      • Classic Traceroute Behavior in MPLS Networks
      • LSP Ping
      • LSP Traceroute
  • Routing
    • BGP
      • BGP Synchronization
      • BGP Load Sharing (Multipath)
      • An Intuitive Look at Path Attributes
      • AS Path Prepending on XE and XR
      • RPL
    • BGP Security
      • BGP TTL Security, Pt. 1
      • BGP TTL Security, Pt. 2 (IOS-XE)
      • BGP TTL Security, Pt. 3 (IOS-XR)
      • BGP MD5 Authentication
      • BGP Maximum Prefixes
      • BGP RFD (Route Flap Dampening)
      • RTBH
      • Flowspec
      • BGPsec
    • L3VPN
      • An In-Depth Look at RD and RT, Pt. 1
      • An In-Depth Look at RD and RT, Pt. 2
      • An In-Depth Look at RD and RT, Pt. 3
      • An In-Depth Look at RD and RT, Pt. 4
      • Inter-AS L3VPN Pt. 1, Overview
      • Inter-AS L3VPN Pt. 2, Option A
      • Inter-AS L3VPN Pt. 3, Option B
      • Inter-AS L3VPN Pt. 4, Option C
      • CSC (Carrier Supporting Carrier)
      • PE NAT
    • OSPF
      • Type 7 to Type 5 Translation
      • OSPF Authentication
      • Troubleshooting OSPF Adjacencies
      • OSPFv3 LSA Types
      • OSPFv3 LSAs Example (Single Area)
    • ISIS
      • The Potential for Asymmetric Routing with Multi-Area ISIS
      • Interarea Routing is Distance-Vector
      • Basic ISIS - LSPDB
      • Multitopology
      • What is the role of CLNS and CLNP in ISIS?
      • Troubleshooting ISIS Adjacencies
    • IPv6 Transition
      • Overview
      • NAT64
      • 6to4
      • 6RD (IPv6 Rapid Deployment)
      • DS Lite (Dual Stack Lite)
      • MAP (Mapping of Address and Port)
      • Tunneling IPv6 Dynamic Routing Protocols over IPv4
    • Multicast
      • Introduction
      • IP and MAC Addressing
      • Tree Formation and Packet Forwarding
      • IGMP
      • PIM-DM (Dense Mode)
      • PIM-SM (Sparse Mode)
      • PIM-SM SPT Switchover
      • PIM-SM Tunnel Interfaces
      • PIM DR and the Assert Message
      • PIM-SM RP Discovery
      • PIM-BiDir
      • PIM-SSM (Source-Specific Multicast)
      • Interdomain Multicast (PIM-SM)
      • IPv6 Multicast
      • mVPN Introduction
      • mVPN Profile 0
      • mVPN Profile 1
      • Multicast Routing on IOS-XR
  • L2VPN & Ethernet
    • IOS-XE Ethernet Services
      • Service Instances
      • E-Line
      • E-LAN (VPLS)
      • E-Tree
      • E-Access
      • VPLS with BGP Autodiscovery
      • Martini/Kompella Circuits
    • EVPN
      • Introduction to EVPN
      • Learning EVPN VXLAN First
      • E-Line (EVPN VPWS)
      • E-Line (EVPN VPWS) on IOS-XR
      • E-Line (EVPN VPWS) Multi-Homed
      • E-LAN (EVPN Single-Homed)
    • Carrier Ethernet
      • 802.1ah (MAC-in-MAC)
      • 802.3ah (Ethernet OAM)
      • 802.1ag (CFM)
      • Cisco REP (Resilient Ethernet Protocol)
      • ITU G.8032 ERPS (Ethernet Ring Protection Switching)
  • Security
    • CoPP (Control Plane Policing)
    • LPTS (Local Packet Transport Services)
  • Misc
    • QoS
      • QoS Introduction (Part 1)
      • QoS Tools Overview and QoS Models (Part 2)
      • QoS Classification and Marking (Part 3)
      • QoS Queuing/Congestion Management (Part 4)
      • QoS Shaping and Policing (Part 5)
      • QoS for IPv6
      • MPLS QoS Basics
      • MPLS QoS Modes
      • MPLS TE QoS (DS-TE)
      • MPLS TE CBTS/PBTS
    • Automation and Assurance
      • NSO
      • NSO Command Cheat Sheet
      • Intro to YANG/NETCONF
      • YANG In-Depth
      • NETCONF In-Depth
      • RESTCONF
      • Model-Driven Telemetry
      • Automation Tool Comparison
      • Netflow
      • SNMP
    • Virtualization
      • NFV (Network Function Virtualization)
      • OpenStack
    • Transport
      • xPON
      • SONET/SDH
      • WDM
      • 4G and 5G RAN
    • High Availability (HA)
      • NSF/GR
      • NSR
      • NSF/NSR Whitepapers
      • BFD
      • Link Aggregation on IOS-XE
      • Link Aggregation on IOS-XR
    • IOS Software Overview
  • Labs
    • Lab Challenges
      • How to Use These Labs
      • Basic LDP
      • Advanced LDP
      • BGP Security
      • Unified MPLS
      • BGP Fundamentals
      • Ethernet Services
      • L3VPN Extranet
      • Multicast
      • Inter-area OSPF
      • ISIS
      • MPLS-TE
      • Control Plane Policing
      • QoS
Powered by GitBook
On this page
  • Type 0 (No Authentication)
  • Type 1 (Plain Text Authentication)
  • Type 2 (MD5/HMAC-SHA Authentication)
  • Type 2 Authentication with Key Chains
  • Further Reading
  1. Routing
  2. OSPF

OSPF Authentication

PreviousType 7 to Type 5 TranslationNextTroubleshooting OSPF Adjacencies

Last updated 1 year ago

There are several ways to enable authentication for OSPF, which can make the topic a little confusing.

OSPF authentication is carried in the OSPF header of every OSPF packet. There are three OSPF authentication types:

Type
Use

Type 0

No authentication

Type 1

Plain text authentication. The password is in clear text.

Type 2

MD5 or HMAC-SHA authentication. The password is hashed.

In all cases, the OSPF data itself is always in clear text. You cannot encrypt the OSPF data itself.

Type 0 (No Authentication)

This is of course the default authentication method. The authentication field is always present in the OSPF header, so when you don’t use authentication you will see “Auth Type: 0” on each OSPF packet:

The only situtation in which you need to explicitly configure null authentication, is when you have enabled type 1 or type 2 authentication for the OSPF area, and you want to set null authentication on an interface. As you would expect, interface-specific configuration “overrides” area-level configuration.

! Type 1 authentication enabled for area 0
router ospf 1
 area 0 authentication

! Revert Gi1 back to null authentication (type 0)
int Gi1
 ip ospf authentication null

If you do not set null authentication on the interface in the situation above, the interface will use type 1 authentication with no authentication key, and the OSPF adjacency will not come up.

Type 1 (Plain Text Authentication)

As the name implies, the authentication password is simply in clear text in the OSPF header. In the OSPF header, you will see “auth type 1” for plain text authentication. An attacker could easily learn the password and apply it themselves to form an adjacency with a router on your network. I can only see this as being useful in situations where you don’t want to accidentally form an adjacency with other directly connected routers.

To configure this you need to enable authentication under the interface, or under the OSPF process:

int Gi1
 ip ospf authentication

- or -

router ospf 1
 area 0 authentication

Then set the password on the interface:

int Gi1
 ip ospf authentication-key cisco123
  • The type 1 password can be a max of 8 characters

As you can see, the password is in clear text:

The authentication is present in the OSPF header, not just the Hello. So every OSPF message will be authenticated. (The other message types are: DBDs, LSUs, LSRs, and LACKs).

Also notice that the packet data itself is still clear text. This is true whether you use type 1 or type 2 authentication. The OSPF data itself is always clearly visible.

To verify in the CLI, you can use the following show command:

R1#show ip ospf int gi1 | in auth
  Simple password authentication enabled

If one side does not have authentication enabled, you will not form an adjacency on either side. The neighbor simply won’t be listed in show ip ospf neighbor. You can see the error using debug ip ospf adj.

R1#
*Nov 28 13:23:40.241: OSPF-1 ADJ   Gi1: Rcv pkt from 10.1.2.2,  : Mismatched Authentication Key - Clear Text

Type 2 (MD5/HMAC-SHA Authentication)

With MD5 authentication, the password is hashed using MD5, instead of being present in clear text. This makes it much more difficult for an attacker to form an adjacency with your router. OSPF considers MD5/HMAC-SHA authentication “Type 2.”

Enabling MD5 authentication is very similar to using a clear text password. First, enable the authentication method as MD5 for the interface or the area:

int Gi1
 ip ospf authentication message-digest

- or -

router ospf 1
 area 0 authentication message-digest

Then set the key on the interface:

int Gi1
 ip ospf message-digest key <1-255> md5 key


! Example:
 ip ospf message-digest key 1 md5 cisco123

The password is now MD5 hashed. The packet data is still in plain text.

You can verify whether authentication is enabled:

R1#show ip ospf int gi1 | sec authentication
  Cryptographic authentication enabled
    Youngest key id is 1

The debug command shows intuitive output when one side does not have authentication enabled:

*Nov 28 13:29:43.979: OSPF-1 ADJ   Gi1: Rcv pkt from 10.1.2.2 : Mismatched Authentication Key - Invalid cryptographic authentication Key ID 0 on interface
*Nov 28 13:29:43.995: OSPF-1 ADJ   Gi1: Send with youngest Key 1

Type 2 Authentication with Key Chains

To make things slightly confusing, you can achieve the same MD5 authentication configuration as above with just a key chain. A key chain allows you to rotate keys and give each key a different start time and lifetime. We will simply enable single-key key chains with infinite lifetimes to demonstrate this feature.

To enable type 2 MD5 authentication, we can simply reference a key chain which has a key-string and a crypto-algorithm of md5. You do not need to enable the authentication type when using a key chain.

int Gi1
 ip ospf authentication key-chain MY_KEY_CHAIN
!
key chain MY_KEY_CHAIN
 key 1
  key-string cisco123
  cryptographic-algorithm md5
    ! Available choices are: hmac-sha-1|hmac-sha-256|hmac-sha-384|hmac-sha-512|md5

A key chain is required when using HMAC-SHA for hashing (instead of MD5). RFC5709 updated type 2 authentication to be able to use either MD5 or HMAC-SHA.

The key chain in the example above is effectively no different from using the command ip ospf message-digest-key 1 md5 cisco123, because we are using MD5 for hashing.

By default, when no accept or send lifetime is specified, the key is “always valid”

R1#show key chain
Key-chain MY_KEY_CHAIN:
    key 1 -- text "cisco123"
        cryptographic-algorithm: md5
        accept lifetime (always valid) - (always valid) [valid now]
        send lifetime (always valid) - (always valid) [valid now]

You can see that the interface uses a key chain now, instead of an MD5 key configured on the interface, with the following show command:

R1#show ip ospf int gi1 | sec authentication
  Cryptographic authentication enabled
    Sending SA: Key 1, Algorithm MD5 - key chain MY_KEY_CHAIN

Further Reading

https://www.cisco.com/c/en/us/support/docs/ip/open-shortest-path-first-ospf/13697-25.html

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_ospf/configuration/xe-3s/iro-xe-3s-book/iro-ospfv2-crypto-authen-xe.html