-
-
Save Harrisoon/fe57a5c1f6cd9876beb97fd8584951e9 to your computer and use it in GitHub Desktop.
Returns next available IP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/env python2 | |
import ipaddress | |
def consecutive_IP(CIDR = u'0.0.0.0', ip=u'0.0.0.0'): | |
''' | |
Takes an IP as the inupt and returns the next available IP address | |
d | |
@param CIDR: CIDR notation | |
@param ip: ip address | |
''' | |
if ip+1 in CIDR: | |
return ip+1 | |
else: | |
return 'No longer in network' | |
print(consecutive_IP(ipaddress.ip_network(u'195.168.1.0/24'), ipaddress.IPv4Address(u'195.168.1.50'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment