summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
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;