Skip to content

Commit

Permalink
Support DNS-over-TLS in systemd-resolve configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Hollensbe <[email protected]>
  • Loading branch information
erikh committed Mar 8, 2022
1 parent 04f19d4 commit 9a07a25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type templateScaffold struct {
DNS []string
DNSSearch string
MagicComment string
DNSOverTLS bool
}

// wrapped openapi client. should probably be replaced with a code generator in
Expand Down Expand Up @@ -71,6 +72,7 @@ func main() {
// two flags for the CLI auto-restart and reconcile are defaulted to true, so you rarely need them.
autoRestartFlag := flag.Bool("auto-restart", true, "Automatically restart systemd-resolved when things change")
reconcileFlag := flag.Bool("reconcile", true, "Automatically remove left networks from systemd-networkd configuration")
dnsOverTLSFlag := flag.Bool("dns-over-tls", true, "Automatically prefer DNS-over-TLS. Requires ZeroNSd v0.4 or better")
flag.Parse()

if os.Geteuid() != 0 {
Expand Down Expand Up @@ -201,6 +203,7 @@ func main() {
DNS: *network.Dns.Servers,
DNSSearch: strings.Join(searchkeys, " "),
MagicComment: magicComment,
DNSOverTLS: *dnsOverTLSFlag,
}

buf := bytes.NewBuffer(nil)
Expand Down
3 changes: 3 additions & 0 deletions template.network
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ DHCP=no
{{ range $key := .DNS -}}
DNS={{ $key }}
{{ end -}}
{{ if .DNSOverTLS -}}
DNSOverTLS=yes
{{ end -}}
Domains=~{{ .DNSSearch }}
ConfigureWithoutCarrier=true
KeepConfiguration=static

0 comments on commit 9a07a25

Please sign in to comment.