Last active
November 14, 2016 02:26
-
-
Save YUChoe/a74c251763419d4906f1e611db361c77 to your computer and use it in GitHub Desktop.
static routing
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/perl | |
foreach my $l (split(/\n/, `route -n`)) { | |
my @ll = split(' ', $l); | |
$r{$ll[0]} = [$ll[0], $ll[2], $ll[1]]; | |
} | |
foreach my $l (split(/\n/, `cat /usr/local/shieldone/etc/route/addroute`)) { | |
@ll = split(' ', $l); | |
if ( $ll[0] eq $r{$ll[0]}[0] | |
and $ll[1] eq $r{$ll[0]}[1] | |
and $ll[2] eq $r{$ll[0]}[2]) { | |
# pass | |
} else { | |
my $cmd = "route add -net $ll[0] netmask $ll[1] gw $ll[2]"; | |
#print($cmd . "\n"); | |
system($cmd . " 2> /dev/null"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment