network_dns
Manages DNS configuration (nameservers and domain name) on network devices over SSH. Supports Cisco IOS, NX-OS, IOS-XR, Arista EOS, and Juniper Junos.
SSH connection parameters (host, username, credential, port, device_type) are auto-injected by the gateway proxy.
Supported Device Types
cisco_ios-- Cisco IOS / IOS-XEcisco_nxos-- Cisco NX-OScisco_iosxr-- Cisco IOS-XRarista_eos-- Arista EOSjuniper_junos-- Juniper Junos
Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
server |
No* | -- | DNS server IP address |
domain |
No* | -- | Domain name for the device |
state |
Yes | -- | present to configure, absent to remove |
host |
Auto | -- | Target IP/hostname (auto-injected) |
port |
Auto | 22 |
SSH port (auto-injected) |
username |
Auto | -- | SSH user (auto-injected) |
credential |
Auto | -- | Password or SSH key (auto-injected) |
device_type |
Auto | -- | Device type (auto-injected from envoy config) |
*At least one of server or domain is required. Both can be specified together to configure nameserver and domain in a single resource.
Idempotency
The executor reads the device's running configuration and independently checks whether the DNS server and/or domain name are configured:
- On Cisco IOS/NX-OS/EOS: runs
show running-config | include name-server|domainand matchesname-server <ip>anddomain-name <name>lines. - On Cisco IOS-XR: runs
show running-config | include domainand matchesname-server <ip>anddomain name <name>lines. - On Juniper Junos: runs
show configuration systemand checks forname-server <ip>anddomain-name <name>.
Each field (server and domain) is evaluated independently. If both are specified and only one needs changing, only the necessary commands are issued. No commands are sent if the current configuration already matches the desired state for all specified fields.
Examples
Cisco IOS -- Set DNS server and domain
resources:
- name: dns-config
type: network_dns
server: "8.8.8.8"
domain: "example.com"
state: present
Arista EOS -- Add a nameserver
resources:
- name: dns-server
type: network_dns
server: "10.0.0.53"
state: present
Cisco IOS-XR -- Configure domain name
resources:
- name: domain-name
type: network_dns
domain: "corp.example.com"
state: present
Juniper Junos -- Remove a DNS server
resources:
- name: remove-old-dns
type: network_dns
server: "1.1.1.1"
state: absent