@@ -27,6 +27,10 @@ import (
2727 "k8s.io/minikube/pkg/minikube/out"
2828)
2929
30+ // primaryInterface is the main network interface in the buildroot-based minikube ISO.
31+ // Update this if the ISO switches to a different distro or naming scheme.
32+ const primaryInterface = "eth0"
33+
3034// configureDNS configures static DNS servers on the VM, overriding DHCP-provided
3135// DNS settings. This fixes DNS resolution on managed Macs where network extensions
3236// block DNS traffic from the VM bridge to the host resolver.
@@ -54,10 +58,10 @@ func configureDNS(runner command.Runner, servers []netip.Addr) {
5458 dnsServers := strings .Join (values , " " )
5559
5660 script := fmt .Sprintf (`
57- resolvectl dns eth0 %s
58- resolvectl domain eth0 "~."
61+ resolvectl dns %s %s
62+ resolvectl domain %s "~."
5963resolvectl flush-caches
60- ` , dnsServers )
64+ ` , primaryInterface , dnsServers , primaryInterface )
6165
6266 cmd := exec .Command ("sudo" , "bash" , "-o" , "errexit" , "-c" , script )
6367 if _ , err := runner .RunCmd (cmd ); err != nil {
@@ -68,3 +72,19 @@ resolvectl flush-caches
6872
6973 klog .Infof ("Configured static DNS servers: %s" , dnsServers )
7074}
75+
76+ // configureMDNS enables mDNS (.local address resolution) on the VM by configuring
77+ // systemd-resolved. This allows the guest to resolve other machines on the local
78+ // network that advertise via mDNS.
79+ func configureMDNS (runner command.Runner , enabled bool ) {
80+ if ! enabled {
81+ return
82+ }
83+ cmd := exec .Command ("sudo" , "resolvectl" , "mdns" , primaryInterface , "yes" )
84+ if _ , err := runner .RunCmd (cmd ); err != nil {
85+ klog .Warningf ("Failed to enable mDNS on %s: %v" , primaryInterface , err )
86+ out .WarningT ("Failed to enable mDNS on {{.iface}}" , out.V {"iface" : primaryInterface })
87+ return
88+ }
89+ klog .Infof ("Enabled mDNS on %s" , primaryInterface )
90+ }
0 commit comments