summaryrefslogtreecommitdiff
path: root/scripts/is_valid_address.pl
blob: 2860cc2260441466e8d8997b70e0c61f9ff656bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl
# Check a single IPv4 or IPv6 address

use NetAddr::IP;

$ip = $ARGV[0];

if( !defined($ip) ||
    $ip =~ "/"    || # Ensure it doesn't have prefix length
    !($addr = new NetAddr::IP $ip)
  ) {
      exit 1;
}

exit 0;