def is_valid_cidr(string_network):
 if (string_network.count('/') == 1):
  try:
   mask = int(string_network.split('/')[1])
  except ValueError:
   return False
  if ((mask < 1) or (mask > 32)):
   return False
  try:
   socket.inet_aton(string_network.split('/')[0])
  except socket.error:
   return False
 else:
  return False
 return True

def is_valid_cidr ( string_network ) : if ( string_network . count ( '/' ) == 1 ) : try : mask = int ( string_network . split ( '/' ) [ 1 ] ) except ValueError : return False if ( ( mask < 1 ) or ( mask > 32 ) ) : return False try : socket . inet_aton ( string_network . split ( '/' ) [ 0 ] ) except socket . error : return False else : return False return True
check if address is valid the provided address can be a ipv6 or a ipv4 cidr address .