1. Home
  2. Docs
  3. HTTP API of NDI
  4. Network Configuration

Network Configuration

Module name: network

Basic URL: /api/v1/network/

Get current network configuration


API URL

/api/v1/network/get

Request

​ Method: GET/POST

​ Parameters: NONE

Response

Example:

{
    "result": "ok",
    "data": [
      {
        "device": "eth0",
        "state": "up",
        "ip": "192.168.2.160",
        "mask": "255.255.255.0",
        "mac": "68:3A:7F:8C:A7:96",
        "gw": "192.168.2.1",
        "dynamic": "y",
        "dns": "8.8.8.8; 4.4.4.4",

        "ip2": "192.168.100.168",
        "mask2": "255.255.255.0",
        "gw2": "",

        "ip3": "0.0.0.0",
        "mask3": "255.255.255.0",
        "gw3": ""
      }
    ],
    "data_size": 1
}

Data field description:

"data" is a JSON array, "data_size" is a field that help assist to describe "data" array size (you may not use it) .

Each item of the array means one network interface’s configuration:

Field Value Description
device [STRING] Device name of current network interface. pay attention this device name, it is the basis for you to modify the network configuration. it is said that when you modify the network configuration, you must specify the device name.
state [STRING] Current working status of the network:
up: The network is working fine
down: Disconnected because the network cable disconnected
disabled: Forbidden to use the network for other reasons
error: Network work failure
ip [STRING] Current IP address of network configuration. Note: If your network is configured with DHCP address, ip will show the current IP address obtained by DHCP ; and if the network is configured with a static IP address, ip will shows the static IP address that you set.
mask [STRING] Subnet mask of the current network (netmask)
mac [STRING] MAC address of current network card
gw [STRING] The default gateway of the current network (gateway). If it is not set yet, it may be "" (empty string) or "0.0.0.0"
dynamic [STRING] y: Start DHCP configuration
n: Use static IP address configuration
dns [STRING] current configured DNS server address. Separate multiple addresses with ‘;’.
ip2 [STRING] The second IP address of the device (also called Failsafe address). Because the modification of the main IP address of the device may occur error or cannot access the device due to forgotten, the Failsafe address allows you to configure a default, easy-to-remember IP. So, you can access and configure the device through the Failsafe address.

So, we suggest you not to modify ip2 (Failsafe address) as much as possible.

mask2 [STRING] Subnet mask of ip2 (netmask)
gw2 [STRING] The default gateway of ip2 (gateway). If not set, it may be "" (empty string) or "0.0.0.0"
ip3/mask3/gw3 [STRING] ip3/mask3/gw3 and ip2/mask2/gw2 have the similar meanings and uses. But you do not need to configure ip3 in most cases, We do not guarantee the validity of this parameter configuration.

Modify network configuration


Important note: The modification of the network configuration is a sensitive operation, the wrong configuration may lead to the device can not be normal access. Therefore, we remind you:

  • Regular network address modification, please try to finish through the Web UI of NDI device;
  • If it is unable to access due to network parameter is modified, you can restore to factory default settings by pressing the Reset button of the device.

API URL

/api/v1/network/set

Request

​ Method: GET/POST

Field Value Description
device [STRING], Required Specify the name of the network interface to modify. Please refer to 11.1 /api/v1/network/get description of the device parameter. This parameter is necessary.
dynamic [STRING], Optional y: use DHCP to get IP address. If dynamic="y",then ip, mask, gw, dns will make no sense
n: use static IP address
ip [STRING]Optional configure IP address
mask [STRING]Optional subnet mask (netmask)
mac [STRING]Optional if mac specified,MAC address of the current network card can be modified. Please pay attention:
1. You must provide a valid and effective MAC address;
2. Unless you are sure what you want to do, or please do not modify MAC address.
gw [STRING]Optional default gateway(gateway). specify "" (empty string) means no gateway configuration.
dns [STRING]Optional specify 0 or more DNS server address. Separate multiple addresses with ‘;’. "" (empty string) means no configuration.
ip2 [STRING]Optional configure Failsafe IP address. If you need to clear Failsafe address, please setup ip2 = "" (empty string)
mask2 [STRING]Optional subnet mask of Failsafe address (netmask)
gw2 [STRING]Optional default gateway which correspond to Failsafe address (gateway). specify "" (empty string) means no gateway configuration.
ip3/mask3/gw3 [STRING]Optional ip3/mask3/gw3 and ip2/mask2/gw2 have similar meanings and uses. But in most cases, you do not need configure ip3. We do not guarantee the validity of this parameter configuration

Response

Example:

{
    "result": "ok"
}

If execute successfully, it will return the message of result = "ok", or please refer to 1.3 for error message descriptions.

Note: You must use new IP address to access HTTP API if network address was modified and IP address was changed. The effectiveness of network address modification is usually <1s. If you specified IP address for DHCP acquisition, it depends on your actual network environment, the time to obtain a valid IP address is uncertain.

How can we help?