Task #6998
closed
Install & Setup netbox on an IPv6 only VM and find out how to get / reserve the next free ip address
Added by Ahmed Bilal over 5 years ago.
Updated about 5 years ago.
Description
Checkout whether getting "the next free IP address" works nicely via API for IPv6 and IPv4
If yes, we can use netbox as an IPAM backend
- Status changed from Seen to Feedback
- Assignee changed from Ahmed Bilal to Nico Schottelius
- Subject changed from Install & Setup netbox on an IPv6 only VM to Install & Setup netbox on an IPv6 only VM and find out how to get / reserve the next free ip address
- Status changed from Feedback to Seen
- Assignee changed from Nico Schottelius to Ahmed Bilal
ping. please create a proof of concept for getting the next free ip address of a network via the API. Test it for IPv6 and IPv4. Document the commands used.
Nico Schottelius wrote:
ping. please create a proof of concept for getting the next free ip address of a network via the API. Test it for IPv6 and IPv4. Document the commands used.
OK.
- Status changed from Seen to Feedback
- Assignee changed from Ahmed Bilal to Nico Schottelius
For credentials, see channel org-ahmedbilal
I created a prefix 2a0a:e5c1:144:1::/64 using netbox web interface. It can be seen at http://netbox-dev.ungleich.ch/ipam/prefixes/1/ then use netbox's official Python library pynetbox to get and consume next free ip
import pynetbox
# Create connection
nb = pynetbox.api('http://netbox-dev.ungleich.ch/',
token='6042908243ca4b3cb81040064165eb187af48b6f')
# Get prefix of which we want to get
# next free ip address of
prefix = nb.ipam.prefixes.get(1)
# Get free IP
free_ip = prefix.available_ips.list()[0]
print("Free IP", free_ip)
# Consume or Mark that IP as used
prefix.available_ips.create(data={"address": free_ip["address"]})
print("Free IP after using last", prefix.available_ips.list()[0])
Output:
Free IP {'family': 6, 'address': '2a0a:e5c1:144:1::/64', 'vrf': None}
Free IP after using last {'family': 6, 'address': '2a0a:e5c1:144:1::1/64', 'vrf': None}
- Related to Task #7129: Turn the netbox installation into a production setup added
Related task is also complete.
- Status changed from Feedback to Closed
Also available in: Atom
PDF