dns-client-conf - Simple and portable cli tool and golang package for work with operating system dns client settings
To install dns-client-conf, please use go get
.
$ go get github.com/ArtemKulyabin/dns-client-conf/cmd/dns-client-conf
...
$ dns-client-conf help
...
$ go get github.com/ArtemKulyabin/dns-client-conf
...
$ sudo dns-client-conf add 8.8.8.8 8.8.4.4 # Google Public DNS
DNS servers added successfully
$ dns-client-conf show
8.8.8.8
8.8.4.4
...
$ sudo dns-client-conf add 77.88.8.8 77.88.8.1 # Yandex.DNS
DNS servers added successfully
$ dns-client-conf show
77.88.8.8
77.88.8.1
...
$ sudo dns-client-conf dhcp # Receive dns addresses by DHCP protocol
DNS servers received by DCHP protocol successfully
$ dns-client-conf show # My ISP provider DNS servers
141.105.32.88
141.105.32.89
127.0.1.1
...
package main
import (
"log"
"github.com/ArtemKulyabin/dns-client-conf"
)
func main() {
dnsconf := dnsclientconf.NewDNSConfigurator()
addrs, err := dnsconf.GetNameServers()
if err != nil {
log.Fatal(err)
}
err = dnsconf.AddNameServers([]string{"8.8.8.8", "8.8.4.4"})
if err != nil {
log.Fatal(err)
}
err = dnsconf.DHCPNameServers()
if err != nil {
log.Fatal(err)
}
}
For cross compilation you may use the Gox. Example:
$ gox github.com/ArtemKulyabin/dns-client-conf/cmd/dns-client-conf
...
- Linux, FreeBSD, OpenBSD, NetBSD, Darwin(OS X), Windows
- Ubuntu 14.04, FreeBSD 10.1, OpenBSD 5.6, NetBSD 6.1.5, OS X Yosemite 10.10.3, Windows 7