diff --git a/ocaml/networkd/bin/network_server.ml b/ocaml/networkd/bin/network_server.ml index dee5edb098..45d1251c5d 100644 --- a/ocaml/networkd/bin/network_server.ml +++ b/ocaml/networkd/bin/network_server.ml @@ -737,11 +737,21 @@ module Interface = struct ) ) -> update_config name c ; exec (fun () -> - (* Old configs used empty dns lists to mean none, keep that - behaviour instead of writing an empty resolv.conf *) match dns with - | None | Some ([], []) -> + | None -> () + | Some ([], []) -> ( + match (ipv4_conf, ipv6_conf) with + | Static4 _, _ | _, Static6 _ | _, Autoconf6 -> + (* clear DNS for Static mode *) + set_dns () dbg ~name ~nameservers:[] ~domains:[] + | _ -> + (* networkd.db in v25.28.0 and before stores empty + dns lists for DHCP mode, this case is to keep + resolv.conf intact when Toolstack update from + version earlier than v25.28.0 *) + () + ) | Some (nameservers, domains) -> set_dns () dbg ~name ~nameservers ~domains ) ; diff --git a/ocaml/xapi/nm.ml b/ocaml/xapi/nm.ml index fbc37a5fed..7f324f68ef 100644 --- a/ocaml/xapi/nm.ml +++ b/ocaml/xapi/nm.ml @@ -638,8 +638,10 @@ let bring_pif_up ~__context ?(management_interface = false) (pif : API.ref_PIF) in let dns = match (static, rc.API.pIF_DNS) with - | false, _ | true, "" -> + | false, _ -> None + | true, "" -> + Some ([], []) | true, pif_dns -> let nameservers = List.map Unix.inet_addr_of_string