We’ve all been there – there’s a missing binary or library on a Solaris host, someone’s accidentally deleted it, and we need to re-install the package. Or the other common scenario – two boxes that have been built by hand, one has binary A and the other doesn’t – which package adds it?
Along with the usual Solaris package management commands of pkgadd and pkgrm, there’s a lesser known utility called pkgchk. pkgchk allows us to check which package a file belongs to.
pkgchk will work with binaries:
-bash-3.00$ /usr/sbin/pkgchk -l -p /usr/bin/less
NOTE: Couldn't lock the package database.
Pathname: /usr/bin/less
Type: regular file
Expected mode: 0555
Expected owner: root
Expected group: bin
Expected file size (bytes): 117760
Expected sum(1) of contents: 20724
Expected last modification: Jan 23 01:48:30 2005
Referenced by the following packages:
SUNWless
Current status: installed
And we can also invoke pkgchk for libraries as well:
-bash-3.00$ /usr/sbin/pkgchk -l -p /lib/libresolv.so.1
NOTE: Couldn't lock the package database.
Pathname: /lib/libresolv.so.1
Type: regular file
Expected mode: 0755
Expected owner: root
Expected group: bin
Expected file size (bytes): 48368
Expected sum(1) of contents: 5063
Expected last modification: Jan 23 01:44:54 2005
Referenced by the following packages:
SUNWcslr
Current status: installed
For a quick overview of some of the other options, just invoke pkgchk with the -? command line:
-bash-3.00$ /usr/sbin/pkgchk -?
usage:
pkgchk [-l|vqacnxf] [-R rootdir] [-p path[, ...] | -P path[, ...]]
[-i file] [options]
pkgchk -d device [-f][-l|v] [-p path[, ...] | -P path[, ...]]
[-V ...] [-M] [-i file] [-Y category[, ...] | pkginst [...]]
where options may include ONE of the following:
-m pkgmap [-e envfile]
pkginst [...]
-Y category[, ...]
As you can see from the output, pkgchk is also very handy to see if the binaries or libraries that were part of a Solaris package file have been overwritten. As each file in a package has it’s checksum, file size, ownership, and permissions stored as part of the package manifest, this gets added to the Solaris package database when the package is installed – giving a quick and easy method to sanity check your installation.
Having covered how to manually configure ethernet interfaces in Solaris, I’ll now go over configuring the DHCP client. Solaris comes bundled with both a DHCP client and server, but here we just want to configure the client to go out and configure a Solaris ethernet interface.
Instead of a hostname.<interface> file, you need to create two empty files – dhcp.<interface> and hostname.<interface>, in the /etc/directory
bash-3.2$ touch /etc/dhcp.e1000g0
bash-3.2$ touch /etc/hostname.e1000g0
Reboot for the changes to take effect.
NOTE: you can have either DHCP or a static IP address – so double check which files are in place under /etc and what their contents are.
DHCP can be checked with the following commands:
bash-3.2$ /usr/sbin/ifconfig e1000g0 dhcp status
And you can release the DHCP lease with:
bash-3.2$ /usr/sbin/ifconfig e1000g0 dhcp release
DHCP from within VMWare will allocate a default router and DNS settings automatically to your Solaris VM. To enable this to work properly, both /etc/defaultrouter and /etc/resolv.conf must be present, but empty.
If these files already exist, just delete them:
bash-3.2$ rm /etc/defaultrouter
bash-3.2$ rm /etc/resolv.conf
Then recreate them as empty files with the touch command:
bash-3.2$ touch /etc/defaultrouter
bash-3.2$ touch /etc/resolv.conf
Now reboot and note the new settings take effect.
Recently I’ve had several clients who’ve just started with Solaris, and who have had roughly similar questions. So I thought I’d put up a few “How To” posts covering some Solaris basics.
Each LAN interface in Solaris has a configuration file in /etc which is named after the interface name and it’s instance.
So, let’s assume that you have two e1000g interfaces configured – you’d have two configuration files:
/etc/hostname.e1000g0
/etc/hostname.e1000g1
These files will just contain a hostname, which maps to an entry in /etc/hosts.
An example from my OpenSolaris development workstation:
bash-3.2$ cat /etc/hostname.e1000g0
grond
And this is /etc/hosts:
# Internet host table
#
::1 grond grond.local localhost loghost
127.0.0.1 localhost
192.168.13.100 grond grond.local loghost
When Solaris boots, all it does to configure a LAN interface is look for hostname.* files in /etc. It then looks up the hostname in /etc/hosts to find out the IP address, then configures the interface.
So if you need to change the IP address of a LAN interface in Solaris, all you need to do is edit the hostname entry in /etc/hosts and reboot. For example, to change grond’s e1000g0 IP address to a different subnet, /etc/hosts would be modified to:
# Internet host table
#
::1 grond grond.local localhost loghost
127.0.0.1 localhost
192.168.125.100 grond grond.local loghost
Then reboot the host for the changes to take effect.