Wednesday, January 8, 2014

DNS services

DNS (Domain Name System) is a hierarchical and distributed database for hosts name and addresses relationships as well as hosts related information such as: mail exchange routing, location data and available services.

Due to its characteristics, DNS is vital.
Any kind of Internet presence or access requires it.
Many other infrastructure services take advantage of it.
It doesn't replace NIS, but supersedes the hosts map.

NIS has a known DNS-forwarding mode (see nsswitch.conf(4)) where it forwards host names and addresses lookup requests to DNS if it doesn't have the information on its own databases.  This possible integration, together with the further variations on the hosts database source list of the Name Services Switch, can lead to unexpected resolutions and subtle issues. Hence, except for specific cases, it may indeed be better to adopt the following host database source list:
hosts: files dns nis
Nowadays we also have the alternative of multicast DNS and the now reserved .local pseudo-TLD name is used for it. The on-line documentation also talks about it as well as man pages mdnsd(1M) and dns-sd(1M). It has to do with the zero-configuration networking and Apples's Bonjour implementation whose open source framework and tools is present in Solaris. But being restricted to local area networks, at least for now, I won't enable it. One notable exception is when setting up the Automated Installer Framework, which requires enabling it.

# svcs dns/multicast
STATE          STIME    FMRI
disabled       Jan_07   svc:/network/dns/multicast:default


These DNS series of blog posts will primarily cover traditional DNS, a.k.a. unicast DNS. I do not yet know how deep I'll go with my descriptions and examples, but I intend to visit the basics alongside benefits and advantages of implementing it under Solaris.

So these are the main posts:


For further detail I'd point to:
 
     

Global zone L2 & L3 protection

L2 (layer 2) and L3 (layer 3) refers respectively to MAC and IP addresses.
This is all similar to non-global zones (NGZ) L2 & L3 protection.

By default we have no protection setting for the global zone (GZ).
Note that ip-nospoof also requires setting the allowed-ips property.

$ dladm show-linkprop -p allowed-ips,protection net0
LINK  PROPERTY     PERM VALUE          DEFAULT  POSSIBLE
 
net0  allowed-ips  rw   --             --       --  
net0  protection   rw   --             --       mac-nospoof,
                                                restricted,
                                                ip-nospoof,
                                                dhcp-nospoof


In general both should be set to improve security.

# dladm set-linkprop -p allowed-ips=192.168.0.100 net0
# dladm set-linkprop -p protection=mac-nospoof,ip-nospoof net0

$ dladm show-linkprop -p allowed-ips,protection net0
LINK  PROPERTY     PERM VALUE          DEFAULT  POSSIBLE
net0  allowed-ips  rw   192.168.0.100  --       -- 

net0  protection   rw   mac-nospoof,   --       mac-nospoof,
                       
ip-nospoof              restricted,
                                                ip-nospoof,
                                                dhcp-nospoof

   

Tuesday, January 7, 2014

Zones L2 & L3 protection

L2 (layer 2) and L3 (layer 3) refers respectively to MAC and IP addresses.
Zones are particularly attractive in securing those two networking entities.
This is because zones are fundamental to the IaaS cloud service model.
This assures zones will never be a vector for common L2/L3 attacks.

Zones can use two different kind of protected networking resources:

net
Refers to either a physical NIC or a predefined virtual NIC (vnic).
The protection is given by the allowed-address and the configure-allowed-address parameters. This will automatically set ip-nospoof  for the underlying link, but currently it will make it impossible to set the mac-nospoof (sort of bug or limitation).

anet
Automatically creates a vnic according to parameters.
Naturally, the underlying link (lower-link) can't be another vnic.
The protection is given by the link-protection parameter, but
its setting is somewhat automatic along the setting of allowed-address and the configure-allowed-address parameters. I say somewhat because they set the ip-nospoof.  But it may be good to add the mac-nospoof.

Hence, at a minimum, no matter if net or anet is used, what's important is to set the allowed-address and configure-allowed-address parameters. But if using anet, then also set the link-protection to mac-nospoof.
 
For instance:

# zonecfg -z server-1b info net
net:
    address not specified
    allowed-address: 192.168.0.12/24
    configure-allowed-address: true
    physical: net2
    defrouter not specified


But the protection technology isn't restricted to non-global zones (NGZ).
In fact, this networking protection technology is totally independent.
As such they can be used in global zones (GZ) as well.
    

Immutable zones

The advent of immutable zones is a great improvement to Solaris.
Now it's possible to set portions of the root file system as read-only.

The improvement is two-folded:

Security

If the zone virtual environment somehow gets compromised, then the read-only root file system will be a tough barrier helping to limit the exposed surface.

For instance, a DNS service running on a dedicated immutable zone doesn't require the associated SMF service tunning in order to run the service under a non-root account.

Management

This is easier to understand. Once perfectly set up, it's assured that the configuration won't be changed by accident or even by tampering. It's known that a many problems arise from a poor change management. Now the operating system supports and enforces the expected behavior. Great!

There are 3 degrees of protection:

Complete
This is given by the zone property file-mac-profile=strict.
Nothing can be changed and data can only be logged remotely.

Fixed
This is given by file-mac-profile=fixed-configuration.
Logging can be local and portions of /var are writable.
For instance, NIS services seem to work fine.

Flexible
This is given by file-mac-profile=flexible-configuration.
This differs from Fixed by allowing a writable /etc.

To check if a zone is configured as immutable:

# zonecfg -z server-1b info file-mac-profile
file-mac-profile: fixed-configuration
 

To check if a zone is running as immutable:

# zoneadm list -p | grep server-1b | cut -d: -f8,9
R:fixed-configuration


NOTE
Immutable zones doesn't protect non-root file systems.
Thus other forms of protection and recover must be devised.

NOTE
To manage an immutable zone, it's necessary to temporarily remove the immutability / read-only enforcements:
 
# zoneadm -z <zonename> boot -w
  
If the zone is already running immutable you don't need to halt or shutdown and then perform the above command; simply use:

# zoneadm -z <zonename> reboot -w

On the last case (a reboot for management) the message [NOTICE: Read-only zone rebooting read-write] will follow on the zone's console.

After the management, to reenter the immutable state simply use init 6 or shutdown -r for an ordered shutdown as usual.
     

Friday, January 3, 2014

NIS & logins

Last year I believe to have covered a great deal of NIS services.
I have tried to exemplify each feature and functionality.
But I think a more real example would be useful.
I intend to give an example dealing with new logins.

A login is an account that is used to directly access the system.
Along with its credential, its home directory is an essential resource.
Those resources are conveniently centrally managed by NIS services.
Unfortunately NIS can't provide nowadays security requirements.
Nevertheless, it may still be very useful on restricted scenarios.

Beyond defaults I make the following assumptions for the example:
 
  • There's no DNS infrastructure in place yet. 
  • The RPC domain is business.corp.
  • The nis-1 host is the NIS master.
  • The nis-2 and nis-3 hosts are the NIS slaves.
  • The desktop-1 host is the NIS client.
  • The nfs-1 host is the NFSv4 server.
  • The automounter is used accordingly.
  • The new login to be created is user2.
  • The group is customer (gid=1000)
  • The default project is project1.
  • The pam_list allowed users on NIS master doesn't list user2. 
  • Customized versions of .profile and .bashrc exist. 
  • The hosts, notably nis-1, aren't immutable zones.

As a best practice, before doing any changes, take a backup.
I prefer ZFS snapshots but they aren't allowed on immutable zones.
On an immutable zone, user management tools won't work either.
I consider worthwhile reboot the zones in temporary write mode (-w).
Another possibility is to use a Revision Control System.

Create the login account locally on the NIS master:

nis-1# useradd -c "User 2" user2

nis-1# getent passwd user2
user2:x:102:10:User 2:/export/home/user2:/usr/bin/bash


nis-1# passwd user2
New Password:
Re-enter new Password:
passwd: password successfully changed for user2


nis-1# passwd -l user2
passwd: password information changed for user2


Copy the login basic configuration to the account maps' sources:

nis-1# grep user2 /etc/passwd >> /var/nis/acct/passwd
nis-1# grep user2 /etc/shadow >> /var/nis/acct/shadow

Clean up the local login account from the NIS master:

nis-1# userdel user2

Edit the group and home directory configurations on the passwd map.
It should look like as follows:

nis-1# grep user2 /var/nis/acct/passwd
user2:x:102:1000:User 2:/home/user2:/usr/bin/bash


nis-1# grep user2 /var/nis/acct/shadow
user2:*LK*$5$...:0::::::


Edit the netgroup configuration.
It should look somewhat similar to:
 
nis-1# cat /var/nis/netgroup
...
users ... (-,user2,business.corp) ...
...
 
Edit the project configuration on the project map.
It should look like as follows:

nis-1# grep user2 /var/nis/project
project1:100:Project 1:user1,user2::


nis-1# grep user2 /var/nis/user_attr
user2::::project=project1


Edit the automounter configuration on the auto_home map.
It should look like as follows:

nis-1# grep user2 /var/nis/auto_home
user2 nfs-1.business.corp:/export/home/&


Run make on the updated sources:

nis1:/var/yp# make
updated passwd
pushed passwd
updated ageing
updated netid
pushed netid
updated project
pushed project

updated netgroup
pushed netgroup
 

updated auto.home
pushed auto.home

updated user_attr
pushed user_attr


Verify that the maps were correctly updated:

nis-2$ ypmatch -k user2 passwd
user2: user2::102:1000:User 2:/home/user2:/usr/bin/bash 


nis-2$ ypmatch -k user2 auto.home
user2: nfs-1.business.corp:/export/home/&


nis-2$ ypmatch -k project1 project
project1: project1:100:Project 1:user1,user2::


nis-2$ ypmatch -k user2 user_attr
user2: user2::::project=project1

 
nis-2$ ypcat -k netgroup | grep user2
users ... (-,user2,business.corp) ...

Create and export the home directory:

nfs-1# zfs create \
> -o quota=1g \
> -o share.nfs.sec.sys.rw="desktops:servers" \
> rpool/export/home/user2

nfs-1# cp /etc/skel/.profile /export/home/user2
nfs-1# cp /etc/skel/.bashrc /export/home/user2

nfs-1# chown -R user2:customer /export/home/user2

nfs-1# ll -a /export/home/user2
total 11
drwxr-xr-x   5 root     root         ... ..
drwxr-xr-x   2 user2    customer     ... .
-rw-r--r--   1 user2    customer     ... .profile
-r--r--r--   1 user2    customer     ... .bashrc


nfs-1# zfs set share.nfs=on rpool/export/home/user2

nfs-1# zfs get -o value share rpool/export/home/user2
VALUE
name=...,path=/export/home/user2,...,rw=servers:desktops


In addition to the update of NIS maps, if there were changes on any NIS netgroup that's referenced on some NFS share, then it's necessary to refresh the NFS service:

nfs-1# svcadm refresh nfs/server 

Finally, unlock the account (remove the *LK* prefix) so it can be used:

nis-1# grep user2 /var/nis/acct/shadow
user2:$5$...:0::::::


nis-1:/var/yp# make
...

NOTE
If user2 is going to be used on a Solaris 11 desktop, then, to avoid the remote directory bug in Login Assistant, make sure that the Gnome file .dmrc exists in the home directory and contains the following:
nfs-1$ cat /export/home/user2/.dmrc

[Desktop]
Language=en_US.UTF-8
Layout=us
  
For an variation of this post see also NIS & roles.

NOTE
It's important to note that during this processes there were no disruption of service to clients as all NIS clients should have been associated only to NIS slave servers.