Solaris Tips
Maybe you are thinking "Hey, you should only need "ifconfig whatever" and look for the word RUNNING in its output". You are half right, IMHO: you should need only that, but sometimes it is not enough.
Solaris ifconfig(1M) sometimes does show as RUNNING an interface for which there is no actual link.
What you need to use is ndd(1M). This administration utility is used to change and view the parameters of network devices and protocols. With it, you can enable or disable IP forwarding, change the different TCP windows, disable Ethernet autonegotiation to force a transmission mode or speed...
The sintaxis of ndd is very simple:
ndd [-set] <driver> <parameter> [value]
Some parameters are read-only, some write-only and some are both readable and writeable. And all drivers are supposed to include a handy ? read-only parameter that lists all the possible parameters, along with their access type.
There is a detail about ndd that can be a little dissorienting. The "driver" names refer to non existing /dev directory entries, like /dev/ip, /dev/tcp or /dev/hme.
Well, what we need to do is to read the value link_status for our interface. Unfortunatelly you can not just use
# ndd /dev/hme1 link_status
Because ndd only knows about /dev/hme, not /dev/hme1. It reffers to drivers, no devices.
We then have to tell it which driver instance to work on. But that is easy:
# ndd -set /dev/hme instance 1 # ndd /dev/hme link_status 1 # ndd -set /dev/hme instance 2 # ndd /dev/hme link_status 0
As you should have guessed, "0" means down and "1" means up. In the example, hme1 is up, while hme2 is down.
This is a perl script that performs the procedure described above and outputs "Up" or "Down". It saves the current value of instance, so the environment is left unchanged (I expect.)
Example output:
# ndd /dev/hme instance 0 # ifstatus hme1 Up # ifstatus hme2 Down # ndd /dev/hme instance 0