cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 9

Script needed to add to an existing config.

I apologize in advance since I am new to the community.  I could not find any scripts readily available and I am horrible at scripting....

I am evaluating NCM for my company and need some assistance on building a simple script to add IP addresses to an ACL on an existing config. 

This is for a Cisco Switch.

Thanks,

Labels (2)
0 Kudos
8 Replies
Level 13

Can you give us a sanitized example of what you want to do? Specifically what the access list looks like now and what you want it to look like after you're done. You can change the IP addresses, ports, etc., used in the list if they are sensitive.

0 Kudos

I need the following (changed) addresses to Access-List 97.

config t

access-list 97 permit 10.21.26.192

access-list 97 permit 10.21.26.195

access-list 97 permit 10.21.26.196

access-list 97 permit 10.21.26.197

end

0 Kudos

That will pretty much be your script then, add the command to save at the end. It should look like this.

config t

access-list 97 permit 10.21.26.192

access-list 97 permit 10.21.26.195

access-list 97 permit 10.21.26.196

access-list 97 permit 10.21.26.197

end

copy run start

!

The blank lines after the copy run start are there to get past the hitting enter to confirm the save, and the exclamation mark (comment) line is there to ensure that the blank lines don't get stripped.


That should be all there is to it.

0 Kudos

That is exactly what I attempted to do but I got a syntax error when validating so I was wondering if there is something I was missing.  I will take a look at it again.  Thansk for your assistance.

0 Kudos

Where are you doing this? This should be under the Configuration Management section. I don't even see a validation option there.

0 Kudos

I am making a template.  I ended up putting the section in a bracket like a programming language and it validated.  I am going to test it soon.

script ACLChangeTemplate(  

                             NCM.Nodes @ContextNode,

                             string @SomeVariable1,

                             string @SomeVariable2    )

{

  //TODO - insert details of change template

  //Enter CLI commands

  CLI

  {

     config t

     access-list 97 permit 10.21.26.194

     access-list 97 permit 10.21.26.196

     access-list 97 permit 10.21.26.197

     end

     wr

  }

0 Kudos

ok, I see what you are saying, templates are not needed.

0 Kudos

That makes sense then. For a static change like this I personally find the Configuration Management feature easier to use, because all you need to type in is the exact commands you would enter in the CLI. There's no additional overhead for the script. Your way isn't wrong, it's just different from where I assumed you were doing it.

0 Kudos