List
List the routes of an interface.
Reads the routes of the main table that go out of the interface: ip route on Linux, netstat on macOS. proto says where a route came from, such as dhcp, kernel or static. An interface with no routes has none; one the host does not have is not found.
osapi client node interface route list [flags]
Examples
# An interface with routes
osapi client node interface route list --target web-01 --name eth0
# An interface with no routes
osapi client node interface route list --target web-01 --name eth1
# A Mac
osapi client node interface route list --target web-01 --name en0
Result
An interface with routes, on one host:
$ osapi client node interface route list --target web-01 --name eth0 Results: HOSTNAME STATUS DESTINATION GATEWAY INTERFACE FAMILY METRIC PROTO SCOPE web-01 ok default 10.0.0.1 eth0 inet 100 dhcp web-01 ok 10.0.0.0/24 eth0 inet 0 kernel link web-01 ok 10.20.0.0/16 10.0.0.254 eth0 inet 50 static 1 host: 1 ok job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9
On each host, where one cannot run it:
$ osapi client node interface route list --target _all --name eth0 Results: HOSTNAME STATUS DESTINATION GATEWAY INTERFACE FAMILY METRIC PROTO SCOPE web-01 ok default 10.0.0.1 eth0 inet 100 dhcp web-01 ok 10.0.0.0/24 eth0 inet 0 kernel link web-01 ok 10.20.0.0/16 10.0.0.254 eth0 inet 50 static web-02 ok default 10.0.0.1 eth0 inet 100 dhcp web-02 ok 10.0.0.0/24 eth0 inet 0 kernel link web-02 ok 10.20.0.0/16 10.0.0.254 eth0 inet 50 static 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": [
{
"destination": "default",
"family": "inet",
"gateway": "10.0.0.1",
"hostname": "web-01",
"interface": "eth0",
"metric": 100,
"proto": "dhcp",
"scope": "",
"status": "ok"
},
{
"destination": "10.0.0.0/24",
"family": "inet",
"gateway": "",
"hostname": "web-01",
"interface": "eth0",
"metric": 0,
"proto": "kernel",
"scope": "link",
"status": "ok"
},
{
"destination": "10.20.0.0/16",
"family": "inet",
"gateway": "10.0.0.254",
"hostname": "web-01",
"interface": "eth0",
"metric": 50,
"proto": "static",
"scope": "",
"status": "ok"
}
]
}
An interface with no routes, on one host:
$ osapi client node interface route list --target web-01 --name eth1 Results: None.
On each host, where one cannot run it:
$ osapi client node interface route list --target _all --name eth1 Results: 1 host: 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": []
}
A Mac, on one host:
$ osapi client node interface route list --target web-01 --name en0 Results: HOSTNAME STATUS DESTINATION GATEWAY INTERFACE FAMILY METRIC PROTO SCOPE web-01 ok default 192.168.0.1 en0 inet 0 1 host: 1 ok job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9
On each host, where one cannot run it:
$ osapi client node interface route list --target _all --name en0 Results: HOSTNAME STATUS DESTINATION GATEWAY INTERFACE FAMILY METRIC PROTO SCOPE web-01 ok default 192.168.0.1 en0 inet 0 web-02 ok default 192.168.0.1 en0 inet 0 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": [
{
"destination": "default",
"family": "inet",
"gateway": "192.168.0.1",
"hostname": "web-01",
"interface": "en0",
"metric": 0,
"proto": "",
"scope": "",
"status": "ok"
}
]
}
The command fails in these cases:
| Call | Flags | Fails with |
|---|---|---|
| An interface the host does not have | --name eth9 | not found |
| A name that is not an interface name | --name "eth0;reboot" | Name |
Permission
It needs the interface:read permission.
osapi controller role get --name <role> shows what a role grants.
Flags
| Flag | Description | Default |
|---|---|---|
--name | The interface, such as eth0, or a fact such as @fact.interface.primary (required) | |
-T, --target | Target: _all, _any, hostname, or label (group:web.dev) | _all |
Global flags
| Flag | Description | Default |
|---|---|---|
-d, --debug | Enable or disable debug mode | |
-j, --json | Enable JSON output | |
-f, --osapi-file | Path to config file; without one at the default path, osapi runs on the defaults | /etc/osapi/osapi.yaml |
--url | Base URL the CLI client connects to (controller.client.url) | https://localhost:8080 |
Output tells how the result is printed, and what
--json gives.