New VLAN+Ip address for about 1000 Switches

Answered Question
Feb 15th, 2017
User Badges:

Hello,

i hope this is the right place to ask.

We have a lot Cisco Switches (in principle 2960, 2950, 2940) an now it's time to change the management VLAN of ~1000 Devices.


So we have to add a new VLAN interface on Every Switch, add a new IP like 10.108.XXX.3-X and set a new default gateway.


We got like 150 branches with different Ip addresses. For Example:

Switch 1 in Branch 1 will get the new IP: 10.108.0.3
Switch 2 in Branch 1 will get the new IP: 10.108.0.4

Switch 3 in Branch 1 will get the new IP: 10.108.0.5 and so on

Switch 1 in Branch 2 will get the new IP: 10.108.2.3

Switch 2 in Branch 2 will get the new IP: 10.108.2.4


Switch 1 in Branch 3 will get the new IP: 10.108.3.3
Switch 2 in Branch 3 will get the new IP: 10.108.3.4

So the third octet is different in every Branch.


There is actually a VLAN where an ip address is set like 10.230.111.3, 10.230.111.220 - XXX when the ip 10.230.111.3 is there the new ip in the new VLAN should be 10.108.0.3, when the ip 10.230.111.220 is there the new ip should be 10.108.0.4 and so on... 221 -> .5 222 -> .6

Is there a way to script this sh*t? I thought about expect Script but there is no way to read out some information and change the ip like i told.

I hope you understand the Problem.

Best regards

Daniel

Correct Answer by r.crist about 4 months 1 day ago

Hi Daniel:


Are you still looking for a way to script this?  Will you have a consistent mapping of second and third octets?  For the new management IP addresses, will the second octet always be 108?  And does the third octet increment by one in both the old and new IP addresses?  For example, will your old and new IP addresses look like this?


Old                        New

10.230.111.3        10.108.0.3

10.230.111.220    10.108.0.4
10.230.111.221    10.108.0.5


10.230.112.3        10.108.1.3

10.230.112.220    10.108.1.4


10.230.113.3        10.108.2.3

10.230.113.220    10.108.2.4

etc.


If so, I think that this can be done with Expect. 

Rich

Correct Answer by Philip D'Ath about 4 months 1 week ago

I'm old school, so I would use perl.  If you are a bit younger you might use Python (its trendy at the moment).


I would probably do it in two parts.  I would write a script to dump the switch serial number to a file (you might also dump the current IP addresses).  Then I would pull it into a spreadsheet, and allocate all the IP addresses using a bit of drag and drop.  And then I would write a second script that applied the config change based on the switch serial number.


Another way I would consider doing it, using two parts again, is to write a script that walked across every switch backing up the configs to a central web server (hmm, backups, that sounds nice).

Then write a script to walk across every stored config on the server updating them.  Then I would check a whole bunch to make sure I was happy.

And then I would write a script to walk across all the switches and download the configs back onto the switch.  This would help you avoid getting locked out part way through a change as well.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Loading.
Correct Answer
Philip D'Ath Thu, 02/16/2017 - 03:04
User Badges:
  • Purple, 4500 points or more
  • Cisco Designated VIP,

    2017 WAN, LAN, VPN

I'm old school, so I would use perl.  If you are a bit younger you might use Python (its trendy at the moment).


I would probably do it in two parts.  I would write a script to dump the switch serial number to a file (you might also dump the current IP addresses).  Then I would pull it into a spreadsheet, and allocate all the IP addresses using a bit of drag and drop.  And then I would write a second script that applied the config change based on the switch serial number.


Another way I would consider doing it, using two parts again, is to write a script that walked across every switch backing up the configs to a central web server (hmm, backups, that sounds nice).

Then write a script to walk across every stored config on the server updating them.  Then I would check a whole bunch to make sure I was happy.

And then I would write a script to walk across all the switches and download the configs back onto the switch.  This would help you avoid getting locked out part way through a change as well.

Correct Answer
r.crist Thu, 02/23/2017 - 04:10
User Badges:

Hi Daniel:


Are you still looking for a way to script this?  Will you have a consistent mapping of second and third octets?  For the new management IP addresses, will the second octet always be 108?  And does the third octet increment by one in both the old and new IP addresses?  For example, will your old and new IP addresses look like this?


Old                        New

10.230.111.3        10.108.0.3

10.230.111.220    10.108.0.4
10.230.111.221    10.108.0.5


10.230.112.3        10.108.1.3

10.230.112.220    10.108.1.4


10.230.113.3        10.108.2.3

10.230.113.220    10.108.2.4

etc.


If so, I think that this can be done with Expect. 

Rich

Actions

This Discussion