Created
October 10, 2017 06:04
-
-
Save raven428/5a9d3e5bcaa5138c5f2b77d01979f409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# | |
# $Id: ms-classless-routes-decoder.pl,v 1.2 2017/10/10 05:59:07 raven Exp $ | |
# | |
use strict; | |
use warnings; | |
my $in = $ARGV[0]; | |
my @in = split(/:/, $in); | |
foreach(@in) { $_ = hex($_); } | |
my @routes = (); | |
while($#in >= 0) { | |
my $mask = shift(@in); | |
if($mask == 0) { | |
for(1..4) { shift(@in); }; | |
} elsif(($mask >= 1) and ($mask <= 8)) { | |
my $route = shift(@in) . '.0.0.0/' . $mask . ' '; | |
for(1..4) { $route .= shift(@in) . '.'; }; | |
print("$route\n"); | |
} elsif(($mask >= 9) and ($mask <= 16)) { | |
my $route = ''; | |
$route .= shift(@in) . '.' . shift(@in) . '.0.0/' . $mask . ' ' . | |
shift(@in) . '.' . shift(@in) . '.' . shift(@in) . '.' . shift(@in); | |
print("$route\n"); | |
} elsif(($mask >= 17) and ($mask <= 24)) { | |
my $route = ''; | |
$route .= shift(@in) . '.' . shift(@in) . '.' . shift(@in) . '.0/' . $mask . ' ' . | |
shift(@in) . '.' . shift(@in) . '.' . shift(@in) . '.' . shift(@in); | |
print("$route\n"); | |
} elsif(($mask >= 24) and ($mask <= 32)) { | |
my $route = ''; | |
$route .= shift(@in) . '.' . shift(@in) . '.' . shift(@in) . '.' . shift(@in) . '/' . $mask . ' ' . | |
shift(@in) . '.' . shift(@in) . '.' . shift(@in) . '.' . shift(@in); | |
print("$route\n"); | |
}; | |
}; | |
#10:c0:a8:a:31:9c:1:c:a:30:a:31:9c:1:18:a:64:c:a:31:9c:1:18:4e:1d:0:a:31:9c:1 | |
# http://www.ietf.org/rfc/rfc3442.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dhcpd.conf:
/etc/dhclient-exit-hooks: