(ip, net)
return (ipaddr & netmask) == (network & netmask)
This function allows you to check if on IP belongs to a network subnet
    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
This function allows you to check if on IP belongs to a network subnet
    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
This function allows you to check if on IP belongs to a network subnet Example : returns True if ip = 192 . 168 . 1 . 1 and net = 192 . 168 . 1 . 0 / 24 returns False if ip = 192 . 168 . 1 . 1 and net = 192 . 168 . 100 . 0 / 24
def address_in_network(ip, net):
    """
    This function allows you to check if on IP belongs to a network subnet
    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
    """
    ipaddr = struct.unpack('=L', socket.inet_aton(ip))[0]
    netaddr, bits = net.split('/')
    netmask = struct.unpack('=L', socket.inet_aton(dotted_netmask(int(bits))))[0]
    network = struct.unpack('=L', socket.inet_aton(netaddr))[0] & netmask
    return (ipaddr & netmask) == (network & netmask)
def address_in_network ( ip , net ) : ipaddr = struct . unpack ( '=L' , socket . inet_aton ( ip ) ) [ 0 ] netaddr , bits = net . split ( '/' ) netmask = struct . unpack ( '=L' , socket . inet_aton ( dotted_netmask ( int ( bits ) ) ) ) [ 0 ] network = struct . unpack ( '=L' , socket . inet_aton ( netaddr ) ) [ 0 ] & netmask return ( ipaddr & netmask ) == ( network & netmask )