Initial implementation of DNS services#3678
Conversation
Includes: * New 'services' module with baseline DNS and syslog settings * DNS server on dnsmasq * DNS client on IOS, FRR containers, and Linux containers * Coverage and integration tests * Documentation
There was a problem hiding this comment.
Pull request overview
This PR introduces an initial services module focused on DNS (client + dnsmasq-based server) and lays the groundwork for additional network services (syslog, etc.) across supported platforms.
Changes:
- Adds a new
servicesmodule (schema + transform) that resolves service server node names into per-node IPv4/IPv6 server address lists. - Extends device/provider templates to configure DNS behavior (IOS DNS client config; container
/etc/resolv.confgeneration; dnsmasq server config). - Adds/updates documentation plus integration/coverage/error fixtures and expected topology outputs to reflect the new module behavior.
Reviewed changes
Copilot reviewed 34 out of 43 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/topology/expected/vlan-routed-vrf.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/vlan-routed-multiprovider.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/vlan-access-single.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/vlan-access-links.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/stp.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/stp-port-type.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/multiserver-explicit.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/libvirt-clab-complex.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/group-ansible-variables.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/dhcp-vlan.yml | Expected topology updated for services module + dnsmasq service/hosts/resolv files |
| tests/topology/expected/dhcp-server-on-segment.yml | Expected topology updated for services module + dnsmasq service/hosts/resolv files |
| tests/topology/expected/components.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/clab-attributes.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/topology/expected/bridge-module-attr.yml | Expected topology updated with /etc/resolv.conf bind mounts |
| tests/integration/services/x-01-dns-client.yml | Integration test topology added for DNS client configuration |
| tests/errors/module-missing-prerequisite.log | Error fixture updated to include services in valid module list |
| tests/errors/invalid-module.log | Error fixture updated to include services in valid module list |
| tests/coverage/input/svc-server.yml | Coverage input added for service-server resolution behavior |
| tests/coverage/expected/svc-server.yml | Coverage expected output added for resolved DNS server addresses |
| tests/coverage/expected/device-node-defaults.yml | Coverage expected output updated with /etc/resolv.conf bind mounts |
| tests/coverage/expected/device-module-defaults.yml | Coverage expected output updated with /etc/resolv.conf bind mounts |
| tests/coverage/errors/validate-list.log | Coverage error fixture updated to include services in valid module list |
| tests/coverage/errors/svc-errors.yml | Coverage error topology added to exercise services-module validation |
| tests/coverage/errors/svc-errors.log | Coverage error log fixture added for services-module failures |
| netsim/templates/provider/clab/linux/resolv.j2 | Provider template added to render /etc/resolv.conf via shared include |
| netsim/templates/provider/clab/linux/hosts.j2 | Provider hosts template adjusted to support DNS-based name resolution behavior |
| netsim/templates/provider/clab/frr/resolv.j2 | Provider template added to render /etc/resolv.conf via shared include |
| netsim/modules/services.yml | New services module schema/defaults (DNS + syslog) |
| netsim/modules/services.py | New services module transform logic (feature checks, server resolution, VRF checks) |
| netsim/devices/none.yml | Adds services feature flags to the none device model |
| netsim/devices/linux.yml | Enables clab resolv template and marks transport_vrf unsupported for Linux containers |
| netsim/devices/ios.yml | Enables services DNS client feature on IOS |
| netsim/devices/frr.yml | Enables clab resolv template and marks transport_vrf unsupported for FRR containers |
| netsim/daemons/dnsmasq/services.j2 | Dummy services template to avoid configuring services during netlab initial for dnsmasq |
| netsim/daemons/dnsmasq/dnsmasq.j2 | Enhances dnsmasq config to support DNS server mode and forwarders |
| netsim/daemons/dnsmasq.yml | Declares dnsmasq device supports services DNS server and adds services daemon_config |
| netsim/ansible/templates/services/linux.j2 | Placeholder services config template for Linux |
| netsim/ansible/templates/services/ios.j2 | IOS services template added to configure DNS client |
| netsim/ansible/templates/services/frr.j2 | FRR services template added (including VM-only resolv.conf creation) |
| netsim/ansible/templates/initial/linux/resolv.j2 | Adds a reusable resolv.conf template |
| netsim/ansible/templates/initial/ios.j2 | Adjusts IOS initial host mapping generation behavior when DNS is in use |
| docs/module/services.md | New documentation for services module + DNS parameters/support matrix |
| docs/module-reference.md | Adds services module to module reference index |
| # | ||
| # DHCP module | ||
| # |
| # DHCP default settings and attributes | ||
| # |
| cp_intf = svc_cache[srv_name].get('cp_intf',_routing.get_remote_cp_endpoint(srv_data)) | ||
| svc_cache[srv_name].cp_intf = cp_intf |
| ip name-server {% if services.dns.vrf is defined | ||
| %}vrf {{ services.dns.vrf }} {% endif | ||
| %}{{ dns_srv_list|join(' ') }} |
| domain={{ netlab_domain }} | ||
| log-facility=/var/log/dnsmasq | ||
| log-dhcp | ||
| {% if services.server.dns is defined %} |
| ff02::2 ip6-allrouters | ||
| # | ||
| {% if _hosts_entries is defined %} | ||
| {% if (services.dns.ipv4 is not defined and services.dns.ipv6 is not defined) or services.server.dns is defined %} |
|
@sdargoeuves @DanPartelly @jbemmel @snuffy22 -- here's the initial implementation of DNS client (IOS, FRR, Linux) and server. It still has a few quirks, but I wanted to push it out to get feedback. Known open issues:
Unknown unknowns:
|
|
So in terms of DNS checking, for what we would initially use for If you wanted to check PTR (Reverse DNS), Linux can do it with If we start to implement other record types like CNAME / TXT / SRV etc |
That's the only cross-platform way I could think of that would test the DNS client.
This would be needed to test the DNS server. Thank you!
If someone wants to have that, they're most welcome to deploy something like BIND in a custom Linux container, and write a template (or a few of them) to generate a proper zone file. I'm not going there (yet 😜), the goal (for the moment) is to get rid of tons of ip host (or equivalent) commands in the device configuration. |
|
I was missing a few pieces to this puzzle. Do I understand correctly that the current plan is to use the dns server (dnsmasq) and its /etc/hosts file, which is the equivalent for all the ip host we would see on the network devices, to respond to DNS queries? |
Includes: