Link to home
Start Free TrialLog in
Avatar of TIMFOX123
TIMFOX123Flag for United States of America

asked on

I need a simple script to tell me the IP addresses of the zones running on a solaris system

I do not have access to a solaris 10 with zones but I do need a script for the sysadmin to run nightly.

As I understand if you do a:
global# /usr/sbin/zoneadm list -vc
 
it shows the zones.  Now for each zone if you do a:
global# zonecfg -z myzone info

it gives the ip address.  

I need someone to "grep out" the zone and then run the secon command on each zone.  


http://www.logiqwest.com/dataCenter/Demos/RunBooks/Zones/zoneStatus.html
ASKER CERTIFIED SOLUTION
Avatar of apresence
apresence

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apresence
apresence

As you might guess, there may be more than one IP address assigned to a zone.  The following code will get you a list of zones and their IP addresses.
for i in `/usr/sbin/zoneadm list -vc | perl -ne 'print "$1 $2\n" if /^\s+ (\d+) ([^\s]+)/' | grep -v "^0 " | cut -d' ' -f2`; do zonecfg -z $i info; done | perl -ne 'print $_ if /(zonename:|address:)\s+([^\s]+)/'

Open in new window

Sample output from the previous command:
zonename: some-local-zone
        address: 192.168.10.112/24
        address: 192.168.119.109/24
Avatar of TIMFOX123

ASKER

What a great solution !!!!!!!!!!!!!!!!!!!!!!!

This realllllly helps us.