<div id="google_translate_element"></div> <script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element'); } </script> <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> |
The DHCPv2 system is built upon the Resource API, so actions relating to DHCP tasks are largely expressed in terms of Resource actions.
This section describes common DHCP tasks and how they are accomplished via the DHCPv2 system.
get all DHCP-enabled resources | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | Finds all resources from section 'dhcp_module,' which indicates that their parents are DHCP-enabled. Adding in other Resource-Get API parameters can filter this list further. | ||||||||||||||||||||||||||||||||||||||||
URL | /api/v1/api.php?target=resource&action=get&type=dhcp_module | ||||||||||||||||||||||||||||||||||||||||
Returns | Examples:
Return Detail:
Attributes:
|
create a new DHCP-enabled resource | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | A resource becomes a DHCP-enabled by adding a special "dhcp_module" resource as a child. This action is identical to a normal Resource Create command. | |||||||||||||||||||||||||
URL | /api/v1/api.php?target=resource&action=add&meta[type]=dhcp_module&meta[name]=2163 DHCP Module&meta[parent_id]=2163 | |||||||||||||||||||||||||
Returns | Examples:
Return Detail:
|
update a DHCP-enabled resource with new configuration info | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | Modifying an existing dhcp_module uses the identical commands as all other Resource-Update actions. An example of configuring a DHCP server is given below. | |||||||||||||||||||||||||||||||
URL | /api/v1/api.php?target=resource&action=update&meta[id]=2178 &meta[type]=dhcp_module&fields[_dhcp_attributes][]={"type":"ISC","notes":"notes go here","username":"username","port":"port","config_test":"/etc/init.d/dhcpd configtest","server_stop":"/etc/init.d/dhcpd stop","server_start":"/etc/init.d/dhcpd start","config_path":"/tmp/dhcpd.conf","option_routers":"192.168.0.0","option_domain_name_servers":"ns1.6connect.com","option_domain_name":"6connect.com","authoritative":"1","default_lease_time":"600","max_lease_time":"7200","local_port":"67","log_facility":"local7","password":"password","server_ip":"192.168.0.1","freeLines":3,"freeLine1":"free line 1","freeLine2":"free line 2","freeLine3":"free line 3"} | |||||||||||||||||||||||||||||||
Returns | Examples:
Return Detail:
Attributes:
|
remove DHCP functionality from a resource | |||||
---|---|---|---|---|---|
Description | To remove DHCP functionality, delete the dhcp_module child resource. This operation uses general Resource->Delete functionality. | ||||
URL | /api/v1/api.php?target=resource&action=delete&id=2166 | ||||
Returns | Examples:
|
get all DHCP Pools | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | As with the dhcp_module commands, the API endpoints governing DHCP IP Pools use the general Resource system. All the modifiers that can be applied to a Resource-Get can be used to filter this query. | |||||||||||||||||||||||||||||||||||||||||||
URL | /api/v1/api.php?target=resource&action=get&type=dhcp_pool | |||||||||||||||||||||||||||||||||||||||||||
Returns | Examples:
Return Detail:
Attributes:
|
create a new DHCP Pool resource | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | Uses the general Resource-Add endpoint to create a DHCP Pool resource. | |||||||||||||||||||||||||
URL | /api/v1/api.php?target=resource& action=add& meta[type]=dhcp_pool& meta[name]=New Subnet& fields[_dhcp_type][]=host& fields[_dhcp_pool_attributes][]={"mac":"aa:bb:cc:dd:ee:ff", "rangeStart":"", "rangeEnd":"", "freeLines":3, "freeLine1":"Free Line 1", "freeLine2":"Free Line 2", "freeLine3":"Free Line 3"} | |||||||||||||||||||||||||
Returns | Examples:
Return Detail:
|
update a DHCP Pool | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | Modifying an existing dhcp_pool uses the identical commands as all other Resource-Update actions. | |||||||||||||||||||||||||||||||||||||
URL | /api/v1/api.php?target=resource& action=update& meta[type]=dhcp_pool& meta[name]=Another Test& fields[_dhcp_type][]=subnet& fields[_dhcp_pool_attributes][]={"mac":"", "rangeStart":"10.10.10.4", "rangeEnd":"10.10.10.5", "freeLines":3, "freeLine1":"example1", "freeLine2":"example2", "freeLine3":"example3"}&fields[_dhcp_ip_id][]=92430&meta[id]=2165 | |||||||||||||||||||||||||||||||||||||
Returns | Examples:
Return Detail:
Attributes:
|
delete a DHCP Pool | |||||
---|---|---|---|---|---|
Description | To delete a DHCP Pool, use the standard Resource-Delete functionality | ||||
URL | /api/v1/api.php?target=resource&action=delete&id=2165 | ||||
Returns | Examples:
|
assigning an IP address or blocks to a DHCP Pool | |||||
---|---|---|---|---|---|
Description | Assigning IP addresses or blocks to a DHCP Pool resource removes them from the available pool so they cannot be assigned out again. This procedure uses all the standard IPAM assignment functions, so long as the resource assigned from is the DHCP Available resource. | ||||
URL | /api/v1/api.php?target=ipam&action=smartAssign&resourceId=2162&type=ipv4&mask=31&rir=1918&assignedResourceId=1282 | ||||
Returns | Examples:
Return Detail: For a detailed breakdown of this endpoint's return data, please see the IPAM documentation. |
get all DHCP Pool linkages | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | The association between DHCP Pools and DHCP Modules belongs to the Resource Linkage family of endpoints. The 'relation' field should be set to the 'dhcpPoolLink' type to pull only DHCP Pool linkage information. | ||||||||||||||||||||||||||||||||||||||||
URL | /api/v1/api.php?target=resource&action=getLink&relation=dhcpPoolLink | ||||||||||||||||||||||||||||||||||||||||
Returns | Examples:
Return Detail:
Meta Attributes:
Optional Attributes:
|
add a new DHCP Pool linkage | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | Adds a new link between a DHCP Pool and a dhcp_module resource. A single pool can be linked to many dhcp_modules, and a single dhcp_module can have any number of linked pools. | ||||||||||||||||
URL | /api/v1/api.php?target=resource&action=addLink&resource_id1=1292&resource_id2=2162&relation=dhcpPoolLink | ||||||||||||||||
Returns | Examples:
Data Detail:
|
delete DHCP Pool linkages | |||||
---|---|---|---|---|---|
Description | Deletes a link between a dhcp_module and a dhcp_pool. Uses the standard Resource Linkage endpoints. | ||||
URL | /api/v1/api.php?target=resource&action=deleteLink&id=22 | ||||
Returns | Examples:
|
push a DHCP config | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Description | Builds a DHCP configuration from the attributes assigned to a dhcp_module and all of the linked dhcp_pools. Pushes that config to the configured DHCP server, tests it against the config parsing function, then restarts the server with the new configuration. | ||||||||||
URL | /api/v1/api.php?target=dhcp&action=push&id=1292 | ||||||||||
Returns | Examples:
Data Detail
|
DHCP search | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | Searches DHCP information by name, mac, or IP. | ||||||||||||||||||||||||||||||||||||||||
URL | /api/v1/api.php?target=dhcp&action=search&searchType=name&searchValue=Blah /api/v1/api.php?target=dhcp&action=search&searchType=mac&searchValue=22: /api/v1/api.php?target=dhcp&action=search&searchType=ip&searchValue=13.0.0.255 | ||||||||||||||||||||||||||||||||||||||||
Returns | Examples:
Return Detail
Attributes
| ||||||||||||||||||||||||||||||||||||||||
Required Parameters |
| ||||||||||||||||||||||||||||||||||||||||
Optional Parameters |
|
_dhcp_attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | The _dhcp_attributes data attribute holds the specific settings used to generate a DHCP configuration file, place it on a server via SCP, and restart that server via a SSH session. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Example: | {"type":"ISC", "notes":"notes here", "username":"username", "port":"22", "config_test":"/etc/init.d/dhcpd configtest", "server_stop":"/etc/init.d/dhcpd stop", "server_start":"/etc/init.d/dhcpd start", "config_path":"/tmp/dhcpd.conf", "option_routers":"", "option_domain_name_servers":"", "option_domain_name":"", "authoritative":"1", "default_lease_time":"600", "max_lease_time":"7200", "local_port":"67", "log_facility":"local7", "password":"", "server_ip":"10.0.0.0", "freeLines":0} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Data Description
|
_dhcp_pool_attributes | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | A JSON-encoded string containing all the specific configuration parameters which govern this DHCP Pool. | ||||||||||||||||||
Example: | {"mac":"ab:cc:de:ff:aa:bc","rangeStart":"13.0.0.0","rangeEnd":"13.0.0.255","freeLines":1,"freeLines1":"free line"} | ||||||||||||||||||
Data Description
|