How to get or set the configuration

Introduction

Use the Configuration call to get the current configuration, or make changes to the configuration.

Usage

The configuration contains security sensitive information (e.g. Wi-Fi password), so make sure you obtain a valid session ID first, see How to authenticate to the API. It goes without saying that changing the configuration requires authentication too.

Refer to Introduction for the explanation of the parameters.

πŸ“˜

TIP

Let's say you want to programmatically query if the firewall allows devices to access the internet or change the setting, but do not know what this setting is called.

Go to Fleet Manager and make sure the configuration is in sync with the device. Navigate to Network > Firewall and toggle Allow access to the internet. This will trigger a configuration difference, because the configuration in IXON Cloud is different from the configuration on the IXrouter. Instead of choosing the default Push config to device to resolve the conflict, click on the small upside down triangle and choose See differences. This will show you the configuration difference in detail and in this case it will tell you that the following changed:

- lan.forward_lan_wan_private=false
+ lan.forward_lan_wan_private=true 

From that you can deduce that the ixrouter.lan.forward_lan_wan_private key corresponds to the Allow access to the internet setting in Fleet Manager.

Get

Use the get method to obtain the current configuration:

curl --request POST \
     --url "192.168.140.1/ubus" \
     --data '
     {
         "jsonrpc": "2.0",
         "id": 1,
         "method": "call",
         "params": [
             "0a3e1036df206a33fcd6573a524c1ef2",
             "ixon.ui.configuration",
             "get",
             {}
         ]
     }'
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        0,
        {
            "ixrouter": {
                "display": {
                    "lock_enable": "false"
                },
                "wan": {
                    "multiwan_policy": "eth_wifi_cell",
                    "wlan_ssid": "IXON Guest",
                    "3g_mtu": "1200",
                    "wlan_track_interval": "5",
                    "wan_track_ip": [
                        "8.8.8.8",
                        "8.8.4.4",
                        "208.67.222.222",
                        "208.67.220.220"
                    ],
                    "wlan_track_ip": [
                        "8.8.8.8",
                        "8.8.4.4",
                        "208.67.222.222",
                        "208.67.220.220"
                    ],
                    "3g_apn": "internet",
                    "wlan_key": "|REDACTED|",
                    "ixapi_account_id": "9397-4731-1785-1293-4413",
                    "3g_track_ip": [
                        "8.8.8.8",
                        "8.8.4.4",
                        "208.67.222.222",
                        "208.67.220.220"
                    ],
                    "wan_track_interval": "5",
                    "ip_use_dhcp": "true",
                    "3g_pincode": "|REDACTED|",
                    "3g_track_interval": "5"
                },
                "steward": {
                    "config": "|REDACTED|"
                },
                "lan": {
                    "additional_subnet": [
                        "192.168.160.0/24,192.168.140.125",
                        "192.168.180.0/24,192.168.140.150"
                    ],
                    "gateway_less_routing": "true",
                    "wlan_enable": "false",
                    "dhcp_range": "100,150",
                    "ip_address": "192.168.140.1",
                    "ip_netmask": "255.255.255.0",
                    "forward_lan_wan_private": "false",
                    "wlan_ssid": "IXON_21050005",
                    "wlan_channel": "11",
                    "wlan_key": "|REDACTED|",
                    "forward_lan_wan_public": "false"
                }
            }
        }
    ]
}

Set

Use the set method to obtain the current configuration.

Let's say you would like to change the LAN IP address of the device to 192.168.27.1. The easiest way to see what key to use is to simply get the current configuration and look at the output. For settings that are difficult to find, use the TIP above to find out the corresponding key. In this case, the key is ixrouter.lan.ip_address:

curl --request POST \
     --url "192.168.140.1/ubus" \
     --data '
     {
         "jsonrpc": "2.0",
         "id": 1,
         "method": "call",
         "params": [
             "0a3e1036df206a33fcd6573a524c1ef2",
             "ixon.ui.configuration",
             "set",
             {
                 "configuration": {
                     "ixrouter": {
                         "lan": {
                             "ip_address": "192.168.27.1"
                         }
                     }
                 }
             }
         ]
     }'
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        0
    ]
}

πŸ“˜

TIP

Making a change to the device's network configuration causes a network restart, so it may take some time before your request returns a response.

🚧

WARNING

Do not forget to start making subsequent requests to the new IP address if you change the LAN IP address of the IXrouter. In this case 192.168.27.1/ubus instead of 192.168.140.1/ubus.