Write a Python program that reads IP addresses from an input file (ip_input.txt), checks its format and validity, and then checks its connectivity to each IP. Use the IP input file shown as below. Submit your code and the output screen shots after a run.
8.8.8.8
2.2.2.2.2
127.5.6.7
3.3.3.305
0.120.3.5
8.8.8.1
169.234.6.8
8.8.4.4
4.4.8.8
(you may add more to test your code)
Validity check (check the format and filter the addresses that are not publicly routable):
– IP should be four dotted format (x.x.x.x)
– octets having values between 0-255.
– IP should not belong to one of these blocks:
o 0.0.0.0/8
o 127.0.0.0/8
o 169.254.0.0/8
o (you may add more if you like)
Connectivity check:
– Use ping for testing reachability to the IP address.
The output could look like:
Ip address: 8.8.8.8
Validity: yes
Reachability: yes
Ip address: 2.2.2.2.2
Validity: no – bad format
Reachability: no
Ip address: 127.5.6.7
Validity: no – in block 127.0.0.0/8
Reachability: no
…….
…….