Last active
September 9, 2015 20:45
-
-
Save jamesallman/39789d54551936060021 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/perl | |
use strict; | |
use warnings; | |
my %address; | |
my %service; | |
while (<>) { | |
next unless $. > 1; | |
chomp; | |
my @csv = split(/,/); | |
my ($trf_port, $trf_protocol, $l2) = ($csv[5], $csv[4], $csv[3]); | |
$address{$trf_port} = 1; | |
$address{$trf_protocol} = 1; | |
$service{$l2} = 1; | |
} | |
print "config firewall address\n"; | |
foreach ( keys %address ) { | |
if ($_ =~ /swp-(.*)/) { | |
print " edit \"$_\"\n"; | |
print " set subnet $1 255.255.255.255\n"; | |
print " next\n"; | |
} | |
} | |
print "end\n"; | |
print "config firewall service custom\n"; | |
foreach ( keys %service ) { | |
if ($_ =~ /(tcp|udp)-(.*)/) { | |
print " edit \"$_\"\n"; | |
print " set $1-portrange $2\n"; | |
print " next\n"; | |
} | |
} | |
print "end\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment