summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher LILJENSTOLPE <vyatta@cdl.asgaard.org>2008-03-10 11:11:29 -0700
committerStig Thormodsrud <stig@vyatta.com>2008-03-10 11:11:29 -0700
commitebca7579f5d946d1e5d81c3c4ddc338dda0f7939 (patch)
treee9082d92afbe4c912cb550ed3eca6d3b4285bd8f /scripts
parent7c5c72228f538f3c9aa3dc3bee300e278e3cda2e (diff)
downloadvyatta-op-ebca7579f5d946d1e5d81c3c4ddc338dda0f7939.tar.gz
vyatta-op-ebca7579f5d946d1e5d81c3c4ddc338dda0f7939.zip
Fix 2965: IPv6 Interface information not shown in show interfaces
Diffstat (limited to 'scripts')
-rw-r--r--scripts/vyatta-show-interfaces.pl13
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/vyatta-show-interfaces.pl b/scripts/vyatta-show-interfaces.pl
index 15a411b..4376fc0 100644
--- a/scripts/vyatta-show-interfaces.pl
+++ b/scripts/vyatta-show-interfaces.pl
@@ -30,6 +30,7 @@ use lib "/opt/vyatta/share/perl5/";
use VyattaConfig;
use Getopt::Long;
use POSIX;
+use NetAddr::IP;
use strict;
use warnings;
@@ -157,11 +158,15 @@ sub get_ipaddr {
my $intf = shift;
my @addr_list = ();
- my @lines = `ip addr show $intf | grep 'inet '`;
+ my @lines = `ip addr show $intf | grep 'inet' | grep -iv 'fe80'`;
foreach my $line (@lines) {
- if ($line =~ m/inet (\d+\.\d+\.\d+\.\d+)\/(\d+)/) {
- push @addr_list, "$1/$2";
- }
+ (my $inet, my $addr, my $remainder) = split(' ', $line, 3);
+ my $ip = new NetAddr::IP($addr);
+ if ($ip->version() == 6) {
+ push @addr_list, $ip->short() . '/' . $ip->masklen();
+ } else {
+ push @addr_list, $ip->cidr();
+ }
}
chomp @addr_list;
return @addr_list;