Sponsored Content
Top Forums Shell Programming and Scripting Grabbing IP and zonename from multiline 'ifconfig' output Post 302723663 by hcclnoodles on Tuesday 30th of October 2012 01:40:21 PM
Old 10-30-2012
Grabbing IP and zonename from multiline 'ifconfig' output

Hi There,

I have a Solaris server that has a bunch of zones configured and I am trying to write a script that will take all interfaces other than the loopback ones (e.g. lo0:3 etc) and present them so that I can easily determine the zone that owns the IP

So in the case of the following ifconfg output



Code:
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone myzone1
        inet 127.0.0.1 netmask ff000000
lo0:2: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone myzone2
        inet 127.0.0.1 netmask ff000000
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone myzone3
        inet 127.0.0.1 netmask ff000000
lo0:4: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone myzone4
        inet 127.0.0.1 netmask ff000000	
nxge3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        inet 10.90.24.145 netmask ffffff00 broadcast 10.90.24.255
        groupname MAIN
        ether 0:21:28:e5:xx:xx
nxge3:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        inet 0.0.0.0 netmask ff000000 broadcast 0.255.255.255
nxge3:2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        zone myzone1
        inet 10.90.24.82 netmask ffffff00 broadcast 10.90.24.255
nxge3:3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        zone myzone2
        inet 10.90.24.81 netmask ffffff00 broadcast 10.90.24.255
nxge3:4: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        zone myzone3
        inet 10.90.24.83 netmask ffffff00 broadcast 10.90.24.255
nxge3:5: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        zone myzone4
        inet 10.90.24.84 netmask ffffff00 broadcast 10.90.24.255

I would get something like

Code:
iface		ip			zonename
nxge3		10.90.24.145	
nxge3:1		0.0.0.0			
nxge3:2		10.90.24.82		myzone1
nxge3:3		10.90.24.81		myzone2
nxge3:4		10.90.24.83		myzone3
nxge3:5		10.90.24.84		myzone4


Im a little unsure how I would get it to treat each individual block of ifconfig output as a seperate entity as clearly the virtual IP's for the zones are laid out differently by ifconfig than the non zone/main IP's (eg. nxge3) .. youll notice that the ip address line is positioned differently.

I have to capture all valid IPs in the report whether they are linked to a zone or not ..

Any advice or guidance on what would be a good starting point for me would be greatly appreciated, as im not really sure how to tackle this one

Regards
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Further question on 'ifconfig' output

I asked a similar question earlier and got a very good answer but a new doubt came up. This is a few lines of a '/sbin/ifconfig' command on my PC: RX packets:3781025 errors:0 dropped:0 overruns:0 frame:0 TX packets:1941909 errors:0 dropped:0 overruns:0 carrier:0 Does the RX and TX packets... (1 Reply)
Discussion started by: mint1981
1 Replies

2. Solaris

/sbin/zonename file giving me problems

I'm trying to install the recommended patch cluster on a x86 Solaris 10 box. I get this error: ERROR: /sbin/zonename cannot be found. install_cluster for 10_x86 patch cluster not applied. Exiting. I tried touching the file and it gave a different error of: expected argument.. anyone... (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

3. UNIX for Dummies Questions & Answers

Grabbing a value from an output file

I am executing a stored proc and sending the results in a log file. I then want to grab one result from the output parameters (bolded below, 2) so that I can store it in a variable which will then be called in another script. There are more details that get printed in the beginning of the log file,... (3 Replies)
Discussion started by: hern14
3 Replies

4. Solaris

How to know the global zonename from non-global zone?

It is easy to list all zones from global zones, but how to find out the global zone name from non-global zone? thx (11 Replies)
Discussion started by: honglus
11 Replies

5. OS X (Apple)

Ifconfig output - help understanding flags 'Smart, Simplex', etc

Hi - Trying to understand a few things from an ifconfig -a output - can't seem to find info anywhere on the net. Specifically - looking to understand the following: Flags=8863 Smart Running (is this the same as UP) Simplex inet6 supported media: autoselect - does that imply the... (1 Reply)
Discussion started by: littlefrog
1 Replies

6. Shell Programming and Scripting

assigning a multiline grep output which has been piped through sed to a shell variabl

Hi, I wish to format the output of a grep command in such a way that sed will be able to handle the newline characters held in the output. Since sed does not allow newlines to be contained in a replacement pattern, that means adding a backslash '\' character to the end of each line from... (8 Replies)
Discussion started by: timculhane
8 Replies

7. Shell Programming and Scripting

Grabbing value from command output and monitoring for changes

Hi all, Very new to shell scripting so appreciate some help! There is a process count that I need to monitor, I have the AIX command that gives this value and I've cleaned it up with grep/awk so it only spits out the value I'm interested in: echo "psc -i 10050 -s RELOAD_SERVICE" | tmadmin... (14 Replies)
Discussion started by: monty77
14 Replies

8. Shell Programming and Scripting

parsing ifconfig output

I'm trying to gather information on the interfaces on a large number of servers. If I run ifconfig I will get: eth0 Link encap:Ethernet HWaddr 00:50:56:A2:27:C1 inet addr:10.145.xxx.xxx Bcast:10.152.45.255 Mask:255.255.254.0 ----- eth1 Link... (2 Replies)
Discussion started by: C0ppert0p
2 Replies

9. UNIX for Dummies Questions & Answers

Assigning ipv6 to bonding interface - getting old as well as changed ipv6 in ifconfig output

Hi, I have created a bonding bond1 interface with 6 Eth , mode=4. Recently i have changed my old ipv6 to new one and tried to restart as well as reload network service. Post which i can see old as well as changed ipv6 in ifconfig command output. Below are few files and command output for your... (1 Reply)
Discussion started by: omkar.jadhav
1 Replies

10. Shell Programming and Scripting

Printing from multiline output

Dear all, I have below "ldapsearch" output $ ldapsearch -D "CN=SVC-ACCOUNT,OU=SVC,OU=VDSI,OU=Non-Human,DC=Org,DC=com" -w secretword -H ldaps://org.com:636 -b DC=Org,DC=com -s sub uid=v00000 "(filter)" "displayName" "uid" "street" # extended LDIF # # LDAPv3 # base <DC=Org,DC=com> with... (7 Replies)
Discussion started by: baluchen
7 Replies
zonename(1)                                                        User Commands                                                       zonename(1)

NAME
zonename - print name of current zone SYNOPSIS
zonename DESCRIPTION
The zonename utility prints the name of the current zone. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWzoneu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
zlogin(1), zoneadm(1M), zonecfg(1M), attributes(5), zones(5) SunOS 5.10 9 Jan 2004 zonename(1)
All times are GMT -4. The time now is 08:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy