If domainname command not showing any output then you need to check either defaultdomain or NIS domain is configured or not.
Steps which we need to follow to set the NIS domain name as describe below.
1. Please run "cat /etc/defaultdomain" command and check the output that domain is set or not.
#domainname
The above command shows you the current domain name on the server, if no output is display you need to set the domain by below command.
#domainname UNIX
Run the below command to check the output again.
#domainname
UNIX
You can see the output. All the above command is used for checking and setting the domain name on the Solaris operating server.
2. If you want to set the domain using NIS, then first please check the NIS/DOMAIN service is running or not
root@sun:~# svcs status nis/domain
STATE STIME FMRI
disabled 18:20:04 svc:/network/nis/domain:default
In my Solaris machine, currently NIS domain services is stop, we will start it later once we will configured the NIS domain name on the Solaris server.
3. Now you need to configure the NIS domain for your machine ( in my case - UNIX is my domain name)
root@sun:~# svccfg -s svc:/network/nis/domain setprop config/domainname = UNIX
If you see the above command, "svccfg" command is used to configure the domain and set the proper properties.
4. In the final step once the configuration has been completed you need to refresh & enable the NIS domain service again.
root@sun:~# svccfg -s nis/domain:default refresh
root@sun:~# svcadm enable nis/domain
You can check the NIS domain service status as describe in step 2.
5. Now you can verify the domain name using below command so we can ensure that the NIS domain name has been set successfully.
root@sun:~# domainname
The above command output show "UNIX" domain name which we set during the configuration, so using these above method we can easily set the NIS domain name on the Solaris operating server.UNIX