Introduction
By default, an OSPF neighbor is displayed by its router ID or Neighbor ID in an OSPF show EXEC commands. However the behavior can be re-structured or customized by displaying the hostname.
To configure OSPF to look up Domain Name System (DNS) names for use in all OSPF show EXEC command displays, ip ospf name-lookup command in the global configuration mode.
This command makes it easier to identify a router because the router is displayed by name rather than by its router ID or neighbor ID.
Background
In this topology, the three routers are configured with OSPF on a frame-relay network. The DLCI assignment and ip addressing scheme is given below.
To achieve the name look-up task, all three routers are configured with the command “ip ospf name-lookup”.
DLCI Assignment
Router - To - RouterDLCI Number
HUB --> Spoke-1 | 203 |
HUB --> Spoke-2 | 204 |
Spoke-1 --> HUB | 302 |
Spoke-2 --> HUB | 402 |
IP Addressing Scheme
Router / InterfaceIP Address
HUB Se 0/0 | 10.10.10.2 /24 |
Spoke-1 Se 0/0 | 10.10.10.3 /24 |
Spoke-2 Se 0/0 | 10.10.10.4 /24 |
Note: All configurations are tested on Cisco 3745 Router running IOS 12.4 software.
Topology Diagram

Configuration
Summary Steps
Step 1. Router (config) # ip host Name-Of-Host A.B.C.D
Step 2. Router (config) # ip ospf name-lookup
Router Configuration
HUBSpoke-1Spoke-2
hostname HUB ip cef ip host Spoke-1 3.3.3.3 ip host Spoke-2 4.4.4.4 ip host HUB 2.2.2.2 interface Loopback0 ip address 2.2.2.2 255.255.255.255 interface Serial0/0 ip address 10.10.10.2 255.255.255.0 encapsulation frame-relay IETF ip ospf network broadcast frame-relay map ip 10.10.10.2 204 frame-relay map ip 10.10.10.3 203 broadcast frame-relay map ip 10.10.10.4 204 broadcast no frame-relay inverse-arp frame-relay lmi-type cisco router ospf 10 router-id 2.2.2.2 log-adjacency-changes network 10.10.10.2 0.0.0.0 area 0 ip ospf name-lookup end | hostname Spoke-1 ip cef ip host Spoke-1 3.3.3.3 ip host Spoke-2 4.4.4.4 ip host HUB 2.2.2.2 interface Loopback0 ip address 3.3.3.3 255.255.255.255 interface Serial0/0 ip address 10.10.10.3 255.255.255.0 encapsulation frame-relay IETF ip ospf network broadcast frame-relay map ip 10.10.10.2 302 broadcast frame-relay map ip 10.10.10.3 302 no frame-relay inverse-arp frame-relay lmi-type cisco router ospf 10 router-id 3.3.3.3 log-adjacency-changes network 10.10.10.3 0.0.0.0 area 0 ip ospf name-lookup end | hostname Spoke-2 ip cef ip host Spoke-1 3.3.3.3 ip host Spoke-2 4.4.4.4 ip host HUB 2.2.2.2 interface Loopback0 ip address 4.4.4.4 255.255.255.255 interface Serial0/0 ip address 10.10.10.4 255.255.255.0 encapsulation frame-relay IETF ip ospf network broadcast frame-relay map ip 10.10.10.2 402 broadcast frame-relay map ip 10.10.10.4 204 no frame-relay inverse-arp frame-relay lmi-type cisco router ospf 10 router-id 4.4.4.4 log-adjacency-changes network 10.10.10.4 0.0.0.0 area 0 ip ospf name-lookup end |
Note: The command is configured on all the routers.
Verification Commands
show ip ospf neighbor

Note: Under the Neighbor-ID column, we see the host names and not the Router-Id. If we remove the feature by "no ip ospf name-lookup" the output will be like below.

References
IP Routing OSPF Command Reference - IOS 12.4
IP Routing OSPF Configuration Guide