Thursday, June 20, 2013

Resolving OSPF neighbor router-id to hostname

In Large networks, you may find it hard to remember which OSPF neighbor is on a certain link. Of course if you can memorize the router-id of each router in your network that would be amazing, but for someone like me it can be a pain while working on something that needs to be done fast since i have to jot down the topology with IPs on just to remember who's who in the network.

Luckily, there's a command in Cisco IOS that can resolve OSPF neighbor router-id into it's hostname.

ip ospf name-lookup

This is a Global configuration command, now let's see how a typical OSPF show neighbor command looks like

R1#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface           1   FULL/DR         00:00:31        FastEthernet1/0

As you can see, R1 see neighbor R2 by it's router-id, now let's make it see it by hostname

First we need to map R2 hostname to the IP on R1 then configure OSPF router-id hostname resolving.

R1(config)#ip host R2

R1#show hosts
Default domain is not set
Name/address lookup uses domain service using source interface Loopback0
Name servers are
Codes: UN - unknown, EX - expired, OK - OK, ?? - revalidate
       temp - temporary, perm - permanent
       NA - Not Applicable None - Not defined
Host                      Port  Flags      Age Type   Address(es)
R2                        None  (perm, OK)  0   IP

As shown above, the hostname R2 can now be resolved to locally on R1, now let's make OSPF resolve hostnames from router-ids

R1(config)#ip ospf name-lookup

R1#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
R2                1   FULL/DR         00:00:33        FastEthernet1/0

As you can see now, the show command displays the hostname instead of the router-id, which be very useful. one thing to notice though is that if you're using an external DNS server for name resolution, it can get very slow when using the show commands because of the name lookup process.