Monday 16 October 2017

Python Script:Generate Running Config

1.Write a script to generate Incremental IPv6, IPv6 ,Vlan Numbers and VE Numbers .


Range:10 - 51

IPv4 Start: 10.10.10.1
IPv6 Start: 10::1
IPv6 Start: 2010::1
IPv6 Start: 3010::1


Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> for i in range(10,51):
...  print "vlan "+str(i)
...  print "router-int ve "+str(i)
...  print "int ve "+str(i)
...  print "ip add "+str(i)+'.'+str(i)+'.'+str(i)+'.'+str(1)+'/24'
...  print "ipv6 add "+str(i)+'::'+str(1)+'/64'
...  print "ipv6 add "+str(20)+str(i)+'::'+str(1)+'/64'
...  print "ipv6 add "+str(30)+str(i)+'::'+str(1)+'/64'
... 
vlan 10
router-int ve 10
int ve 10
ip add 10.10.10.1/24
ipv6 add 10::1/64
ipv6 add 2010::1/64
ipv6 add 3010::1/64
vlan 11
router-int ve 11
int ve 11
ip add 11.11.11.1/24
ipv6 add 11::1/64
ipv6 add 2011::1/64
ipv6 add 3011::1/64
vlan 12
router-int ve 12
int ve 12
ip add 12.12.12.1/24
ipv6 add 12::1/64
ipv6 add 2012::1/64
ipv6 add 3012::1/64
vlan 13
router-int ve 13
int ve 13
ip add 13.13.13.1/24
ipv6 add 13::1/64
ipv6 add 2013::1/64
ipv6 add 3013::1/64
vlan 14
router-int ve 14
int ve 14
ip add 14.14.14.1/24
ipv6 add 14::1/64
ipv6 add 2014::1/64
ipv6 add 3014::1/64
vlan 15
router-int ve 15
int ve 15
ip add 15.15.15.1/24
ipv6 add 15::1/64
ipv6 add 2015::1/64
ipv6 add 3015::1/64
vlan 16
router-int ve 16
int ve 16
ip add 16.16.16.1/24
ipv6 add 16::1/64
ipv6 add 2016::1/64
ipv6 add 3016::1/64
vlan 17
router-int ve 17
int ve 17
ip add 17.17.17.1/24
ipv6 add 17::1/64
ipv6 add 2017::1/64
ipv6 add 3017::1/64
vlan 18
router-int ve 18
int ve 18
ip add 18.18.18.1/24
ipv6 add 18::1/64
ipv6 add 2018::1/64
ipv6 add 3018::1/64
vlan 19
router-int ve 19
int ve 19
ip add 19.19.19.1/24
ipv6 add 19::1/64
ipv6 add 2019::1/64
ipv6 add 3019::1/64
vlan 20
router-int ve 20
int ve 20
ip add 20.20.20.1/24
ipv6 add 20::1/64
ipv6 add 2020::1/64
ipv6 add 3020::1/64
vlan 21
router-int ve 21
int ve 21
ip add 21.21.21.1/24
ipv6 add 21::1/64
ipv6 add 2021::1/64
ipv6 add 3021::1/64
vlan 22
router-int ve 22
int ve 22
ip add 22.22.22.1/24
ipv6 add 22::1/64
ipv6 add 2022::1/64
ipv6 add 3022::1/64
vlan 23
router-int ve 23
int ve 23
ip add 23.23.23.1/24
ipv6 add 23::1/64
ipv6 add 2023::1/64
ipv6 add 3023::1/64
vlan 24
router-int ve 24
int ve 24
ip add 24.24.24.1/24
ipv6 add 24::1/64
ipv6 add 2024::1/64
ipv6 add 3024::1/64
vlan 25
router-int ve 25
int ve 25
ip add 25.25.25.1/24
ipv6 add 25::1/64
ipv6 add 2025::1/64
ipv6 add 3025::1/64
vlan 26
router-int ve 26
int ve 26
ip add 26.26.26.1/24
ipv6 add 26::1/64
ipv6 add 2026::1/64
ipv6 add 3026::1/64
vlan 27
router-int ve 27
int ve 27
ip add 27.27.27.1/24
ipv6 add 27::1/64
ipv6 add 2027::1/64
ipv6 add 3027::1/64
vlan 28
router-int ve 28
int ve 28
ip add 28.28.28.1/24
ipv6 add 28::1/64
ipv6 add 2028::1/64
ipv6 add 3028::1/64
vlan 29
router-int ve 29
int ve 29
ip add 29.29.29.1/24
ipv6 add 29::1/64
ipv6 add 2029::1/64
ipv6 add 3029::1/64
vlan 30
router-int ve 30
int ve 30
ip add 30.30.30.1/24
ipv6 add 30::1/64
ipv6 add 2030::1/64
ipv6 add 3030::1/64
vlan 31
router-int ve 31
int ve 31
ip add 31.31.31.1/24
ipv6 add 31::1/64
ipv6 add 2031::1/64
ipv6 add 3031::1/64
vlan 32
router-int ve 32
int ve 32
ip add 32.32.32.1/24
ipv6 add 32::1/64
ipv6 add 2032::1/64
ipv6 add 3032::1/64
vlan 33
router-int ve 33
int ve 33
ip add 33.33.33.1/24
ipv6 add 33::1/64
ipv6 add 2033::1/64
ipv6 add 3033::1/64
vlan 34
router-int ve 34
int ve 34
ip add 34.34.34.1/24
ipv6 add 34::1/64
ipv6 add 2034::1/64
ipv6 add 3034::1/64
vlan 35
router-int ve 35
int ve 35
ip add 35.35.35.1/24
ipv6 add 35::1/64
ipv6 add 2035::1/64
ipv6 add 3035::1/64
vlan 36
router-int ve 36
int ve 36
ip add 36.36.36.1/24
ipv6 add 36::1/64
ipv6 add 2036::1/64
ipv6 add 3036::1/64
vlan 37
router-int ve 37
int ve 37
ip add 37.37.37.1/24
ipv6 add 37::1/64
ipv6 add 2037::1/64
ipv6 add 3037::1/64
vlan 38
router-int ve 38
int ve 38
ip add 38.38.38.1/24
ipv6 add 38::1/64
ipv6 add 2038::1/64
ipv6 add 3038::1/64
vlan 39
router-int ve 39
int ve 39
ip add 39.39.39.1/24
ipv6 add 39::1/64
ipv6 add 2039::1/64
ipv6 add 3039::1/64
vlan 40
router-int ve 40
int ve 40
ip add 40.40.40.1/24
ipv6 add 40::1/64
ipv6 add 2040::1/64
ipv6 add 3040::1/64
vlan 41
router-int ve 41
int ve 41
ip add 41.41.41.1/24
ipv6 add 41::1/64
ipv6 add 2041::1/64
ipv6 add 3041::1/64
vlan 42
router-int ve 42
int ve 42
ip add 42.42.42.1/24
ipv6 add 42::1/64
ipv6 add 2042::1/64
ipv6 add 3042::1/64
vlan 43
router-int ve 43
int ve 43
ip add 43.43.43.1/24
ipv6 add 43::1/64
ipv6 add 2043::1/64
ipv6 add 3043::1/64
vlan 44
router-int ve 44
int ve 44
ip add 44.44.44.1/24
ipv6 add 44::1/64
ipv6 add 2044::1/64
ipv6 add 3044::1/64
vlan 45
router-int ve 45
int ve 45
ip add 45.45.45.1/24
ipv6 add 45::1/64
ipv6 add 2045::1/64
ipv6 add 3045::1/64
vlan 46
router-int ve 46
int ve 46
ip add 46.46.46.1/24
ipv6 add 46::1/64
ipv6 add 2046::1/64
ipv6 add 3046::1/64
vlan 47
router-int ve 47
int ve 47
ip add 47.47.47.1/24
ipv6 add 47::1/64
ipv6 add 2047::1/64
ipv6 add 3047::1/64
vlan 48
router-int ve 48
int ve 48
ip add 48.48.48.1/24
ipv6 add 48::1/64
ipv6 add 2048::1/64
ipv6 add 3048::1/64
vlan 49
router-int ve 49
int ve 49
ip add 49.49.49.1/24
ipv6 add 49::1/64
ipv6 add 2049::1/64
ipv6 add 3049::1/64
vlan 50
router-int ve 50
int ve 50
ip add 50.50.50.1/24
ipv6 add 50::1/64
ipv6 add 2050::1/64
ipv6 add 3050::1/64
>>>   

... 

2.Write a script to generate Incremental Dhcp Pool, excluded address and network.

 e 9/1/11 e 6/1/14 e 7/1/12 e 8/1/12  e 2/1/1 e 3/1/24 e 5/1/13 e 1/1/18 e 1/1/23 e 2/1/24


>>> for i in [99,220,210,55,77]:
...  print "ip dhcp-server pool network-"+str(i)
...  print "excluded-address "+str(i)+'.'+str(i)+'.'+str(i)+'.'+str(1)
...  print "network "+str(i)+'.'+str(i)+'.'+str(i)+'.'+str(0)+" "+"255.255.255.0"
...  print "lease 0 0 30"
...  print "deploy"
... 
ip dhcp-server pool network-99
excluded-address 99.99.99.1
network 99.99.99.0 255.255.255.0
lease 0 0 30
deploy
ip dhcp-server pool network-220
excluded-address 220.220.220.1
network 220.220.220.0 255.255.255.0
lease 0 0 30
deploy
ip dhcp-server pool network-210
excluded-address 210.210.210.1
network 210.210.210.0 255.255.255.0
lease 0 0 30
deploy
ip dhcp-server pool network-55
excluded-address 55.55.55.1
network 55.55.55.0 255.255.255.0
lease 0 0 30
deploy
ip dhcp-server pool network-77
excluded-address 77.77.77.1
network 77.77.77.0 255.255.255.0
lease 0 0 30
deploy
>>>  
... 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.