Changing a hostname in Solaris 10 requires modifying multiple configuration files to ensure the change persists across reboots. Unlike some modern Linux distributions, Solaris 10 doesn't have a single command that handles all aspects permanently.
First, check your current hostname:
# uname -n
oldsunserver
Now let's make the permanent changes:
# echo "newsunserver" > /etc/nodename
Edit the file to include your new hostname:
# vi /etc/hosts
::1 localhost
127.0.0.1 localhost
192.168.1.100 newsunserver loghost
For each network interface (like hme0 or e1000g0):
# vi /etc/hostname.e1000g0
newsunserver
If using NIS/NIS+:
# vi /etc/defaultdomain
example.com
After making all changes, reboot the system or run:
# uname -S newsunserver
Verify with:
# uname -n
newsunserver
# hostname
newsunserver
If the hostname reverts after reboot:
- Check /etc/nodename permissions (should be 644)
- Verify all interface files in /etc/hostname.*
- Ensure no DHCP overriding (check /etc/dhcp.* files)
For multiple systems, use this ksh script:
#!/bin/ksh
NEWHOST="newsunserver"
DOMAIN="example.com"
echo "$NEWHOST" > /etc/nodename
echo "$DOMAIN" > /etc/defaultdomain
sed -i "s/oldhostname/$NEWHOST/g" /etc/hosts
for iface in $(ls /etc/hostname.*)
do
echo "$NEWHOST" > $iface
done
uname -S $NEWHOST
Changing the hostname temporarily in Solaris is straightforward with the hostname
command, but making it persistent across reboots requires modifying system configuration files. Solaris 10 has specific files that control the hostname behavior.
Here's how to permanently modify your hostname in Solaris 10:
# First, check current hostname
hostname
# Edit the /etc/nodename file
vi /etc/nodename
# Enter your new hostname (FQDN format recommended)
# Example: solaris-server01.example.com
# Edit the /etc/hosts file
vi /etc/hosts
# Update the line with your IP address and new hostname
# Example:
# 192.168.1.100 solaris-server01.example.com solaris-server01
# For DHCP environments, edit /etc/hostname.*
# Replace * with your network interface name (e.g., e1000g0)
vi /etc/hostname.e1000g0
# Add your new hostname
If your system uses NIS/NIS+ or LDAP, additional steps may be required:
# For NIS/NIS+ systems
cp /etc/hosts /etc/hosts.bak
cp /etc/nodename /etc/nodename.bak
svcadm restart network/nis/client
After making changes, verify your configuration:
# Apply changes without reboot
uname -S [new-hostname]
/etc/init.d/network restart
# Verify changes
hostname
uname -n
cat /etc/nodename
If hostname reverts after reboot, check:
- DHCP client settings in /etc/dhcp
- Network auto-configuration services
- Name service cache daemon (nscd) status
# Force hostname update
svcadm restart network/physical
svcadm restart network/initial