Skip to main content

Get

Get the DNS resolvers of an interface.

Reads the servers and the search domains of the interface: resolvectl on Linux, with resolv.conf on a host that has no resolvers per interface, such as a container, and scutil on macOS.

osapi client node dns get [flags]

Examples​

# An interface with servers and a domain
osapi client node dns get --target web-01 --interface-name osapi0

# A container with no resolvers per interface
osapi client node dns get --target web-01 --interface-name osapi0

# A Mac
osapi client node dns get --target web-01 --interface-name en0

Result​

An interface with servers and a domain, on one host:

$ osapi client node dns get --target web-01 --interface-name osapi0
Results:
  HOSTNAME  STATUS  SERVERS           SEARCH DOMAINS
  web-01    ok      1.1.1.1, 8.8.8.8  example.com

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

On each host, where one cannot run it:

$ osapi client node dns get --target _all --interface-name osapi0
Results:
  HOSTNAME  STATUS  SERVERS           SEARCH DOMAINS
  web-01    ok      1.1.1.1, 8.8.8.8  example.com
  web-02    ok      1.1.1.1, 8.8.8.8  example.com

  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": [
{
"hostname": "web-01",
"search_domains": ["example.com"],
"servers": ["1.1.1.1", "8.8.8.8"],
"status": "ok"
}
]
}

A container with no resolvers per interface, on one host:

$ osapi client node dns get --target web-01 --interface-name osapi0
Results:
  HOSTNAME  STATUS  SERVERS   SEARCH DOMAINS
  web-01    ok      10.0.0.2  svc.local

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

On each host, where one cannot run it:

$ osapi client node dns get --target _all --interface-name osapi0
Results:
  HOSTNAME  STATUS  SERVERS   SEARCH DOMAINS
  web-01    ok      10.0.0.2  svc.local
  web-02    ok      10.0.0.2  svc.local

  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": [
{
"hostname": "web-01",
"search_domains": ["svc.local"],
"servers": ["10.0.0.2"],
"status": "ok"
}
]
}

A Mac, on one host:

$ osapi client node dns get --target web-01 --interface-name en0
Results:
  HOSTNAME  STATUS  SERVERS  SEARCH DOMAINS
  web-01    ok      1.1.1.1

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

On each host, where one cannot run it:

$ osapi client node dns get --target _all --interface-name en0
Results:
  HOSTNAME  STATUS  SERVERS  SEARCH DOMAINS
  web-01    ok      1.1.1.1
  web-02    ok      1.1.1.1

  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": [
{
"hostname": "web-01",
"search_domains": [],
"servers": ["1.1.1.1"],
"status": "ok"
}
]
}

The command fails in these cases:

CallFlagsFails with
An interface the host does not have--interface-name eth9not found
An interface name that is not alphanumeric--interface-name "osapi0;reboot"InterfaceName

Permission​

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

Flags​

FlagDescriptionDefault
--interface-nameThe interface, such as eth0, or a fact such as @fact.interface.primary (required)
-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.