Skip to content

Instantly share code, notes, and snippets.

@Harrisoon
Created November 21, 2018 10:31
Show Gist options
  • Save Harrisoon/fe57a5c1f6cd9876beb97fd8584951e9 to your computer and use it in GitHub Desktop.
Save Harrisoon/fe57a5c1f6cd9876beb97fd8584951e9 to your computer and use it in GitHub Desktop.
Returns next available IP.
#!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