Find the smallest range containing the given IP.

def by_ip(self, ip):
        """ Find the smallest range containing the given IP.
        """
        try:
            number = inet_aton(ip)
        except Exception:
            raise IpRange.DoesNotExist

        try:
            return self.filter(start_ip__lte=number, end_ip__gte=number)\
                       .order_by('end_ip', '-start_ip')[0]
        except IndexError:
            raise IpRange.DoesNotExist