K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / share / doc / ifupdown / contrib /
server ip : 104.21.89.46

your ip : 172.70.130.204

H O M E


Filename/usr/share/doc/ifupdown/contrib/ifstate-check
Size2.33 kb
Permissionrw-r--r--
Ownerroot : root
Create time27-Apr-2025 09:50
Last modified22-Jun-2012 05:52
Last accessed07-Jul-2025 04:53
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
#!/usr/bin/perl
#
# Generate a report of the status of interfaces configured
# by 'ifupdown'
# (c) 2004 Javier Fernandez-Sanguino <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

$statefile="/run/network/ifstate";
$configfile="/etc/network/interfaces";

open (IFACE,"<$configfile") || die ("Could not open $configfile: $!\n");
while (<IFACE>) {
chomp;
if ( /^iface\s+(\w+)\s+/ ) {
$configured{$1}=$_;
}
}

close IFACE;

open (IPLINK,"ip link show|") || die ("Could not execute ip: $!\n");
while (<IPLINK>) {
chomp;
# FORMAT
# #: AAAA: <XXXXX,UP> mtu 16436 qdisc noqueue
if ( /^\d+: (\w+):.*?\<.*?,UP.*?\>/ ) {
$iplink{$1}=$_;
}
}
close IPLINK;


open (STATE,"<$statefile") || die ("Could not open $statefile: $!\n");
$line = 0;
while (<STATE>) {
chomp;
$line++;
# Format is IFACE=IFACE
if ( /^(\w+)=(\w+)$/ ) {
$iface = $1;
$ifaces = $2;
if ( $iface ne $ifaces ) {
print STDERR "Error in $statefile (line $line), interface names do not match ('$iface' and '$ifaces')\n";
} else {
check_status($iface);
}
} else {
print STDERR "Error in $statefile (line $line), unknown content\n";
}

}
close STATE;

exit 0;

sub check_status {
my ($int) = @_;
print "$int: ";
my $status = "UP";
# Check if it's really up, this is done basicly because ifupdown
# might not have configured it properly even if it thinks he has
# (sample: ifconfig croaks when wrong parameters are used and
# ifupdown does not detect that the system call went awry)
$status = "ERROR_NOT_REALLY_UP" if ! defined ($iplink{$int}) ;
if ( defined ( $configured{$int} ) ) {
$status .= ",CONFIGURED";
} else {
$status .= ",MANUALLY_CONFIGURED";
}
print "$status\n";
return 0;
}