kulhanek / phpipam-utils

utilities for phpIPAM
3 stars 1 forks source link

phpIPAM v.1.7.0 Compatibility #5

Open IrieBro opened 1 week ago

IrieBro commented 1 week ago

Are these utilities compatible with phpIPAM version 1.7.0? So far, these seem to be the only way connect phpIPAM to Bind9 DNS. However, when running dns2phpipam in test mode, I get errors. I am not sure how to integrate the API token with these utils. I tried to add it to phpipam.conf without success. I guess the project date is my clue.

Server:/opt/docker_volumes/phpipam-utils # ./dns2phpipam -test 192.168.1.0/24

SubNet: 192.168.1.0/24
Test  : ON
PHP Notice:  Undefined property: stdClass::$data in /opt/docker_volumes/phpipam-utils/dns2phpipam on line 75
PHP Notice:  Trying to get property 'token' of non-object in /opt/docker_volumes/phpipam-utils/dns2phpipam on line 75
>>> ERROR: Unable to get subnet id for 192.168.1.0/24

object(stdClass)#1 (4) {
  ["code"]=>
  int(400)
  ["success"]=>
  bool(false)
  ["message"]=>
  string(22) "Invalid application id"
  ["time"]=>
  float(0.001)
}
Server:/opt/docker_volumes/phpipam-utils #
kulhanek commented 1 week ago

The utilities are tested with phpIPAM 1.4.x. Moreover, the scripts expect additional data via custom fields, such as NS, MX, host descriptions, etc. I am not sure, but the management of custom fields was probably changed in later versions of phpIPAM. Also, dns2phpipam was a one-time-used helper script to check consistency between DNS and phpIPAM records. We currently use phpipam2xxxx scripts to retrieve data from phpIPAM and generate config files for DNS and DHCP. These scripts might work after some tweaking to work also with the newest version of phpIPAM. Back to your problem. The error "Invalid application id" in your output indicates an error in the phpipam.conf file. To interact with the phpIPAM, you must create a user with proper rights (the read access to required subnets and other parts is usually enough). This access information is configured in phpipam.conf as $username and $passwd. In addition, you have to create API ID. This is managed in "API management" in the administration interface of phpIPAM. This API ID is then provided in the phpipam.conf file as SERVICEAPI (part of $url). See https://phpipam.net/api/api_documentation/, Available methods for authentication (user) controller: "my_app" in urls is "API ID" or "SERVICEAPI".