def ip2bin(ip_addr):
    """Convert IP address to binary"""
    octets = map(int, ip_addr.split('/')[0].split('.'))
    binary = '{0:08b}{1:08b}{2:08b}{3:08b}'.format(*octets)
    range_bin = int(ip_addr.split('/')[1]) if '/' in ip_addr else None
    return binary[:range_bin] if range_bin else binary