diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md
index d84487ab92c..cd2f2b0e397 100644
--- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md
+++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md
@@ -387,17 +387,21 @@ ip domain-list domain2.local
| 2001:db8::2 | - | 0 |
| 2001:db8::1 | mgmt | - |
| 2001:db8::2 | TEST | 3 |
+| 2001:db8::1 | TEST | 3 |
+| 10.10.128.11 | TEST | 2 |
#### IP Name Servers Device Configuration
```eos
-ip name-server 10.10.128.10
+ip name-server vrf default 10.10.128.10
+ip name-server vrf default 10.10.129.10
+ip name-server vrf default 2001:db8::1
+ip name-server vrf default 2001:db8::2
ip name-server vrf mgmt 10.10.128.10
-ip name-server vrf TEST 10.10.128.10 priority 3
-ip name-server 10.10.129.10 priority 0
-ip name-server 2001:db8::1
ip name-server vrf mgmt 2001:db8::1
-ip name-server 2001:db8::2 priority 0
+ip name-server vrf TEST 10.10.128.11 priority 2
+ip name-server vrf TEST 10.10.128.10 priority 3
+ip name-server vrf TEST 2001:db8::1 priority 3
ip name-server vrf TEST 2001:db8::2 priority 3
```
diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg
index e213b30b800..945e104d3b2 100644
--- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg
+++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg
@@ -489,13 +489,15 @@ ip nat profile NAT-PROFILE-TEST-VRF vrf TEST
hostname hostname-set-via-hostname-var
ip domain lookup source-interface Loopback0
ip domain lookup vrf mgt source-interface Management0
-ip name-server 10.10.128.10
+ip name-server vrf default 10.10.128.10
+ip name-server vrf default 10.10.129.10
+ip name-server vrf default 2001:db8::1
+ip name-server vrf default 2001:db8::2
ip name-server vrf mgmt 10.10.128.10
-ip name-server vrf TEST 10.10.128.10 priority 3
-ip name-server 10.10.129.10 priority 0
-ip name-server 2001:db8::1
ip name-server vrf mgmt 2001:db8::1
-ip name-server 2001:db8::2 priority 0
+ip name-server vrf TEST 10.10.128.11 priority 2
+ip name-server vrf TEST 10.10.128.10 priority 3
+ip name-server vrf TEST 2001:db8::1 priority 3
ip name-server vrf TEST 2001:db8::2 priority 3
dns domain test.local
ip domain-list domain1.local
diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip-name-servers.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip-name-servers.yml
index 16da3fb0086..0cb7cb6992c 100644
--- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip-name-servers.yml
+++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip-name-servers.yml
@@ -25,3 +25,9 @@ ip_name_servers:
- ip_address: 2001:db8::2
vrf: TEST
priority: 3
+ - ip_address: 2001:db8::1
+ vrf: TEST
+ priority: 3
+ - ip_address: 10.10.128.11
+ vrf: TEST
+ priority: 2
diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/custom-structured-configuration.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/custom-structured-configuration.cfg
index af4faddd92a..b10f03aafad 100644
--- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/custom-structured-configuration.cfg
+++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/custom-structured-configuration.cfg
@@ -17,15 +17,15 @@ transceiver qsfp default-mode 4x10G
service routing protocols model multi-agent
!
hostname custom-structured-configuration
+ip name-server vrf MGMT 192.168.42.10
+ip name-server vrf MGMT 192.168.42.40
+ip name-server vrf MGMT 192.168.42.50
ip name-server vrf VRF1 192.168.42.1
-ip name-server vrf VRF2 192.168.42.1
ip name-server vrf VRF1 192.168.42.4
-ip name-server vrf VRF2 192.168.42.8
-ip name-server vrf MGMT 192.168.42.10
ip name-server vrf VRF1 192.168.42.10
-ip name-server vrf MGMT 192.168.42.40
+ip name-server vrf VRF2 192.168.42.1
+ip name-server vrf VRF2 192.168.42.8
ip name-server vrf VRF2 192.168.42.40
-ip name-server vrf MGMT 192.168.42.50
!
vrf instance MGMT
!
diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md
index 35e93124ad2..c3a47a6b9bf 100644
--- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md
+++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md
@@ -9,7 +9,7 @@
| -------- | ---- | -------- | ------- | ------------------ | ----------- |
| [ip_name_servers](## "ip_name_servers") | List, items: Dictionary | | | | |
| [ - ip_address](## "ip_name_servers.[].ip_address") | String | Required | | | IPv4 or IPv6 address for DNS server. |
- | [ vrf](## "ip_name_servers.[].vrf") | String | | | | VRF Name. |
+ | [ vrf](## "ip_name_servers.[].vrf") | String | | `default` | | VRF Name. |
| [ priority](## "ip_name_servers.[].priority") | Integer | | | Min: 0
Max: 4 | Priority value (lower is first). |
| [name_server](## "name_server") removed | Dictionary | | | | This key was removed. Support was removed in AVD version v5.0.0. Use ip_name_servers instead. |
@@ -22,7 +22,7 @@
- ip_address:
# VRF Name.
- vrf:
+ vrf:
# Priority value (lower is first).
priority:
diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-servers.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-servers.j2
index 182718cc7fc..b20cd04d0f0 100644
--- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-servers.j2
+++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-servers.j2
@@ -4,14 +4,24 @@
that can be found in the LICENSE file.
#}
{# eos - ip name servers #}
-{% for name_server in ip_name_servers | arista.avd.natural_sort('ip_address') %}
-{% set name_server_cli = "ip name-server" %}
-{% if name_server.vrf is arista.avd.defined %}
-{% set name_server_cli = name_server_cli ~ " vrf " ~ name_server.vrf %}
-{% endif %}
-{% set name_server_cli = name_server_cli ~ " " ~ name_server.ip_address %}
-{% if name_server.priority is arista.avd.defined %}
-{% set name_server_cli = name_server_cli ~ " priority " ~ name_server.priority %}
-{% endif %}
-{{ name_server_cli }}
-{% endfor %}
+{% if ip_name_servers is arista.avd.defined %}
+{% set all_name_servers = [] %}
+{% for name_server in ip_name_servers %}
+{% set server = {'ip_address':"",'priority': 0, 'vrf': 'default'} %}
+{% do server.update({'ip_address': name_server.ip_address}) %}
+{% if name_server.priority is arista.avd.defined %}
+{% do server.update({'priority': name_server.priority}) %}
+{% endif %}
+{% if name_server.vrf is arista.avd.defined %}
+{% do server.update({'vrf': name_server.vrf}) %}
+{% endif %}
+{% do all_name_servers.append(server) %}
+{% endfor %}
+{% for name_server in all_name_servers | arista.avd.natural_sort('ip_address') | arista.avd.natural_sort('vrf') | arista.avd.natural_sort('priority') %}
+{% if name_server.priority | int == 0 %}
+ip name-server vrf {{ name_server.vrf }} {{ name_server.ip_address }}
+{% else %}
+ip name-server vrf {{ name_server.vrf }} {{ name_server.ip_address }} priority {{ name_server.priority }}
+{% endif %}
+{% endfor %}
+{% endif %}
diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/__init__.py b/python-avd/pyavd/_eos_cli_config_gen/schema/__init__.py
index f35545f25db..64e274e2886 100644
--- a/python-avd/pyavd/_eos_cli_config_gen/schema/__init__.py
+++ b/python-avd/pyavd/_eos_cli_config_gen/schema/__init__.py
@@ -15750,11 +15750,20 @@ def __init__(
class IpNameServersItem(AvdModel):
"""Subclass of AvdModel."""
- _fields: ClassVar[dict] = {"ip_address": {"type": str}, "vrf": {"type": str}, "priority": {"type": int}, "_custom_data": {"type": dict}}
+ _fields: ClassVar[dict] = {
+ "ip_address": {"type": str},
+ "vrf": {"type": str, "default": "default"},
+ "priority": {"type": int},
+ "_custom_data": {"type": dict},
+ }
ip_address: str
"""IPv4 or IPv6 address for DNS server."""
- vrf: str | None
- """VRF Name."""
+ vrf: str
+ """
+ VRF Name.
+
+ Default value: `"default"`
+ """
priority: int | None
"""Priority value (lower is first)."""
_custom_data: dict[str, Any]
@@ -15765,7 +15774,7 @@ def __init__(
self,
*,
ip_address: str | UndefinedType = Undefined,
- vrf: str | None | UndefinedType = Undefined,
+ vrf: str | UndefinedType = Undefined,
priority: int | None | UndefinedType = Undefined,
_custom_data: dict[str, Any] | UndefinedType = Undefined,
) -> None:
diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml
index 90a7ac05177..c2f11dc0e52 100644
--- a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml
+++ b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml
@@ -5569,6 +5569,7 @@ keys:
vrf:
description: VRF Name.
type: str
+ default: default
convert_types:
- int
priority:
diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml
index 5d71dcdfe2b..da7a2ef21ee 100644
--- a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml
+++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml
@@ -18,6 +18,7 @@ keys:
vrf:
description: VRF Name.
type: str
+ default: default
convert_types:
- int
priority: