07-07-2008 01:06 PM
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?
Solved! Go to Solution.
07-07-2008 09:40 PM
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.
07-07-2008 09:40 PM
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.
07-08-2008 06:02 AM
Thats pretty cool. Thanks!
11-16-2010 01:21 PM
Thanks Joseph,
Added the alias to makes things easier and lazier...
#alias exec host tclsh flash:host.tcl
11-16-2010 01:59 PM
I've posted an updated version of my host.tcl with UDP and IPv6 support at http://forums.cisco.com/eforum/servlet/EEM;jsessionid=3BBA522C4C95130B9EE7E8EF010F6BB8.SJ1A?page=eem&fn=script&scriptId=2507 .
11-28-2012 01:29 PM
Joe,
The above link you posted is not working. Is the updated script still available?
Thanks.
11-28-2012 02:05 PM
Script is available at https://supportforums.cisco.com/docs/DOC-19590 .
01-15-2021 04:38 AM
The script is not available anymore. Can you please re-upload it ?
02-14-2021 11:30 PM
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.
10-27-2020 05:39 AM - edited 10-27-2020 05:55 AM
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?
10-08-2015 07:28 PM - edited 08-30-2019 09:18 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide