Skip to content

Enhance tailnet to (optionally) configure DNS records for peers. #14718

Closed

Description

@spikecurtis

Today, tailnet.Conn does not configure any DNS in Tailscale networking. In order to support a desktop native VPN to Coder workspaces, we should enhance tailnet.Conn (e.g. via the configMaps subcomponent) to be programmed with domain names and corresponding IP addresses to be served from the Tailscale DNS server.

This will allow us to eventually have client applications learn workspace agent names and IP addresses ( via #14716 ) and then program DNS entries for them into Tailscale.

In this increment, only IPv6 addresses need to be supported, and if enabled the Tailscale DNS service should respond on [fd60:627a:a42b::53]:53.

Activity

  1. assigned and unassigned on Sep 23, 2024
  2. spikecurtis commented on Sep 23, 2024

    @spikecurtis
    CollaboratorAuthor

    Here's what the DNS configuration looks like (taken from an experimental branch with hardcoded values), in configmaps.go

    // reconfig computes the correct wireguard config and calls the engine.Reconfig
    // with the config we have.  It is not intended for this to be called outside of
    // the updateLoop()
    func (c *configMaps) reconfig(nm *netmap.NetworkMap) {
    	cfg, err := nmcfg.WGCfg(nm, Logger(c.logger.Named("net.wgconfig")), netmap.AllowSingleHosts, "")
    	if err != nil {
    		// WGCfg never returns an error at the time this code was written.  If it starts, returning
    		// errors if/when we upgrade tailscale, we'll need to deal.
    		c.logger.Critical(context.Background(), "update wireguard config failed", slog.Error(err))
    		return
    	}
    
    	addrs := append([]netip.Prefix{}, nm.Addresses...)
    	rc := &router.Config{
    		LocalAddrs: addrs,
    		Routes:     []netip.Prefix{ServicePrefix},
    	}
    	err = c.engine.Reconfig(cfg, rc, &dns.Config{
    		Routes: map[dnsname.FQDN][]*dnstype.Resolver{
    			"coderlan.": nil,
    		},
    		Hosts: map[dnsname.FQDN][]netip.Addr{
    			"dogfood2.coderlan.": {netip.MustParseAddr("fd7a:115c:a1e0:4280:a0ad:1919:6552:9fe3")},
    		},
    		OnlyIPv6: true,
    	}, &tailcfg.Debug{})
    	if err != nil {
    		if errors.Is(err, wgengine.ErrNoChanges) {
    			return
    		}
    		c.logger.Error(context.Background(), "failed to reconfigure wireguard engine", slog.Error(err))
    	}
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

networking

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions