Skip to content

Instantly share code, notes, and snippets.

@tacitochaves
Created July 24, 2014 17:18
Show Gist options
  • Select an option

  • Save tacitochaves/f95f4b9da4684c242679 to your computer and use it in GitHub Desktop.

Select an option

Save tacitochaves/f95f4b9da4684c242679 to your computer and use it in GitHub Desktop.
Chamando o módulo network::Route
#!/usr/bin/env perl
use strict;
use warnings;
use lib '/usr/lib/tchaves';
use network::Route qw( ip_rule_list rule_add rule_del rule_emb ping_emb r_add_147 r_add_34 );
use strict;
use warnings;
my %options = (
fwbuilder => "/etc/fw/fw1sesma.fw",
destino => "8.8.4.4",
arquivo => "/tmp/rules.txt"
);
my @rule = &ip_rule_list;
my $rule_add_link2 = rule_emb("add", $options{destino}, "LINK2");
my $ping_link2 = ping_emb($options{destino});
my $rule_del_link2 = rule_emb("del", $options{destino}, "LINK2");
if ( $ping_link2 eq "100" ) {
if ( @rule ) {
foreach ( @rule ) {
if ( /LINK2/ ) {
rule_del($_);
}
}
}
}
else {
foreach ( @rule ) {
if ( ! /LINK2/ and ! /LINK3/ ) {
map { rule_add( $_ ) } &r_add_34($options{fwbuilder});
}
else {
print;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment