- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Cisco - Make Changes on Multiple Interfaces and Save Config
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-07-2015 04:01 PM
I am looking for a script example of how to make change across multiple interfaces and then save the changes once completed.
I am looking to do something like the following:
config t
int gi0/1
no switchport port-security
no switchport voice vlan 30
int gi0/2
no switchport port-security
no switchport voice vlan 30
... repeat for every port on the switch
end
write memory
=============
I am have trouble figuring out how to go int to configuration mode 1 time, iterate through all the interfaces and then finally end out and save the configuration before moving on to the next switch.
Questions:
1. Are there any templated scripts that can do such a task?
2. Should this be done in CCS or Perl?
Thanks ahead of time.
Solved! Go to Solution.
Re: Cisco - Make Changes on Multiple Interfaces and Save Config
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-07-2015 06:59 PM
NetMRI ships with a collection of sample scripts that incrementally show how to do exactly what you want. Both CCS and Perl equivalents are included. Start with Example5.ccs or Example5.pl.
Re: Cisco - Make Changes on Multiple Interfaces and Save Config
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-08-2015 11:45 AM
Thank you MAdkins. Those scripts look promising.
Re: Cisco - Make Changes on Multiple Interfaces and Save Config
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-09-2015 10:47 AM
If you want to make the same changes to all interfaces and if the switch is Cisco why not use an interface range and change them all at once ? Heck you could do that with an ad hoc script quite easily.
Int range gi 0/1-48
no switchport port-security
no switchport voice vlan 30
do wr mem
Re: Cisco - Make Changes on Multiple Interfaces and Save Config
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-15-2015 04:21 AM
BGroves, then the issue becomes how many line cards does a chassis have to formulate the correct range.
Re: Cisco - Make Changes on Multiple Interfaces and Save Config
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-15-2015 04:22 AM
Here is my final script to remove port security off every interface on a switch. This seems to be a useble solution.
Script-Filter:
$Vendor eq "Cisco" and $Type in ["Switch","Switch-Router"] and $sysDescr like /IOS/
################
Action:
Find Interfaces
Action-Commands:
SET: $UpdateMade = "no"
sho ip int brief
Output-Triggers:
Process Interfaces
################
Trigger:
Process Interfaces
Trigger-Description:
Find valid interfaces to check for helpers - An interface that has an ip address and is "up"
Trigger-Variables:
$IntName /(\w+\d+(\/\d{1,2}|\/\d{1,2}\/\d+|\/\d{1,2}\.\d+|\/\d{1,2}\:\d+)?|\w+-\w+\d{1,3})/
Trigger-Template:
[[$intName]]\s+unassigned
Trigger-Commands: {$UpdateMade eq "no"}
show run interface $intName
SET:$cmdsRemoved = "no"
Trigger-Commands: {$UpdateMade eq "yes"}
do show run interface $intName
SET:$cmdsRemoved = "no"
Output-Triggers:
ParseOutput
################
Trigger:
ParseOutput
Trigger-Variables:
$cmd /switchport\sport-security\smaximum|switchport\sport-security\sviolation\srestrict|switchport\sport-security\saging\stime|switchport\sport-security\saging\stype|switchport\sport-security/
Trigger-Template:
[[$cmd]]
Trigger-Filter:
$cmd like /port-security/
Trigger-Commands: {$UpdateMade eq "no"}
config t
# Only remove the commands 1 time, not for each match of "port-security"
Trigger-Commands: {$cmdsRemoved eq "no"}
int $intName
no switchport port-security maximum
no switchport port-security violation restrict
no switchport port-security aging time
no switchport port-security aging type inactivity
no switchport port-security
exit
SET:$UpdateMade = "yes"
SET:$cmdsRemoved = "yes"
########
Action:
End and Write Memory
Action-Description:
End and Write Memory only if we entered config mode.
Action-Commands: {$UpdateMade eq "yes"}
end
write mem
SET:$UpdateMade = "no"