Skip to content

Initial implementation of DNS services#3678

Open
ipspace wants to merge 1 commit into
devfrom
module-services
Open

Initial implementation of DNS services#3678
ipspace wants to merge 1 commit into
devfrom
module-services

Conversation

@ipspace

@ipspace ipspace commented Jul 21, 2026

Copy link
Copy Markdown
Owner

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 services module (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.conf generation; 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

Comment on lines +1 to +3
#
# DHCP module
#
Comment on lines +1 to +2
# DHCP default settings and attributes
#
Comment on lines +37 to +38
cp_intf = svc_cache[srv_name].get('cp_intf',_routing.get_remote_cp_endpoint(srv_data))
svc_cache[srv_name].cp_intf = cp_intf
Comment on lines +7 to +9
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 %}
@ipspace

ipspace commented Jul 21, 2026

Copy link
Copy Markdown
Owner Author

@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:

  • The services.server.dns cannot be removed with a False value, so it cannot be disabled on dnsmasq (where I check only the attribute presence, not its value). I know exactly what to do, but it's getting late.
  • For whatever crazy reason, the "services" script on Linux containers is run with Ansible.
  • The feature support is using blacklisting, so you can either set the services.dns feature to True, or indicate which attributes are unsupported. That doesn't work well with netlab show modules -m services

Unknown unknowns:

  • The VRF support is more complex than I thought. Cisco IOS can define transport VRF (done, not tested), but also needs to enable DNS resolution for individual VRFs. No such option is available on Linux-based systems.
  • I have no idea how to do a DNS client integration test, apart from assuming that the "ping X" command works and that it displays the IP address in the output.

@snuffy22

snuffy22 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

So in terms of DNS checking, for what we would initially use for ping seems fine.

If you wanted to check PTR (Reverse DNS), Linux can do it with host cmd

If we start to implement other record types like CNAME / TXT / SRV etc
We'd need to use something like dig or nslookup to do more thorough checks.

@ipspace

ipspace commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

So in terms of DNS checking, for what we would initially use for ping seems fine.

That's the only cross-platform way I could think of that would test the DNS client.

If you wanted to check PTR (Reverse DNS), Linux can do it with host cmd

This would be needed to test the DNS server. Thank you!

If we start to implement other record types like CNAME / TXT / SRV etc We'd need to use something like dig or nslookup to do more thorough checks.

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.

@sdargoeuves

Copy link
Copy Markdown
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants