1
0
mirror of https://github.com/rancher/os.git synced 2025-09-17 15:40:47 +00:00

Network: configure nameservers from DHCP and cloud-config

If dns.override is set, use dns.nameservers from cloud-config over the ones set by DHCP. To reconfigure DNS just restart the network service.
This commit is contained in:
Ivan Mikushin
2015-11-30 16:06:21 +05:00
parent 94d4114172
commit a323c1bb02
4 changed files with 11 additions and 2 deletions

2
Godeps/Godeps.json generated
View File

@@ -368,7 +368,7 @@
},
{
"ImportPath": "github.com/rancher/netconf",
"Rev": "b9aeb623c8ef9551d79efec57ee059658c1ac89c"
"Rev": "02925e7cf5a0f0bb0aa5360ee260ef7378e5eff8"
},
{
"ImportPath": "github.com/ryanuber/go-glob",

View File

@@ -16,6 +16,7 @@ type InterfaceConfig struct {
}
type DnsConfig struct {
Override bool `yaml:"override"`
Nameservers []string `yaml:"nameservers,flow,omitempty"`
Search []string `yaml:"search,flow,omitempty"`
}

View File

@@ -7,6 +7,7 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/docker/libnetwork/resolvconf"
"github.com/rancher/netconf"
"github.com/rancher/os/cmd/cloudinit"
"github.com/rancher/os/config"
@@ -37,7 +38,13 @@ func Main() {
}
cloudinit.SetHostname(cfg) // ignore error
if err := netconf.ApplyNetworkConfigs(&cfg.Rancher.Network); err != nil {
log.Fatal(err)
log.Error(err)
}
if cfg.Rancher.Network.Dns.Override {
log.WithFields(log.Fields{"nameservers": cfg.Rancher.Network.Dns.Nameservers}).Info("Override nameservers")
if err := resolvconf.Build("/etc/resolv.conf", cfg.Rancher.Network.Dns.Nameservers, cfg.Rancher.Network.Dns.Search); err != nil {
log.Error(err)
}
}
if _, err := os.Create(NETWORK_DONE); err != nil {
log.Error(err)

View File

@@ -244,6 +244,7 @@ rancher:
volumes:
- /dev:/host/dev
- /etc/docker:/etc/docker
- /etc/resolv.conf:/etc/resolv.conf
- /etc/rkt:/etc/rkt
- /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt.rancher
- /lib/firmware:/lib/firmware