A Python interface to manage IP addresses in phpIPAM through REST API, with integration to ISC-DHCP
phpIPAM is an open-source web IP address management application. Its goal is to provide light and simple IP address management application.
Site: phpIPAM homepage
./dhcp2phpipam.py add ClientIP ClientDHCID ClientName RouterIPWhere:
- ClientIP : Host IP address
- ClientDHCID : Host MAC Address
- ClientName : Hostname
- RouterIP :
RouterIPis required to determine the subnet in which theClientIPshould be added.ClientIPis added on the same subnet whereRouterIPis located. It can be the IP of the gateway of the subnet or some other reference IP in that subnet
./dhcp2phpipam.py update ClientIP ClientDHCID ClientName /dhcp2phpipam.py del ClientIP- Install packages
pip install requestsor
sudo apt update && sudo apt install python-requests libssl-dev-
Create directory
/etc/dhcp/dhcpd-hooks.d/ -
Download and copy
dhcp2phpipam.pyin/etc/dhcp/dhcpd-hooks.d/ -
Edit
dhcp2phpipam.pyand set phpIPAM url, api name and api token
phpipam_url = 'https://phpipam.local'
api_id = 'your_api_name'
api_token = 'your_api_key'- Set execute permission on
dhcp2phpipam.py
chmod +x `/etc/dhcp/dhcpd-hooks.d/dhcp2phpipam.py`-
Download and copy
usr.sbin.dhcpdin:/etc/apparmor.d/local/and restart apparmor service -
Create directory
/etc/dhcp/dhcpd.conf.d/ -
Download and copy
dhcpd-event.confin/etc/dhcp/dhcpd.conf.d/ -
Edit
/etc/dhcp/dhcpd.confand includedhcpd-event.confwith trigers update
include "/etc/dhcp/dhcpd.conf.d/dhcpd-event.conf";-
Restart DHCP Server
-
Enjoy
