Skip to content

Instantly share code, notes, and snippets.

@YUChoe
Last active November 14, 2016 02:26
Show Gist options
  • Save YUChoe/a74c251763419d4906f1e611db361c77 to your computer and use it in GitHub Desktop.
Save YUChoe/a74c251763419d4906f1e611db361c77 to your computer and use it in GitHub Desktop.
static routing
#!/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