]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - config/forwardfw/rules.pl
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # Hi folks! I hope this code is useful for all. I needed something to handle #
23 # my VPN Connections in a comfortable way. #
24 # This script builds firewallrules from the webinterface #
25 ###############################################################################
29 no warnings
'uninitialized';
31 # enable only the following on debugging purpose
33 #use CGI::Carp 'fatalsToBrowser';
36 my %defaultNetworks=();
46 my %configoutgoingfw=();
51 require '/var/ipfire/general-functions.pl';
52 require "${General::swroot}/lang.pl";
53 require "${General::swroot}/forward/bin/firewall-lib.pl";
55 my $configfwdfw = "${General::swroot}/forward/config";
56 my $configinput = "${General::swroot}/forward/input";
57 my $configoutgoing = "${General::swroot}/forward/outgoing";
58 my $p2pfile = "${General::swroot}/forward/p2protocols";
59 my $configgrp = "${General::swroot}/fwhosts/customgroups";
60 my $netsettings = "${General::swroot}/ethernet/settings";
65 my ($TYPE,$PROT,$SPROT,$DPROT,$SPORT,$DPORT,$TIME,$TIMEFROM,$TIMETILL,$SRC_TGT);
66 my $CHAIN="FORWARDFW";
68 my $command = 'iptables -A';
71 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
72 &General
::readhash
("$netsettings", \
%defaultNetworks);
73 &General
::readhasharray
($configfwdfw, \
%configfwdfw);
74 &General
::readhasharray
($configinput, \
%configinputfw);
75 &General
::readhasharray
($configoutgoing, \
%configoutgoingfw);
76 &General
::readhasharray
($configgrp, \
%customgrp);
77 &General
::get_aliases
(\
%aliases);
79 #check if we have an internetconnection
80 open (CONN
,"/var/ipfire/red/iface");
83 if (-f
"/var/ipfire/red/active"){
86 open (CONN1
,"/var/ipfire/red/local-ipaddress");
89 ################################
91 ################################
92 my $MODE=1; # 0 - normal operation
93 # 1 - print configline and rules to console
95 ################################
98 if($param eq 'flush'){
100 print " Flushing chains...\n";
105 print " Flushing chains...\n";
109 print " Preparing rules...\n";
113 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
115 system ("/usr/sbin/firewall-policy");
116 }elsif($fwdfwsettings{'POLICY'} eq 'MODE2'){
117 $defaultNetworks{'GREEN_NETMASK'}=&General
::iporsubtocidr
($defaultNetworks{'GREEN_NETMASK'});
118 $green="$defaultNetworks{'GREEN_ADDRESS'}/$defaultNetworks{'GREEN_NETMASK'}";
119 if ($defaultNetworks{'BLUE_DEV'}){
120 $defaultNetworks{'BLUE_NETMASK'}=&General
::iporsubtocidr
($defaultNetworks{'BLUE_NETMASK'});
121 $blue="$defaultNetworks{'BLUE_ADDRESS'}/$defaultNetworks{'BLUE_NETMASK'}";
122 #set default rules for BLUE
123 system ("iptables -A $CHAIN -s $blue -d $green -j RETURN");
125 if ($defaultNetworks{'ORANGE_DEV'}){
126 $defaultNetworks{'ORANGE_NETMASK'}=&General
::iporsubtocidr
($defaultNetworks{'ORANGE_NETMASK'});
127 $orange="$defaultNetworks{'ORANGE_ADDRESS'}/$defaultNetworks{'ORANGE_NETMASK'}";
128 #set default rules for DMZ
129 system ("iptables -A $CHAIN -s $orange -d $green -j RETURN");
130 if ($defaultNetworks{'BLUE_DEV'}){
131 system ("iptables -A $CHAIN -s $orange -d $blue -j RETURN");
135 system ("iptables -A $CHAIN -m state --state NEW -j ACCEPT");
136 system ("/usr/sbin/firewall-policy");
137 system ("/etc/sysconfig/firewall.local reload");
143 system ("iptables -F FORWARDFW");
144 system ("iptables -F INPUTFW");
145 system ("iptables -F OUTGOINGFW");
146 system ("iptables -t nat -F NAT_DESTINATION");
147 system ("iptables -t nat -F NAT_SOURCE");
151 if (! -z
"${General::swroot}/forward/config"){
152 &buildrules
(\
%configfwdfw);
154 if (! -z
"${General::swroot}/forward/input"){
155 &buildrules
(\
%configinputfw);
157 if (! -z
"${General::swroot}/forward/outgoing"){
158 &buildrules
(\
%configoutgoingfw);
160 if (! -z
"${General::swroot}/forward/nat"){
161 &buildrules
(\
%confignatfw);
174 foreach my $key (sort {$a <=> $b} keys %$hash){
175 next if (($$hash{$key}[6] eq 'RED' || $$hash{$key}[6] eq 'RED1') && $conexists eq 'off' );
176 if ($$hash{$key}[28] eq 'ON'){
177 $command='iptables -t nat -A';
178 $natip=&get_nat_ip
($$hash{$key}[29],$$hash{$key}[31]);
179 if($$hash{$key}[31] eq 'dnat'){
181 if ($$hash{$key}[30] =~ /\|/){
182 $$hash{$key}[30]=~ tr/|/,/;
183 $fireport='-m multiport --dport '.$$hash{$key}[30];
185 $fireport='--dport '.$$hash{$key}[30] if ($$hash{$key}[30]>0);
192 if($$hash{$key}[2] eq 'ON'){
194 if ($$hash{$key}[3] eq 'cust_grp_src'){
195 foreach my $grp (sort {$a <=> $b} keys %customgrp){
196 if($customgrp{$grp}[0] eq $$hash{$key}[4]){
197 &get_address
($customgrp{$grp}[3],$customgrp{$grp}[2],"src");
201 &get_address
($$hash{$key}[3],$$hash{$key}[4],"src");
204 if ($$hash{$key}[5] eq 'cust_grp_tgt'){
205 foreach my $grp (sort {$a <=> $b} keys %customgrp){
206 if($customgrp{$grp}[0] eq $$hash{$key}[6]){
207 &get_address
($customgrp{$grp}[3],$customgrp{$grp}[2],"tgt");
210 }elsif($$hash{$key}[5] eq 'ipfire' ){
211 if($$hash{$key}[6] eq 'GREEN'){
212 $targethash{$key}[0]=$defaultNetworks{'GREEN_ADDRESS'};
214 if($$hash{$key}[6] eq 'BLUE'){
215 $targethash{$key}[0]=$defaultNetworks{'BLUE_ADDRESS'};
217 if($$hash{$key}[6] eq 'ORANGE'){
218 $targethash{$key}[0]=$defaultNetworks{'ORANGE_ADDRESS'};
220 if($$hash{$key}[6] eq 'ALL'){
221 $targethash{$key}[0]='0.0.0.0/0';
223 if($$hash{$key}[6] eq 'RED' || $$hash{$key}[6] eq 'RED1'){
224 open(FILE
, "/var/ipfire/red/local-ipaddress")or die "Couldn't open local-ipaddress";
225 $targethash{$key}[0]= <FILE
>;
228 foreach my $alias (sort keys %aliases){
229 if ($$hash{$key}[6] eq $alias){
230 $targethash{$key}[0]=$aliases{$alias}{'IPT'};
235 &get_address
($$hash{$key}[5],$$hash{$key}[6],"tgt");
237 ##get source prot and port
239 $SPROT = &get_prot
($hash,$key);
240 $SPORT = &get_port
($hash,$key);
243 ##get target prot and port
244 $DPROT=&get_prot
($hash,$key);
246 if ($DPROT eq ''){$DPROT=' ';}
247 @DPROT=split(",",$DPROT);
250 if($$hash{$key}[18] eq 'ON'){
251 my ($time1,$time2,$daylight);
252 my $daylight=$$hash{$key}[28];
253 $time1=&get_time
($$hash{$key}[26],$daylight);
254 $time2=&get_time
($$hash{$key}[27],$daylight);
255 if($$hash{$key}[19] ne ''){push (@timeframe,"Mon");}
256 if($$hash{$key}[20] ne ''){push (@timeframe,"Tue");}
257 if($$hash{$key}[21] ne ''){push (@timeframe,"Wed");}
258 if($$hash{$key}[22] ne ''){push (@timeframe,"Thu");}
259 if($$hash{$key}[23] ne ''){push (@timeframe,"Fri");}
260 if($$hash{$key}[24] ne ''){push (@timeframe,"Sat");}
261 if($$hash{$key}[25] ne ''){push (@timeframe,"Sun");}
262 $TIME=join(",",@timeframe);
264 $TIMEFROM="--timestart $time1 ";
265 $TIMETILL="--timestop $time2 ";
266 $TIME="-m time --weekdays $TIME $TIMEFROM $TIMETILL";
270 foreach my $i (0 .. $#{$$hash{$key}}){
271 print "$i: $$hash{$key}[$i] ";
274 print"##################################\n";
275 #print rules to console
276 foreach my $DPROT (@DPROT){
277 $DPORT = &get_port
($hash,$key,$DPROT);
278 if ($SPROT ne ''){$PROT=$SPROT;}else{$PROT=$DPROT;}
279 $PROT="-p $PROT" if ($PROT ne '' && $PROT ne ' ');
280 foreach my $a (sort keys %sourcehash){
281 foreach my $b (sort keys %targethash){
282 if ($sourcehash{$a}[0] ne $targethash{$b}[0] && $targethash{$b}[0] ne 'none' || $sourcehash{$a}[0] eq '0.0.0.0/0.0.0.0'){
283 if($SPROT eq '' || $SPROT eq $DPROT || $DPROT eq ' '){
284 if(substr($sourcehash{$a}[0], 3, 3) ne 'mac' && $sourcehash{$a}[0] ne ''){ $STAG="-s";}
285 if(substr($DPORT, 2, 4) eq 'icmp'){
286 my @icmprule= split(",",substr($DPORT, 12,));
288 if ($$hash{$key}[17] eq 'ON'){
289 print "$command $$hash{$key}[1] $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] --icmp-type $_ $TIME -j LOG\n";
291 print "$command $$hash{$key}[1] $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] --icmp-type $_ $TIME -j $$hash{$key}[0]\n";
293 }elsif($$hash{$key}[28] eq 'ON' && $$hash{$key}[31] eq 'dnat'){
294 $natchain='NAT_DESTINATION';
295 if ($$hash{$key}[17] eq 'ON'){
296 print "$command $natchain $PROT $STAG $sourcehash{$a}[0] $fireport $TIME -j LOG --log-prefix 'DNAT' \n";
298 my ($ip,$sub) =split("/",$targethash{$b}[0]);
299 print "$command $natchain $PROT $STAG $sourcehash{$a}[0] $SPORT $natip $fireport $TIME -j $nat --to $ip$DPORT\n";
302 $fwaccessdport="--dport ".substr($DPORT,1,);
303 }elsif(! $DPORT && $$hash{$key}[30] ne ''){
304 if ($$hash{$key}[30]=~m/|/i){
305 $$hash{$key}[30] =~ s/\|/,/g;
306 $fwaccessdport="-m multiport --dport $$hash{$key}[30]";
308 $fwaccessdport="--dport $$hash{$key}[30]";
311 print "iptables -A FORWARDFW $PROT -i $con $STAG $sourcehash{$a}[0] -d $ip $fwaccessdport $TIME -j $$hash{$key}[0]\n";
313 }elsif($$hash{$key}[28] eq 'ON' && $$hash{$key}[31] eq 'snat'){
314 $natchain='NAT_SOURCE';
315 print "$command $natchain $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] $DPORT $TIME -j $nat --to $natip\n";
317 if ($$hash{$key}[17] eq 'ON'){
318 print "$command $natchain $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] $DPORT $TIME -j LOG\n";
320 print "iptables -A $$hash{$key}[1] $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] $DPORT $TIME -j $$hash{$key}[0]\n";
327 }elsif($MODE eq '0'){
328 foreach my $DPROT (@DPROT){
329 $DPORT = &get_port
($hash,$key,$DPROT);
330 if ($SPROT ne ''){$PROT=$SPROT;}else{$PROT=$DPROT;}
331 $PROT="-p $PROT" if ($PROT ne '' && $PROT ne ' ');
332 foreach my $a (sort keys %sourcehash){
333 foreach my $b (sort keys %targethash){
334 if ($sourcehash{$a}[0] ne $targethash{$b}[0] && $targethash{$b}[0] ne 'none' || $sourcehash{$a}[0] eq '0.0.0.0/0.0.0.0'){
335 if($SPROT eq '' || $SPROT eq $DPROT || $DPROT eq ' '){
336 if(substr($sourcehash{$a}[0], 3, 3) ne 'mac' && $sourcehash{$a}[0] ne ''){ $STAG="-s";}
337 if(substr($DPORT, 2, 4) eq 'icmp'){
338 my @icmprule= split(",",substr($DPORT, 12,));
340 if ($$hash{$key}[17] eq 'ON'){
341 system ("$command $$hash{$key}[1] $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] -- icmp-type $_ $TIME -j LOG");
343 system ("$command $$hash{$key}[1] $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] --icmp-type $_ $TIME -j $$hash{$key}[0]");
345 }elsif($$hash{$key}[28] eq 'ON' && $$hash{$key}[31] eq 'dnat'){
346 $natchain='NAT_DESTINATION';
347 if ($$hash{$key}[17] eq 'ON'){
348 system "$command $natchain $PROT $STAG $sourcehash{$a}[0] $fireport $TIME -j LOG --log-prefix 'DNAT' \n";
350 my ($ip,$sub) =split("/",$targethash{$b}[0]);
351 system "$command $natchain $PROT $STAG $sourcehash{$a}[0] $SPORT $natip $fireport $TIME -j $nat --to $ip$DPORT\n";
354 $fwaccessdport="--dport ".substr($DPORT,1,);
355 }elsif(! $DPORT && $$hash{$key}[30] ne ''){
356 if ($$hash{$key}[30]=~m/|/i){
357 $$hash{$key}[30] =~ s/\|/,/g;
358 $fwaccessdport="-m multiport --dport $$hash{$key}[30]";
360 $fwaccessdport="--dport $$hash{$key}[30]";
363 system "iptables -A FORWARDFW $PROT -i $con $STAG $sourcehash{$a}[0] -d $ip $fwaccessdport $TIME -j $$hash{$key}[0]\n";
365 }elsif($$hash{$key}[28] eq 'ON' && $$hash{$key}[31] eq 'snat'){
366 $natchain='NAT_SOURCE';
367 system "$command $natchain $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] $DPORT $TIME -j $nat --to $natip\n";
369 if ($$hash{$key}[17] eq 'ON'){
370 system "$command $natchain $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] $DPORT $TIME -j LOG\n";
372 system "iptables -A $$hash{$key}[1] $PROT $STAG $sourcehash{$a}[0] $SPORT -d $targethash{$b}[0] $DPORT $TIME -j $$hash{$key}[0]\n";
393 if($val eq 'RED' || $val eq 'GREEN' || $val eq 'ORANGE' || $val eq 'BLUE'){
394 $result=$defaultNetworks{$val.'_ADDRESS'};
395 }elsif($val eq 'ALL'){
397 }elsif($val eq 'Default IP' && $type eq 'dnat'){
398 $result='-d '.$redip;
399 }elsif($val eq 'Default IP' && $type eq 'snat'){
402 foreach my $al (sort keys %aliases){
403 if($val eq $al && $type eq 'dnat'){
404 $result='-d '.$aliases{$al}{'IPT'};
405 }elsif($val eq $al && $type eq 'snat'){
406 $result=$aliases{$al}{'IPT'};
419 $minutes = &utcmin
($val);
420 $ruletime = $minutes + &time_get_utc
($val);
421 if ($ruletime < 0){$ruletime +=1440;}
422 if ($ruletime > 1440){$ruletime -=1440;}
423 $time=sprintf "%02d:%02d", $ruletime / 60, $ruletime % 60;
428 # Calculates the UTCtime from a given time
430 my @localtime=localtime(time);
431 my @gmtime=gmtime(time);
432 my $diff = ($gmtime[2]*60+$gmtime[1]%60)-($localtime[2]*60+$localtime[1]%60);
438 my ($hrs,$min) = split(":",$ruletime);
439 my $newtime = $hrs*60+$min;
446 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
449 my $CMD = "-m ipp2p";
450 foreach my $p2pentry (sort @p2ps) {
451 my @p2pline = split( /\;/, $p2pentry );
452 if ( $fwdfwsettings{'POLICY'} eq 'MODE1' ) {
454 if ("$p2pline[2]" eq "on") {
455 $P2PSTRING = "$P2PSTRING --$p2pline[1]";
459 if ("$p2pline[2]" eq "off") {
460 $P2PSTRING = "$P2PSTRING --$p2pline[1]";
466 print"/sbin/iptables -A FORWARDFW $CMD $P2PSTRING -j $DO\n";
470 system("/sbin/iptables -A FORWARDFW $CMD $P2PSTRING -j $DO");
476 my $base=shift; #source of checking ($configfwdfw{$key}[x] or groupkey
478 my $type=shift; #src or tgt
485 my $key = &General
::findhasharraykey
($hash);
486 if($base eq 'src_addr' || $base eq 'tgt_addr' ){
487 if (&General
::validmac
($base2)){
488 $$hash{$key}[0] = "-m mac --mac-source $base2";
490 $$hash{$key}[0] = $base2;
492 }elsif($base eq 'std_net_src' || $base eq 'std_net_tgt' || $base eq 'Standard Network'){
493 $$hash{$key}[0]=&fwlib
::get_std_net_ip
($base2,$con);
494 }elsif($base eq 'cust_net_src' || $base eq 'cust_net_tgt' || $base eq 'Custom Network'){
495 $$hash{$key}[0]=&fwlib
::get_net_ip
($base2);
496 }elsif($base eq 'cust_host_src' || $base eq 'cust_host_tgt' || $base eq 'Custom Host'){
497 $$hash{$key}[0]=&fwlib
::get_host_ip
($base2,$type);
498 }elsif($base eq 'ovpn_net_src' || $base eq 'ovpn_net_tgt' || $base eq 'OpenVPN static network'){
499 $$hash{$key}[0]=&fwlib
::get_ovpn_net_ip
($base2,1);
500 }elsif($base eq 'ovpn_host_src' ||$base eq 'ovpn_host_tgt' || $base eq 'OpenVPN static host'){
501 $$hash{$key}[0]=&fwlib
::get_ovpn_host_ip
($base2,33);
502 }elsif($base eq 'ovpn_n2n_src' ||$base eq 'ovpn_n2n_tgt' || $base eq 'OpenVPN N-2-N'){
503 $$hash{$key}[0]=&fwlib
::get_ovpn_n2n_ip
($base2,11);
504 }elsif($base eq 'ipsec_net_src' || $base eq 'ipsec_net_tgt' || $base eq 'IpSec Network'){
505 $$hash{$key}[0]=&fwlib
::get_ipsec_net_ip
($base2,11);
506 }elsif($base eq 'ipfire_src' ){
507 if($base2 eq 'GREEN'){
508 $$hash{$key}[0]=$defaultNetworks{'GREEN_ADDRESS'};
510 if($base2 eq 'BLUE'){
511 $$hash{$key}[0]=$defaultNetworks{'BLUE_ADDRESS'};
513 if($base2 eq 'ORANGE'){
514 $$hash{$key}[0]=$defaultNetworks{'ORANGE_ADDRESS'};
517 $$hash{$key}[0]='0.0.0.0/0';
519 if($base2 eq 'RED' || $base2 eq 'RED1'){
520 open(FILE
, "/var/ipfire/red/local-ipaddress")or die "Couldn't open local-ipaddress";
521 $$hash{$key}[0]= <FILE
>;
524 foreach my $alias (sort keys %aliases){
525 if ($base2 eq $alias){
526 $$hash{$key}[0]=$aliases{$alias}{'IPT'};
536 if ($$hash{$key}[7] eq 'ON' && $SRC_TGT eq 'SRC'){
537 if ($$hash{$key}[10] ne ''){
538 return"$$hash{$key}[8]";
539 }elsif($$hash{$key}[9] ne ''){
540 return"$$hash{$key}[8]";
542 return "$$hash{$key}[8]";
544 }elsif($$hash{$key}[11] eq 'ON' && $SRC_TGT eq ''){
545 if ($$hash{$key}[14] eq 'TGT_PORT'){
546 if ($$hash{$key}[15] ne ''){
547 return "$$hash{$key}[12]";
548 }elsif($$hash{$key}[13] ne ''){
549 return "$$hash{$key}[12]";
551 return "$$hash{$key}[12]";
553 }elsif($$hash{$key}[14] eq 'cust_srv'){
554 return &fwlib
::get_srv_prot
($$hash{$key}[15]);
556 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
557 return &fwlib
::get_srvgrp_prot
($$hash{$key}[15]);
561 if ($SRC_TGT eq '' && $$hash{$key}[31] eq 'dnat' && $$hash{$key}[11] eq '' && $$hash{$key}[12] ne ''){
562 return "$$hash{$key}[12]";
570 if ($$hash{$key}[7] eq 'ON' && $SRC_TGT eq 'SRC'){
571 if ($$hash{$key}[10] ne ''){
572 $$hash{$key}[10] =~ s/\|/,/g;
573 if(index($$hash{$key}[10],",") > 0){
574 return "-m multiport --sport $$hash{$key}[10] ";
576 if($$hash{$key}[28] ne 'ON' || ($$hash{$key}[28] eq 'ON' && $$hash{$key}[31] eq 'snat') ||($$hash{$key}[28] eq 'ON' && $$hash{$key}[31] eq 'dnat') ){
577 return "--sport $$hash{$key}[10] ";
579 return ":$$hash{$key}[10]";
582 }elsif($$hash{$key}[9] ne '' && $$hash{$key}[9] ne 'All ICMP-Types'){
583 return "--icmp-type $$hash{$key}[9] ";
584 }elsif($$hash{$key}[9] eq 'All ICMP-Types'){
587 }elsif($$hash{$key}[11] eq 'ON' && $SRC_TGT eq ''){
588 if($$hash{$key}[14] eq 'TGT_PORT'){
589 if ($$hash{$key}[15] ne ''){
590 $$hash{$key}[15] =~ s/\|/,/g;
591 if(index($$hash{$key}[15],",") > 0){
592 return "-m multiport --dport $$hash{$key}[15] ";
594 if($$hash{$key}[28] ne 'ON' || ($$hash{$key}[28] eq 'ON' && $$hash{$key}[31] eq 'snat') ){
595 return "--dport $$hash{$key}[15] ";
597 $$hash{$key}[15] =~ s/\:/-/g;
598 return ":$$hash{$key}[15]";
601 }elsif($$hash{$key}[13] ne '' && $$hash{$key}[13] ne 'All ICMP-Types'){
602 return "--icmp-type $$hash{$key}[13] ";
603 }elsif($$hash{$key}[13] ne '' && $$hash{$key}[13] eq 'All ICMP-Types'){
606 }elsif($$hash{$key}[14] eq 'cust_srv'){
607 if ($prot ne 'ICMP'){
608 if($$hash{$key}[31] eq 'dnat'){
609 return ":".&fwlib
::get_srv_port
($$hash{$key}[15],1,$prot);
611 return "--dport ".&fwlib
::get_srv_port
($$hash{$key}[15],1,$prot);
613 }elsif($prot eq 'ICMP' && $$hash{$key}[15] ne 'All ICMP-Types'){
614 return "--icmp-type ".&fwlib
::get_srv_port
($$hash{$key}[15],3,$prot);
615 }elsif($prot eq 'ICMP' && $$hash{$key}[15] eq 'All ICMP-Types'){
618 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
619 if ($prot ne 'ICMP'){
620 return &fwlib
::get_srvgrp_port
($$hash{$key}[15],$prot);
622 elsif($prot eq 'ICMP'){
623 return &fwlib
::get_srvgrp_port
($$hash{$key}[15],$prot);