cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
62608
Views
35
Helpful
10
Replies

Can IOS do an nslookup?

sdaniels44
Level 1
Level 1

I have a switch configured to resolve hostnames, it works fine, if I ping xxx.xxx.local or whatever it looks up the IP and displays output.

Can this be done in reverse? So If I find an IP address in the arp table and want to resolve its hostname, is there a command like Windows nslookup that will allow for this?

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

There is nothing built-in, but attached is a Tcl script I wrote to do A and PTR DNS lookups using the IOS tclsh (in IOS 12.3(2)T or later, 12.2(18)SXF5 or higher, 12.2(40)SE or higher, etc.). Tclsh doesn't support UDP sockets right now, so my script uses TCP. It works similarly to the UNIX host command. If you do not specify a DNS server, it tries to obtain one by looking at the device's config. The usage is:

host.tcl address [dns_server]

For example:

Router#tclsh flash:host.tcl 10.1.1.1

1.1.1.10.in-addr.arpa domain name pointer host.company.com

Router#tclsh flash:host.tcl host.company.com

host.company.com has address 10.1.1.1

The script is pretty simplistic, but it should accomplish what you want.

View solution in original post

10 Replies 10

Joe Clarke
Cisco Employee
Cisco Employee

There is nothing built-in, but attached is a Tcl script I wrote to do A and PTR DNS lookups using the IOS tclsh (in IOS 12.3(2)T or later, 12.2(18)SXF5 or higher, 12.2(40)SE or higher, etc.). Tclsh doesn't support UDP sockets right now, so my script uses TCP. It works similarly to the UNIX host command. If you do not specify a DNS server, it tries to obtain one by looking at the device's config. The usage is:

host.tcl address [dns_server]

For example:

Router#tclsh flash:host.tcl 10.1.1.1

1.1.1.10.in-addr.arpa domain name pointer host.company.com

Router#tclsh flash:host.tcl host.company.com

host.company.com has address 10.1.1.1

The script is pretty simplistic, but it should accomplish what you want.

Thats pretty cool. Thanks!

Thanks Joseph,

Added the alias to makes things easier and lazier...

#alias exec host tclsh flash:host.tcl

Joe,

The above link you posted is not working. Is the updated script still available?

Thanks.

The script is not available anymore. Can you please re-upload it ?

I think it is available at https://community.cisco.com/t5/networking-documents/tclsh-implementation-of-host-nm/ta-p/3123994

It is in the archive named

116526-Tclsh_implementation_of_host(1)

I did not test it yet.

Although this post is quite old, it is yet very helpful.

Is there a way to make the script's lookup process to run through a specific interface?

jasonmadruga84
Level 1
Level 1

On my 2940 switch I can issue the traceroute command on an ip address and it will do a reverse DNS lookup. Be sure to keep the CTRL+Shift+6 command handy as traceroute can go for a while sometimes.
 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: