How can i get Solaris interface ip using shell script?

HI Community,

my server has more than 15 zones and each one is having virtual interface of 10G adapter (qlge0)

if the filter the output of ifconfig -a | grep inet, it's showing all interfaces including virtual.

i have take first like from the output and assumed that as my main ip

is there any other way to get ip address from shell?

Regards,
Ben

nslookup zone_name will give you what you want.
If you are logged in to the global zone:

zoneadm list -civ

shows the names of all of the zones.

I had trouble understanding what you need, exactly. If this is not it, please let us know.

This might be what you are looking for :

ifconfig -a4 | nawk '
    BEGIN { ignore=0 }
    /zone/ { ignore=1 }
    /inet/ { if((ignore==0) && ($2!="127.0.0.1") && ($2!="0.0.0.0")) print $2 ; ignore=0}'
1 Like

Wow

thanks for your help. it worked for me