What command do I want to issue when I want to know the IP address of the Solaris machine I'm logged onto?
This question is related to
unix
networking
ip-address
solaris
ip
/usr/sbin/host `hostname`
should do the trick. Bear in mind that it's a pretty common configuration for a solaris box to have several IP addresses, though, in which case
/usr/sbin/ifconfig -a inet | awk '/inet/ {print $2}'
will list them all
The following shell script gives a nice tabular result of interfaces and IP addresses (excluding the loopback interface) It has been tested on a Solaris box
/usr/sbin/ifconfig -a | awk '/flags/ {printf $1" "} /inet/ {print $2}' | grep -v lo
ce0: 10.106.106.108
ce0:1: 10.106.106.23
ce0:2: 10.106.106.96
ce1: 10.106.106.109
The following worked pretty well for me:
ping -s my_host_name
There's also:
getent $HOSTNAME
or possibly:
getent `uname -n`
On Solaris 11 the ifconfig command is considered legacy and is being replaced by ipadm
ipadm show-addr
will show the IP addresses on the system for Solaris 11 and later.
/usr/sbin/ifconfig -a | awk 'BEGIN { count=0; } { if ( $1 ~ /inet/ ) { count++; if( count==2 ) { print $2; } } }'
This will list down the exact ip address for the machine
Try using ifconfig -a
. Look for "inet xxx.xxx.xxx.xxx", that is your IP address
hostname
and uname
will give you the name of the host. Then use nslookup
to translate that to an IP address.
Source: Stackoverflow.com