Skip to content

Commit

Permalink
fix: Update DNS behavior for NetworkManager interfaces
Browse files Browse the repository at this point in the history
If DNS information is added to a NetworkManager managed interface where
the given protocol family is disabled, NetworkManager will be unable to
activate the interface. This seems like a potential bug in NetworkManager
but this fix should work around this condition which can arise in the case
of bonded interfaces where the bond members have no IP information.
  • Loading branch information
jcmoore3 committed Jul 8, 2024
1 parent 0af459e commit 0510760
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cloudinit/net/network_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def _add_nameserver(self, dns: str) -> None:
Extends the ipv[46].dns property with a name server.
"""
family = "ipv6" if is_ipv6_address(dns) else "ipv4"
if self.config.has_section(family):
if self.config.has_section(family) \
and self._get_config_option(family, "method") != "disabled":
self._set_default(family, "dns", "")
self.config[family]["dns"] = self.config[family]["dns"] + dns + ";"

Expand All @@ -248,7 +249,8 @@ def _add_dns_search(self, dns_search: List[str]) -> None:
Extends the ipv[46].dns-search property with a name server.
"""
for family in ["ipv4", "ipv6"]:
if self.config.has_section(family):
if self.config.has_section(family) \
and self._get_config_option(family, "method") != "disabled":
self._set_default(family, "dns-search", "")
self.config[family]["dns-search"] = (
self.config[family]["dns-search"]
Expand Down

0 comments on commit 0510760

Please sign in to comment.