DHCP¶
With the DHCP API you configure the Freebox dhcp server, and access its status.
DHCP Errors¶
When attempting to access the DHCP API, you may encounter the following errors:
| error_code | Description |
|---|---|
| inval | invalid argument |
| inval_netmask | invalid netmask |
| inval_ip_range | invalid IP range |
| inval_ip_range_net | IP range & netmask mismatch |
| inval_gw_net | gateway & netmask mismatch |
| exist | already exists |
| nodev | no such device |
| noent | no such entry |
| netdown | network is down |
| busy | device or resource busy |
DHCP Config Object¶
DHCP config has the following attributes:
-
DhcpConfig¶ -
enabledbool¶ Enable/Disable the DHCP server
-
sticky_assignbool¶ Always assign the same IP to a given host
-
gatewaystring Read-only¶ Gateway IP address
-
netmaskstring Read-only¶ Gateway subnet netmask
-
ip_range_startstring¶ DHCP range start IP
-
ip_range_endstring¶ DHCP range end IP
-
always_broadcastbool¶ Always broadcast DHCP responses
-
dns[] array of string¶ List of dns servers to include in DHCP reply
-
DHCP Configuration API¶
Get the current DHCP configuration¶
-
GET/api/v4/dhcp/config/¶ Returns the current
DhcpConfigExample request:
GET /api/v4/dhcp/config/ HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "enabled": true, "gateway": "192.168.1.254", "sticky_assign": true, "ip_range_end": "192.168.1.50", "netmask": "255.255.255.0", "dns": [ "192.168.1.254", "", "", "", "" ], "always_broadcast": false, "ip_range_start": "192.168.1.2" } }
Update the current DHCP configuration¶
-
PUT/api/v4/dhcp/config/¶ Update the current
DhcpConfigExample request:
PUT /api/v4/dhcp/config/ HTTP/1.1 Host: mafreebox.freebox.fr { "enabled": false, }
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "enabled": false, "gateway": "192.168.1.254", "sticky_assign": true, "ip_range_end": "192.168.1.50", "netmask": "255.255.255.0", "dns": [ "192.168.1.254", "", "", "", "" ], "always_broadcast": false, "ip_range_start": "192.168.1.2" } }
DHCP Static Lease Object¶
DHCP static lease have the following attributes
DHCP Static Lease API¶
Get the list of DHCP static leases¶
You can get the list ofDhcpStaticLeaseusing this API
-
GET/api/v4/dhcp/static_lease/¶ Example request:
GET /api/v4/dhcp/static_lease/ HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": [ { "mac": "00:DE:AD:B0:0B:55", "comment": "", "hostname": "Pc de r0ro", "id": "00:DE:AD:B0:0B:55", "host": { [ ... ] }, "ip": "192.168.1.1" }, { "mac": "00:DE:AD:B0:0B:69", "comment": "", "hostname": "Imprimante", "id": "00:DE:AD:B0:0B:69", "host": { [ ... ] }, "ip": "192.168.1.2" } ] }
Get a given DHCP static lease¶
You can get a specificDhcpStaticLeasewith its id
-
GET/api/v4/dhcp/static_lease/{id}¶ Example request:
GET /api/v4/dhcp/static_lease/00:DE:AD:B0:0B:55 HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "mac": "00:DE:AD:B0:0B:55", "comment": "", "hostname": "Pc de r0ro", "id": "00:DE:AD:B0:0B:55", "host": { [ ... ] }, "ip": "192.168.1.1" } }
Update DHCP static lease¶
You can update aDhcpStaticLeasewith this method
-
PUT/api/v4/dhcp/static_lease/{id}¶ Example request:
PUT /api/v4/dhcp/static_lease/00:DE:AD:B0:0B:55 HTTP/1.1 Host: mafreebox.freebox.fr
{ "comment": "Mon PC" }
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "mac": "00:DE:AD:B0:0B:55", "comment": "Mon PC", "hostname": "Pc de r0ro", "id": "00:DE:AD:B0:0B:55", "host": { [ ... ] }, "ip": "192.168.1.1" } }
Delete a DHCP static lease¶
Deletes theDhcpStaticLeasewith this id
-
DELETE/api/v4/dhcp/static_lease/{id}¶ Example request:
DELETE /api/v4/dhcp/static_lease/00:DE:AD:B0:0B:55 HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, }
Add a DHCP static lease¶
-
POST/api/v4/dhcp/static_lease/¶ Example request:
POST /api/v4/dhcp/static_lease/ HTTP/1.1 Host: mafreebox.freebox.fr
{ "ip": "192.168.1.222", "mac": "00:00:00:11:11:11" }
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "mac": "00:00:00:11:11:11", "comment": "", "hostname": "00:00:00:11:11:11", "id": "00:00:00:11:11:11", "ip": "192.168.1.222" } }
DHCP Dynamic Lease Object¶
DHCP dynamic lease have the following attributes
-
DhcpDynamicLease¶ -
macstring Read-only¶ Host mac address
-
hostnamestring Read-only¶ hostname matching the mac address
-
ipstring Read-only¶ IPv4 assigned to the host
-
lease_remainingint Read-only¶ time left before lease needs to be refreshed
-
assign_timetimestamp Read-only¶ timestamp of the lease first assignment
-
refresh_timetimestamp Read-only¶ timestamp of the last lease refresh
-
is_staticbool Read-only¶ is the lease static
-
Get the list of DHCP dynamic leases¶
You can get the list ofDhcpDynamicLeaseusing this API
-
GET/api/v4/dhcp/dynamic_lease/¶ Example request:
GET /api/v4/dhcp/dynamic_lease/ HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": [ { "mac": "13:37:00:00:01:03", "host": { … }, "refresh_time": 1364494443, "hostname": "iPhone r0ro", "assign_time": 1364494443, "lease_remaining": 42971, "is_static": false, "ip": "192.168.1.21" }, { "mac": "13:37:00:00:01:02", "host": { … }, "refresh_time": 1364493208, "hostname": "android r0ro", "assign_time": 1364482955, "lease_remaining": 41736, "is_static": false, "ip": "192.168.1.22" } ] }