Wednesday, November 19, 2014

Solaris 11: DNS Client Configuration Using Svccfg

In Solaris 11, alot of configurations are being moved from configuration files into the Service Management Framework. Here we will discuss this change around the DNS client.
View Existing DNS Client Configuration
# svccfg -s network/dns/client listprop config
config application
config/value_authorization astring solaris.smf.value.name-service.dns.client
config/domain astring test.local
config/nameserver net_address 10.0.0.152
Update Existing DNS Client Configuration
Here we will update our name servers. In this case we are replacing the original with two different addresses.
# svccfg -s network/dns/client setprop config/nameserver = net_address: "(10.0.0.141 10.0.0.142)"
Here we are changing the domain to b.test.local.
# svccfg -s network/dns/client setprop config/domain = astring: b.test.local
And we are defining a previously undefined setting for the search domains, we are including test.local and b.test.local.
# svccfg -s network/dns/client setprop config/search = astring: '("test.local" "b.test.local")'
Here we are defining our name resolution order.
# svccfg -s name-service/switch setprop config/ipnodes = astring: '("files dns")'
# svccfg -s name-service/switch setprop config/host = astring: '("files dns")'
Review Changed DNS Client Configuration
# svccfg -s network/dns/client listprop config
config application
config/value_authorization astring solaris.smf.value.name-service.dns.client
config/domain astring b.test.local
config/nameserver net_address 10.0.0.141 10.0.0.142
config/search astring "test.local" "b.test.local"
Review Changed Name Service Configuration
# svccfg -s name-service/switch listprop config
config application
config/default astring files
config/value_authorization astring solaris.smf.value.name-service.switch
config/printer astring "user files"
config/ipnodes astring "files dns"
config/host astring "files dns"
Export DNS Client Configuration
This command will build an /etc/resolv.conf based on your settings above.
# svcadm enable dns/client
# nscfg export svc:/network/dns/client:default
# cat /etc/resolv.conf
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
#
#
# _AUTOGENERATED_FROM_SMF_V1_
#
# WARNING: THIS FILE GENERATED FROM SMF DATA.
# DO NOT EDIT THIS FILE. EDITS WILL BE LOST.
# See resolv.conf(4) for details.
domain b.test.local
search test.local b.test.local
nameserver 10.0.0.141
nameserver 10.0.0.142
If you manually edit the /etc/resolv.conf then your changes will be lost on a restart of the network/dns/client service or a reboot, as the warning says.
Export Name Service Configurations
# svcadm refresh name-service/switch
# cat /etc/nsswitch.conf
#
# _AUTOGENERATED_FROM_SMF_V1_
#
# WARNING: THIS FILE GENERATED FROM SMF DATA.
# DO NOT EDIT THIS FILE. EDITS WILL BE LOST.
# See nsswitch.conf(4) for details.
passwd: files
group: files
hosts: files dns
ipnodes: files dns
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files
netgroup: files
automount: files
aliases: files
services: files
printers: user files
project: files
auth_attr: files
prof_attr: files
tnrhtp: files
tnrhdb: files
sudoers: files
An Extra Trick
Now if you can’t be bothered to do things the new way they also put in an import mechanism, whereby you can take advantage of your existing knowledge and simply import your modified configuration files into the SMF to manage them going forward.
So modify up your /etc/resolv.conf and your /etc/nsswitch.conf and then import them with nscfg.
# nscfg import -f name-service/switch:default
# nscfg import -f dns/client:default