Reply

script for checking/ adding port security.

Authority
Posts: 15
5288     0

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 Smiley Happy

 

v/r

Re: script for checking/ adding port security.

Adviser
Posts: 407
5289     0

Can you post what this output looks like 

 

sr | i port-sec

 

Thanks,

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

Re: script for checking/ adding port security.

Authority
Posts: 15
5289     0

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

Showing results for 
Search instead for 
Do you mean 

Recommended for You