cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
1359
Views
0
Helpful
2
Replies

Baseline template - look for specific loopback interface when specifying "ip tftp source-interface"

jesper_petersen
Level 1
Level 1

Hello all

I'm new to regex and I'm trying to make a baseline template, that will check our network devices for our required basic configuration.

What I'm trying to do is to make a template that will look for either a loopback0 or loopback1 interface.

If eĆ­ther one is found (the loopback interfaces will not be there at the same time) it must apply the following command:

ip tftp source-interface loopback0 (or loopback1)

Is it even possible to make an if-then statement using regex?

Thank you in advance.

Best regards

Jesper Ross Petersen

Message was edited by: Jesper Ross Petersen

2 Replies 2

Dan Frey
Cisco Employee
Cisco Employee

Yes, this can be done

#Go to the tcl shell of the device.

C1811#tclsh

C1811(tcl)#

#copy and paste this at the tcl prompt.

proc intf {} {

set runningcfg [exec show run | inc ^interface Loopback]

foreach line [split $runningcfg \n] {

if {[regexp {interface (Loopback[0-1])} $line -> interface] } {

ios_config "ip tftp source-interface $interface"

return "ip tftp source-interface $interface"

}}}

# now type the name of the proc (intf) at the tcl prompt.

C1811(tcl)#intf

# If loopback0 or 1 is present the tftp source interface is added to the running config.

ip tftp source-interface Loopback0

C1811(tcl)#

Hello Dafrey

Thank you for your reply.

It seems that I haven't mentioned that this script is to be used with Cisco LMS, sorry about that.

Is it possible to do the script that you've provided in the Cisco LMS web gui?

I can see that the LMS server also has the tclsh (I've never even seen it or used it before ).

I hope you understand what I mean. Thank you and have a nice day!

Best regards

Jesper Ross