Skip to content

Commit 014fbc3

Browse files
committed
Add a static entry for the hostname to the slirp IP
This is done automatically by systemd-resolved, in which case this change is ignored, but on e.g. Alpine this is required to connect to the VM using its own hostname. Signed-off-by: Jan Dubois <[email protected]>
1 parent e3459c6 commit 014fbc3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/hostagent/hostagent.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type HostAgent struct {
4141
udpDNSLocalPort int
4242
tcpDNSLocalPort int
4343
instDir string
44+
instName string
4445
sshConfig *ssh.SSHConfig
4546
portForwarder *portForwarder
4647
onClose []func() error // LIFO
@@ -146,6 +147,7 @@ func New(instName string, stdout io.Writer, sigintCh chan os.Signal, opts ...Opt
146147
udpDNSLocalPort: udpDNSLocalPort,
147148
tcpDNSLocalPort: tcpDNSLocalPort,
148149
instDir: inst.Dir,
150+
instName: instName,
149151
sshConfig: sshConfig,
150152
portForwarder: newPortForwarder(sshConfig, sshLocalPort, rules),
151153
qExe: qExe,
@@ -252,6 +254,7 @@ func (a *HostAgent) Run(ctx context.Context) error {
252254
if *a.y.HostResolver.Enabled {
253255
hosts := a.y.HostResolver.Hosts
254256
hosts["host.lima.internal."] = qemuconst.SlirpGateway
257+
hosts[fmt.Sprintf("lima-%s.", a.instName)] = qemuconst.SlirpIPAddress
255258
dnsServer, err := dns.Start(a.udpDNSLocalPort, a.tcpDNSLocalPort, *a.y.HostResolver.IPv6, hosts)
256259
if err != nil {
257260
return fmt.Errorf("cannot start DNS server: %w", err)

0 commit comments

Comments
 (0)