Skip to main content

List

List the network interfaces of the host.

Reads each interface but the loopback, in the order of its index: /sys/class/net and ip on Linux, ifconfig and netstat on macOS. dhcp4 is true when a route of the interface has proto dhcp, and primary when it has the default route.

osapi client node interface list [flags]

Examples​

# A Linux host
osapi client node interface list --target web-01

# A Mac
osapi client node interface list --target web-01

Result​

A Linux host, on one host:

$ osapi client node interface list --target web-01
Results:
  HOSTNAME  STATUS  NAME  STATE  MAC                MTU   IPV4      IPV6         ADDRESSES                                                DHCP4  PRIMARY
  web-01    ok      eth0  up     52:54:00:12:34:56  1500  10.0.0.5  2001:db8::5  10.0.0.5/24, 2001:db8::5/64, fe80::5054:ff:fe12:3456/64  yes    yes

  1 host: 1 ok   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

On each host, where one cannot run it:

$ osapi client node interface list --target _all
Results:
  HOSTNAME  STATUS  NAME  STATE  MAC                MTU   IPV4      IPV6         ADDRESSES                                                DHCP4  PRIMARY
  web-01    ok      eth0  up     52:54:00:12:34:56  1500  10.0.0.5  2001:db8::5  10.0.0.5/24, 2001:db8::5/64, fe80::5054:ff:fe12:3456/64  yes    yes
  web-02    ok      eth0  up     52:54:00:12:34:56  1500  10.0.0.5  2001:db8::5  10.0.0.5/24, 2001:db8::5/64, fe80::5054:ff:fe12:3456/64  yes    yes

  3 hosts: 2 ok, 1 skipped   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

Details:
  mac-01  skipped  operation not supported on this OS family

With --json, the API's response:

{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"addresses": [
"10.0.0.5/24",
"2001:db8::5/64",
"fe80::5054:ff:fe12:3456/64"
],
"dhcp4": true,
"hostname": "web-01",
"ipv4": "10.0.0.5",
"ipv6": "2001:db8::5",
"mac": "52:54:00:12:34:56",
"mtu": 1500,
"name": "eth0",
"primary": true,
"state": "up",
"status": "ok"
}
]
}

A Mac, on one host:

$ osapi client node interface list --target web-01
Results:
  HOSTNAME  STATUS  NAME  STATE  MAC                MTU   IPV4          IPV6  ADDRESSES        DHCP4  PRIMARY
  web-01    ok      en0   up     3c:22:fb:00:00:01  1500  192.168.0.40        192.168.0.40/24  no     yes

  1 host: 1 ok   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

On each host, where one cannot run it:

$ osapi client node interface list --target _all
Results:
  HOSTNAME  STATUS  NAME  STATE  MAC                MTU   IPV4          IPV6  ADDRESSES        DHCP4  PRIMARY
  web-01    ok      en0   up     3c:22:fb:00:00:01  1500  192.168.0.40        192.168.0.40/24  no     yes
  web-02    ok      en0   up     3c:22:fb:00:00:01  1500  192.168.0.40        192.168.0.40/24  no     yes

  3 hosts: 2 ok, 1 skipped   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

Details:
  mac-01  skipped  operation not supported on this OS family

With --json, the API's response:

{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"addresses": ["192.168.0.40/24"],
"dhcp4": false,
"hostname": "web-01",
"ipv4": "192.168.0.40",
"ipv6": "",
"mac": "3c:22:fb:00:00:01",
"mtu": 1500,
"name": "en0",
"primary": true,
"state": "up",
"status": "ok"
}
]
}

Permission​

It needs the interface:read permission. osapi controller role get --name <role> shows what a role grants.

Flags​

FlagDescriptionDefault
-T, --targetTarget: _all, _any, hostname, or label (group:web.dev)_all

Global flags​

FlagDescriptionDefault
-d, --debugEnable or disable debug mode
-j, --jsonEnable JSON output
-f, --osapi-filePath to config file; without one at the default path, osapi runs on the defaults/etc/osapi/osapi.yaml
--urlBase URL the CLI client connects to (controller.client.url)https://localhost:8080

Output tells how the result is printed, and what --json gives.