diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index ce3c2a8f9..3ff0ff76e 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -66,10 +66,10 @@ def add_available_ipaddresses(prefix, ipaddress_list): # Iterate through existing IPs and annotate free ranges for ip in ipaddress_list: if prev_ip: - skipped_count = int(ip.address.ip - prev_ip.address.ip - 1) - if skipped_count: + diff = int(ip.address.ip - prev_ip.address.ip) + if diff > 1: first_skipped = '{}/{}'.format(prev_ip.address.ip + 1, prefix.prefixlen) - output.append((skipped_count, first_skipped)) + output.append((diff - 1, first_skipped)) output.append(ip) prev_ip = ip