└── example.sh /example.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #https://phpipam.net/api/api_documentation/ 3 | 4 | link='127.0.0.1' 5 | user='user' 6 | pass='password' 7 | #Go to settings in phpipam GUI and enable API module, than go to settings > API and create new API App( App security - SSL with User token ) 8 | app_id="test" 9 | 10 | # Login & Create Session 11 | token=$(curl -X POST -s -k --user ${user}:${pass} 'https://'$link'/api/'$app_id'/user/' -i) 12 | 13 | #get token 14 | token=$(echo $token | awk -F '":{"' '{print $2}' | awk -F '":"' '{print $2}' | awk -F '","' '{print $1}') 15 | 16 | echo "token:" 17 | echo $token 18 | 19 | 20 | 21 | #create a new subnet 22 | subnet='12.0.0.0' 23 | mask='24' 24 | section_id='18' 25 | out=$(curl -X POST -s -k 'https://'$link'/api/'$app_id'/subnets/?subnet='$subnet'&mask='$mask'§ionId='$section_id --header "token: $token" ) 26 | 27 | echo $out 28 | --------------------------------------------------------------------------------