Skip to content

Commit

Permalink
Fix the order of dhcpcd arguments for static DNS config
Browse files Browse the repository at this point in the history
For some strange reason the order of dhcpcd arguments
"domain_name_servers" and "domain_name" matters. In fact, domain name
should be configured first, otherwise the list of DNS servers is not
applied (or maybe gets reset?). I couldn't find the root cause for this
odd behaviour in the dhcpcd source code or any explanation in the
documentation. I decided to at least report the issue:
NetworkConfiguration/dhcpcd#184

Signed-off-by: Milan Lenco <milan@zededa.com>
  • Loading branch information
milan-zededa authored and eriknordmark committed Feb 7, 2023
1 parent a116453 commit 90b74de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/pillar/dpcreconciler/genericitems/dhcpcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ func (c *DhcpcdConfigurator) dhcpcdArgs(config types.DhcpConfig) (op string, arg
for _, dns := range config.DnsServers {
dnsServers = append(dnsServers, dns.String())
}
if config.DomainName != "" {
args = append(args, "--static",
fmt.Sprintf("domain_name=%s", config.DomainName))
}
if len(dnsServers) > 0 {
// dhcpcd uses a very odd space-separation for multiple DNS servers.
// For manual invocation one must be very careful to not forget
Expand All @@ -308,10 +312,6 @@ func (c *DhcpcdConfigurator) dhcpcdArgs(config types.DhcpConfig) (op string, arg
fmt.Sprintf("domain_name_servers=%s",
strings.Join(dnsServers, " ")))
}
if config.DomainName != "" {
args = append(args, "--static",
fmt.Sprintf("domain_name=%s", config.DomainName))
}
if config.NtpServer != nil && !config.NtpServer.IsUnspecified() {
args = append(args, "--static",
fmt.Sprintf("ntp_servers=%s",
Expand Down

0 comments on commit 90b74de

Please sign in to comment.