-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNH-Co2020-Challenge1.py
47 lines (27 loc) · 1.17 KB
/
DNH-Co2020-Challenge1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""DevNet High - Class of 2020 - Challenge 1"""
import random
import ipaddress
# TODO: Write a print statement that displays both the type and value of 'ip'
ip = "10.1.1.200"
print('Value: '+ip+' Type: '+str(type(ip)))
# TODO: Write a conditional to print out if `iosversion` is less than or greater than 14
i = random.randint(12, 17)
if i>14 or i<14:
print('i is {}'.format(i))
# TODO: Write a conditional that prints the serial number of the device
devices = ({'CAT9300':'XVNM1245ERGC'}, {'ISR4331':'VNMM8742THBX'}, {'NGFW2120':'EAQP4900RTJO'})
device = random.sample(devices, 1) [0]
device = list(device.values())[0]
print('Serial: '+device)
# Function for converting CIDR notation into 32-bit netmask (nothing to do here)
def cidr_to_netmask(ip_str):
ip = ipaddress.IPv4Network(ip_str)
return ip.with_netmask
'''
TODO: Call the function above few times to so that the input of IP network with CIDR displays the IP network with 32-bit netmask
Example:
Input would be '10.1.1.0/24' and when printed out the output would be '10.1.1.0/255.255.255.0'
'''
ipaddrs = ["10.10.10.0/24","172.16.0.0/16","10.10.10.0/31"]
for ipaddr in ipaddrs:
print(cidr_to_netmask(ipaddr))