11-22-2007 06:39 AM
Hello,
Basic Question:
How can I do a "nslookup <hostname>" in an eem tcl ?
Background:
I need to modify the running-config by putting the same (!) ip address at several places (crypto map peers, access-lists, routes).
No Problem. Basically that already works when using IP adresses.
But now the IP adress has to be resolved by DNS. The responsible DNS server uses Round-Robin-DNS and delivers another IP with every answer.
If I use the hostname in the cli_exec, the hostname is parsed to IOS,
and IOS resolves the hostname to a different IP with every "cli_exec"; leading to different IPs in the running config.
Is there a dns command or lib available in the IOS-TCL ?
11-22-2007 09:58 AM
There is no DNS library for IOS TCL (and currently no UDP socket support to make your own). But you could do something like:
set output [exec "ping ip [info hostname] repeat 1"]
regexp {Echos to ([^,]+)} $output ignore ip
puts $ip
11-22-2007 11:09 PM
Sorry, I missed the keyword "eem" there. The same method will work, but you will need to modify things slightly for EEM. I wrote an EEM CLI wrapper library to help with these things which can be downloaded from http://forums.cisco.com/eforum/servlet/EEM?page=eem&fn=script&scriptId=441 . Using that library, the above would become:
set cmd "ping ip [info hostname] repeat 1"
set output [run_cli [list $cmd]]
regexp {Echos to ([^,]+)} $output ignore ip
# $ip now holds the IP address
11-23-2007 01:27 AM
Thanks, Joe.
We already had the "IOS ping command" idea...
As unfortunateley there seems to be no better solution without a resolver/dns lib, I will try to implement that.
btw:
Does a IOS tcl-command/tcl-library reference exist ?
Can it be found anywhere in the vastness of the CCO ?
11-23-2007 02:33 AM
The only references are the documentation for TCL scripting in IOS and EEM:
http://www.cisco.com/en/US/products/sw/iosswrel/ps5207/products_feature_guide09186a00801a75a7.html
http://www.cisco.com/en/US/products/ps6017/products_feature_guide_chapter09186a00804d343f.html
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