Skip to content

Commit df25c45

Browse files
authored
Merge pull request #217 from rancher-sandbox/resolv.conf
Add manage_resolv_conf to cloud-init
2 parents 62159c9 + 3b4533f commit df25c45

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

pkg/cidata/cidata.TEMPLATE.d/user-data

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,17 @@ write_files:
3030
owner: root:root
3131
path: /var/lib/cloud/scripts/per-boot/00-lima.boot.sh
3232
permissions: '0755'
33+
34+
{{- if .DNSAddresses }}
35+
# This has no effect on systems using systemd-resolved, but is used
36+
# on e.g. Alpine to set up /etc/resolv.conf on first boot.
37+
38+
manage_resolv_conf: true
39+
40+
resolv_conf:
41+
nameservers:
42+
{{- range $ns := $.DNSAddresses }}
43+
- {{$ns}}
44+
{{- end }}
45+
- {{.SlirpDNS}}
46+
{{- end }}

pkg/cidata/cidata.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML) error {
5353
Containerd: Containerd{System: *y.Containerd.System, User: *y.Containerd.User},
5454
SlirpNICName: qemuconst.SlirpNICName,
5555
SlirpGateway: qemuconst.SlirpGateway,
56+
SlirpDNS: qemuconst.SlirpDNS,
5657
Env: y.Env,
5758
}
5859

pkg/cidata/template.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type TemplateArgs struct {
3737
Networks []Network
3838
SlirpNICName string
3939
SlirpGateway string
40+
SlirpDNS string
4041
Env map[string]*string
4142
DNSAddresses []string
4243
}

pkg/qemu/qemuconst/qemuconst.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ const (
55
// CIDR is intentionally hardcoded to 192.168.5.0/24, as each of QEMU has its own independent slirp network.
66
SlirpNetwork = "192.168.5.0/24"
77
SlirpGateway = "192.168.5.2"
8+
SlirpDNS = "192.168.5.3"
89
SlirpIPAddress = "192.168.5.15"
910
)

0 commit comments

Comments
 (0)