- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
script for checking/ adding port security.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-26-2018 11:28 AM
i am trying to write a CCS script for checking a cisco switch for port security enabled on the interfaces, and if so stopping the program and moving on, but if no port security, correcting the issue.
so far i have been able to get the switch to show port security and add port security to a range of interfaces, but i cannot seem to get it to see if it does have port security and if so not make the changes and finish the test and close out. below is what i have: any help would be great.
script-filter:
$vendor eq "Cisco" and $sysdescr like /IOS/
action: check Port Security
action-commands:
SET: $updatemade = "no"
sr | i port-sec
output-triggers: check port security
#########
trigger: check port security
trigger-variables: $portsecurity string
trigger-template: port security [[$portsecurity]]
trigger-commands: {$updatemade = "yes"}
ct
SET: $updatemade = "yes"
########
action: save config, log out
action-commands: { $updatemade ="yes"}
crs \r\r
########
trigger: fix port security
trigger-variables: $noportsecurity string
trigger-template: trigger-template: no port security [[$noportsecurity]]
trigger-commands: {$updatemade = "no"}
ct
int range g1/0/1-23
no switchport port-sec mac-address sticky
no switchport port-sec
do wr
end
SET: $updatemade = "yes"
#########
action: add port security to switchports
action-commands: {$updatemade = "no"}
ct
int range g1/0/1-23
switchport port-sec
switchport port-sec mac-address sticky
end
SET: $updatemade = "yes"
########
action:
save config
action-description:
save running config
action-filter:
$updatemade = "yes"
action-commands:
crs \r\r
also , im a bit of a noob at this, so please use small words
v/r
Re: script for checking/ adding port security.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-03-2018 05:07 AM
Can you post what this output looks like
sr | i port-sec
Thanks,
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com
Re: script for checking/ adding port security.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-21-2018 12:31 PM
thanks for your reply SBaksh, but i managed to work it out.
i was thinking to big in my scripting, so i simplified it and it appears to have worked as i want it too.
v/r