def check_subnet_ip(cidr, ip_address):
 ip = netaddr.IPAddress(ip_address)
 net = netaddr.IPNetwork(cidr)
 return ((ip != net.network) and ((net.version == 6) or (ip != net[(-1)])) and ((net.netmask & ip) == net.network))

def check_subnet_ip ( cidr , ip_address ) : ip = netaddr . IPAddress ( ip_address ) net = netaddr . IPNetwork ( cidr ) return ( ( ip != net . network ) and ( ( net . version == 6 ) or ( ip != net [ ( - 1 ) ] ) ) and ( ( net . netmask & ip ) == net . network ) )
validate that the ip address is on the subnet .