Table Of Contents

Previous topic

Freeplug

Next topic

Ftp

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
enabled bool

Enable/Disable the DHCP server

sticky_assign bool

Always assign the same IP to a given host

gateway string Read-only

Gateway IP address

netmask string Read-only

Gateway subnet netmask

ip_range_start string

DHCP range start IP

ip_range_end string

DHCP range end IP

always_broadcast bool

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/v3/dhcp/config/

Returns the current DhcpConfig

Example request:

GET /api/v3/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/v3/dhcp/config/

Update the current DhcpConfig

Example request:

PUT /api/v3/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
DhcpStaticLease
id string

DHCP static lease object id

mac string

Host mac address

comment string

an optional comment

hostname string Read-only

hostname matching the mac address

ip string

IPv4 to assign to the host

host LanHost Read-only

LAN host information from LAN browser (refer to LanHost documentation)

DHCP Static Lease API

Get the list of DHCP static leases

You can get the list of DhcpStaticLease using this API
GET /api/v3/dhcp/static_lease/

Example request:

GET /api/v3/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 specific DhcpStaticLease with its id
GET /api/v3/dhcp/static_lease/{id}

Example request:

GET /api/v3/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 a DhcpStaticLease with this method
PUT /api/v3/dhcp/static_lease/{id}

Example request:

PUT /api/v3/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 the DhcpStaticLease with this id
DELETE /api/v3/dhcp/static_lease/{id}

Example request:

DELETE /api/v3/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/v3/dhcp/static_lease/

Example request:

POST /api/v3/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
mac string Read-only

Host mac address

hostname string Read-only

hostname matching the mac address

ip string Read-only

IPv4 assigned to the host

lease_remaining int Read-only

time left before lease needs to be refreshed

assign_time timestamp Read-only

timestamp of the lease first assignment

refresh_time timestamp Read-only

timestamp of the last lease refresh

is_static bool Read-only

is the lease static

host LanHost Read-only

LAN host information from LAN browser (refer to LanHost documentation)

Get the list of DHCP dynamic leases

You can get the list of DhcpDynamicLease using this API
GET /api/v3/dhcp/dynamic_lease/

Example request:

GET /api/v3/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"
        }
    ]
}