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
I would get something like
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
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT DEBIAN
io::interface
Interface(3pm) User Contributed Perl Documentation Interface(3pm)NAME
IO::Interface - Perl extension for access to network card configuration information
SYNOPSIS
# ======================
# the new, preferred API
# ======================
use IO::Interface::Simple;
my $if1 = IO::Interface::Simple->new('eth0');
my $if2 = IO::Interface::Simple->new_from_address('127.0.0.1');
my $if3 = IO::Interface::Simple->new_from_index(1);
my @interfaces = IO::Interface::Simple->interfaces;
for my $if (@interfaces) {
print "interface = $if
";
print "addr = ",$if->address,"
",
"broadcast = ",$if->broadcast,"
",
"netmask = ",$if->netmask,"
",
"dstaddr = ",$if->dstaddr,"
",
"hwaddr = ",$if->hwaddr,"
",
"mtu = ",$if->mtu,"
",
"metric = ",$if->metric,"
",
"index = ",$if->index,"
";
print "is running
" if $if->is_running;
print "is broadcast
" if $if->is_broadcast;
print "is p-to-p
" if $if->is_pt2pt;
print "is loopback
" if $if->is_loopback;
print "is promiscuous
" if $if->is_promiscuous;
print "is multicast
" if $if->is_multicast;
print "is notrailers
" if $if->is_notrailers;
print "is noarp
" if $if->is_noarp;
}
# ===========
# the old API
# ===========
use IO::Socket;
use IO::Interface qw(:flags);
my $s = IO::Socket::INET->new(Proto => 'udp');
my @interfaces = $s->if_list;
for my $if (@interfaces) {
print "interface = $if
";
my $flags = $s->if_flags($if);
print "addr = ",$s->if_addr($if),"
",
"broadcast = ",$s->if_broadcast($if),"
",
"netmask = ",$s->if_netmask($if),"
",
"dstaddr = ",$s->if_dstaddr($if),"
",
"hwaddr = ",$s->if_hwaddr($if),"
";
print "is running
" if $flags & IFF_RUNNING;
print "is broadcast
" if $flags & IFF_BROADCAST;
print "is p-to-p
" if $flags & IFF_POINTOPOINT;
print "is loopback
" if $flags & IFF_LOOPBACK;
print "is promiscuous
" if $flags & IFF_PROMISC;
print "is multicast
" if $flags & IFF_MULTICAST;
print "is notrailers
" if $flags & IFF_NOTRAILERS;
print "is noarp
" if $flags & IFF_NOARP;
}
my $interface = $s->addr_to_interface('127.0.0.1');
DESCRIPTION
IO::Interface adds methods to IO::Socket objects that allows them to be used to retrieve and change information about the network
interfaces on your system. In addition to the object-oriented access methods, you can use a function-oriented style.
THIS API IS DEPRECATED. Please see IO::Interface::Simple for the preferred way to get and set interface configuration information.
Creating a Socket to Access Interface Information
You must create a socket before you can access interface information. The socket does not have to be connected to a remote site, or even
used for communication. The simplest procedure is to create a UDP protocol socket:
my $s = IO::Socket::INET->new(Proto => 'udp');
The various IO::Interface functions will now be available as methods on this socket.
Methods
@iflist = $s->if_list
The if_list() method will return a list of active interface names, for example "eth0" or "tu0". If no interfaces are configured and
running, returns an empty list.
$addr = $s->if_addr($ifname [,$newaddr])
if_addr() gets or sets the interface address. Call with the interface name to retrieve the address (in dotted decimal format). Call
with a new address to set the interface. In the latter case, the routine will return a true value if the operation was successful.
my $oldaddr = $s->if_addr('eth0');
$s->if_addr('eth0','192.168.8.10') || die "couldn't set address: $!";
Special case: the address of the pseudo-device "any" will return the IP address "0.0.0.0", which corresponds to the INADDR_ANY
constant.
$broadcast = $s->if_broadcast($ifname [,$newbroadcast]
Get or set the interface broadcast address. If the interface does not have a broadcast address, returns undef.
$mask = $s->if_netmask($ifname [,$newmask])
Get or set the interface netmask.
$dstaddr = $s->if_dstaddr($ifname [,$newdest])
Get or set the destination address for point-to-point interfaces.
$hwaddr = $s->if_hwaddr($ifname [,$newhwaddr])
Get or set the hardware address for the interface. Currently only ethernet addresses in the form "00:60:2D:2D:51:70" are accepted.
$flags = $s->if_flags($ifname [,$newflags])
Get or set the flags for the interface. The flags are a bitmask formed from a series of constants. See "Exportable constants" below.
$ifname = $s->addr_to_interface($ifaddr)
Given an interface address in dotted form, returns the name of the interface associated with it. Special case: the INADDR_ANY address,
0.0.0.0 will return a pseudo-interface name of "any".
EXPORT
IO::Interface exports nothing by default. However, you can import the following symbol groups into your namespace:
:functions Function-oriented interface (see below)
:flags Flag constants (see below)
:all All of the above
Function-Oriented Interface
By importing the ":functions" set, you can access IO::Interface in a function-oriented manner. This imports all the methods described
above into your namespace. Example:
use IO::Socket;
use IO::Interface ':functions';
my $sock = IO::Socket::INET->new(Proto=>'udp');
my @interfaces = if_list($sock);
print "address = ",if_addr($sock,$interfaces[0]);
Exportable constants
The ":flags" constant imports the following constants for use with the flags returned by if_flags():
IFF_ALLMULTI
IFF_AUTOMEDIA
IFF_BROADCAST
IFF_DEBUG
IFF_LOOPBACK
IFF_MASTER
IFF_MULTICAST
IFF_NOARP
IFF_NOTRAILERS
IFF_POINTOPOINT
IFF_PORTSEL
IFF_PROMISC
IFF_RUNNING
IFF_SLAVE
IFF_UP
This example determines whether interface 'tu0' supports multicasting:
use IO::Socket;
use IO::Interface ':flags';
my $sock = IO::Socket::INET->new(Proto=>'udp');
print "can multicast!
" if $sock->if_flags & IFF_MULTICAST.
AUTHOR
Lincoln Stein <lstein@cshl.org>
This module is distributed under the same license as Perl itself.
SEE ALSO perl(1), IO::Socket(3), IO::Multicast(3), IO::Interface::Simple
perl v5.14.2 2011-07-21 Interface(3pm)