]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/firewall/rules.pl
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
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 ###############################################################################
24 no warnings
'uninitialized' ;
26 require '/var/ipfire/general-functions.pl' ;
27 require "${General::swroot}/lang.pl" ;
28 require "/usr/lib/firewall/firewall-lib.pl" ;
30 # Set to one to enable debugging mode.
34 my %defaultNetworks =();
44 my %configoutgoingfw =();
50 my $configfwdfw = "${General::swroot}/firewall/config" ;
51 my $configinput = "${General::swroot}/firewall/input" ;
52 my $configoutgoing = "${General::swroot}/firewall/outgoing" ;
53 my $p2pfile = "${General::swroot}/firewall/p2protocols" ;
54 my $configgrp = "${General::swroot}/fwhosts/customgroups" ;
55 my $netsettings = "${General::swroot}/ethernet/settings" ;
56 my $errormessage = '' ;
60 my ( $TYPE , $PROT , $SPROT , $DPROT , $SPORT , $DPORT , $TIME , $TIMEFROM , $TIMETILL , $SRC_TGT );
61 my $CHAIN = "FORWARDFW" ;
62 my $conexists = 'off' ;
63 my $command = 'iptables --wait -A' ;
67 & General
:: readhash
( "${General::swroot}/firewall/settings" , \
%fwdfwsettings );
68 & General
:: readhash
( " $netsettings " , \
%defaultNetworks );
69 & General
:: readhasharray
( $configfwdfw , \
%configfwdfw );
70 & General
:: readhasharray
( $configinput , \
%configinputfw );
71 & General
:: readhasharray
( $configoutgoing , \
%configoutgoingfw );
72 & General
:: readhasharray
( $configgrp , \
%customgrp );
73 & General
:: get_aliases
( \
%aliases );
75 #check if we have an internetconnection
76 open ( CONN
, "/var/ipfire/red/iface" );
80 if (- f
"/var/ipfire/red/active" ){
84 open ( CONN1
, "/var/ipfire/red/local-ipaddress" );
91 my $MODE =! $DEBUG ; # 0 - normal operation
92 # 1 - print configline and rules to console
97 if ( $param eq 'flush' ){
99 print " Flushing chains... \n " ;
104 print " Flushing chains... \n " ;
108 print " Preparing rules... \n " ;
112 if ( $fwdfwsettings { 'POLICY' } eq 'MODE1' ){
114 run
( "/usr/sbin/firewall-policy" );
115 } elsif ( $fwdfwsettings { 'POLICY' } eq 'MODE2' ){
117 run
( "/usr/sbin/firewall-policy" );
123 # Executes or prints the given shell command.
134 run
( "iptables --wait -F FORWARDFW" );
135 run
( "iptables --wait -F INPUTFW" );
136 run
( "iptables --wait -F OUTGOINGFW" );
137 run
( "iptables --wait -t nat -F NAT_DESTINATION" );
138 run
( "iptables --wait -t nat -F NAT_SOURCE" );
142 if (! - z
"${General::swroot}/firewall/config" ){
143 & buildrules
( \
%configfwdfw );
145 if (! - z
"${General::swroot}/firewall/input" ){
146 & buildrules
( \
%configinputfw );
148 if (! - z
"${General::swroot}/firewall/outgoing" ){
149 & buildrules
( \
%configoutgoingfw );
163 foreach my $key ( sort { $a <=> $b } keys % $hash ){
164 next if (($ $hash { $key }[ 6 ] eq 'RED' || $ $hash { $key }[ 6 ] eq 'RED1' ) && $conexists eq 'off' );
165 $command = "iptables --wait -A" ;
166 if ($ $hash { $key }[ 28 ] eq 'ON' ){
167 $command = 'iptables --wait -t nat -A' ;
168 $natip =& get_nat_ip
($ $hash { $key }[ 29 ],$ $hash { $key }[ 31 ]);
169 if ($ $hash { $key }[ 31 ] eq 'dnat' ){
171 if ($ $hash { $key }[ 30 ] =~ /\|/ ){
172 $ $hash { $key }[ 30 ]=~ tr/|/,/ ;
173 $fireport = '-m multiport --dport ' .$ $hash { $key }[ 30 ];
175 $fireport = '--dport ' .$ $hash { $key }[ 30 ] if ($ $hash { $key }[ 30 ]> 0 );
182 if ($ $hash { $key }[ 2 ] eq 'ON' ){
184 if ($ $hash { $key }[ 3 ] eq 'cust_grp_src' ){
185 foreach my $grp ( sort { $a <=> $b } keys %customgrp ){
186 if ( $customgrp { $grp }[ 0 ] eq $ $hash { $key }[ 4 ]){
187 & get_address
( $customgrp { $grp }[ 3 ], $customgrp { $grp }[ 2 ], "src" );
191 & get_address
($ $hash { $key }[ 3 ],$ $hash { $key }[ 4 ], "src" );
194 if ($ $hash { $key }[ 5 ] eq 'cust_grp_tgt' ){
195 foreach my $grp ( sort { $a <=> $b } keys %customgrp ){
196 if ( $customgrp { $grp }[ 0 ] eq $ $hash { $key }[ 6 ]){
197 & get_address
( $customgrp { $grp }[ 3 ], $customgrp { $grp }[ 2 ], "tgt" );
200 } elsif ($ $hash { $key }[ 5 ] eq 'ipfire' ){
201 if ($ $hash { $key }[ 6 ] eq 'GREEN' ){
202 $targethash { $key }[ 0 ]= $defaultNetworks { 'GREEN_ADDRESS' };
204 if ($ $hash { $key }[ 6 ] eq 'BLUE' ){
205 $targethash { $key }[ 0 ]= $defaultNetworks { 'BLUE_ADDRESS' };
207 if ($ $hash { $key }[ 6 ] eq 'ORANGE' ){
208 $targethash { $key }[ 0 ]= $defaultNetworks { 'ORANGE_ADDRESS' };
210 if ($ $hash { $key }[ 6 ] eq 'ALL' ){
211 $targethash { $key }[ 0 ]= '0.0.0.0/0' ;
213 if ($ $hash { $key }[ 6 ] eq 'RED' || $ $hash { $key }[ 6 ] eq 'RED1' ){
214 open ( FILE
, "/var/ipfire/red/local-ipaddress" ) or die "Couldn't open local-ipaddress" ;
215 $targethash { $key }[ 0 ]= < FILE
>;
218 foreach my $alias ( sort keys %aliases ){
219 if ($ $hash { $key }[ 6 ] eq $alias ){
220 $targethash { $key }[ 0 ]= $aliases { $alias }{ 'IPT' };
225 & get_address
($ $hash { $key }[ 5 ],$ $hash { $key }[ 6 ], "tgt" );
227 ##get source prot and port
229 $SPORT = & get_port
( $hash , $key );
232 ##get target prot and port
233 $DPROT =& get_prot
( $hash , $key );
235 if ( $DPROT eq '' ){ $DPROT = ' ' ;}
236 @DPROT = split ( "," , $DPROT );
239 if ($ $hash { $key }[ 18 ] eq 'ON' ){
240 my ( $time1 , $time2 , $daylight );
241 my $daylight =$ $hash { $key }[ 28 ];
242 $time1 =& get_time
($ $hash { $key }[ 26 ], $daylight );
243 $time2 =& get_time
($ $hash { $key }[ 27 ], $daylight );
244 if ($ $hash { $key }[ 19 ] ne '' ){ push ( @timeframe , "Mon" );}
245 if ($ $hash { $key }[ 20 ] ne '' ){ push ( @timeframe , "Tue" );}
246 if ($ $hash { $key }[ 21 ] ne '' ){ push ( @timeframe , "Wed" );}
247 if ($ $hash { $key }[ 22 ] ne '' ){ push ( @timeframe , "Thu" );}
248 if ($ $hash { $key }[ 23 ] ne '' ){ push ( @timeframe , "Fri" );}
249 if ($ $hash { $key }[ 24 ] ne '' ){ push ( @timeframe , "Sat" );}
250 if ($ $hash { $key }[ 25 ] ne '' ){ push ( @timeframe , "Sun" );}
251 $TIME = join ( "," , @timeframe );
253 $TIMEFROM = "--timestart $time1 " ;
254 $TIMETILL = "--timestop $time2 " ;
255 $TIME = "-m time --weekdays $TIME $TIMEFROM $TIMETILL " ;
257 foreach my $DPROT ( @DPROT ){
258 $DPORT = & get_port
( $hash , $key , $DPROT );
260 $PROT = "-p $PROT " if ( $PROT ne '' && $PROT ne ' ' );
261 if ( $DPROT ne 'TCP' && $DPROT ne 'UDP' && $DPROT ne 'ICMP' ){
264 foreach my $a ( sort keys %sourcehash ){
265 foreach my $b ( sort keys %targethash ){
266 if (! $sourcehash { $a }[ 0 ] || ! $targethash { $b }[ 0 ] || ( $natip eq '-d ' && $ $hash { $key }[ 28 ] eq 'ON' ) || (! $natip && $ $hash { $key }[ 28 ] eq 'ON' )){
267 #Skip rules when no RED IP is set (DHCP,DSL)
270 next if ( $targethash { $b }[ 0 ] eq 'none' );
272 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' ){
274 if ( substr ( $sourcehash { $a }[ 0 ], 3 , 3 ) ne 'mac' && $sourcehash { $a }[ 0 ] ne '' ){ $STAG = "-s" ;}
276 if ( substr ( $DPORT , 2 , 4 ) eq 'icmp' ){
277 my @icmprule = split ( "," , substr ( $DPORT , 12 ,));
279 $icmptype = "--icmp-type " ;
284 if ($ $hash { $key }[ 17 ] eq 'ON' ){
285 run
( " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $icmptype $_ $TIME -j LOG" );
287 run
( " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $icmptype $_ $TIME -j $ $hash { $key }[0]" );
289 #PROCESS DNAT RULE (Portforward)
290 } elsif ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'dnat' ){
291 $natchain = 'NAT_DESTINATION' ;
292 if ($ $hash { $key }[ 17 ] eq 'ON' ){
293 run
( " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT $natip $fireport $TIME -j LOG --log-prefix 'DNAT'" );
295 my ( $ip , $sub ) = split ( "/" , $targethash { $b }[ 0 ]);
296 #Process NAT with servicegroup used
297 if ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'dnat' && $ $hash { $key }[ 14 ] eq 'cust_srvgrp' ){
298 run
( " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT $natip $fireport $TIME -j $nat --to-destination $ip $DPORT " );
299 $fwaccessdport = $DPORT ;
301 run
( " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT $natip $fireport $TIME -j $nat --to-destination $ip $DPORT " );
304 $fwaccessdport = "--dport " . substr ( $DPORT , 1 ,);
305 } elsif (! $DPORT && $ $hash { $key }[ 30 ] ne '' ){
306 if ($ $hash { $key }[ 30 ]=~ m/|/i ){
307 $ $hash { $key }[ 30 ] =~ s/\|/,/g ;
308 $fwaccessdport = "-m multiport --dport $ $hash { $key }[30]" ;
310 $fwaccessdport = "--dport $ $hash { $key }[30]" ;
314 run
( "iptables --wait -A FORWARDFW $PROT $STAG $sourcehash { $a }[0] -d $ip $fwaccessdport $TIME -j $ $hash { $key }[0]" );
317 } elsif ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'snat' ){
318 $natchain = 'NAT_SOURCE' ;
319 if ($ $hash { $key }[ 17 ] eq 'ON' ){
320 run
( " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j LOG --log-prefix 'SNAT'" );
322 run
( " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j $nat --to-source $natip " );
324 #PROCESS EVERY OTHER RULE (If NOT ICMP, else the rule would be applied double)
325 if ( $PROT ne '-p ICMP' ){
326 if ($ $hash { $key }[ 17 ] eq 'ON' && $ $hash { $key }[ 28 ] ne 'ON' ){
327 run
( " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j LOG" );
329 run
( "iptables --wait -A $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j $ $hash { $key }[0]" );
331 #PROCESS Prot ICMP and type = All ICMP-Types
332 if ( $PROT eq '-p ICMP' && $ $hash { $key }[ 9 ] eq 'All ICMP-Types' ){
333 if ($ $hash { $key }[ 17 ] eq 'ON' && $ $hash { $key }[ 28 ] ne 'ON' ){
334 run
( " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j LOG" );
336 run
( "iptables --wait -A $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j $ $hash { $key }[0]" );
357 if ( $val eq 'RED' || $val eq 'GREEN' || $val eq 'ORANGE' || $val eq 'BLUE' ){
358 $result = $defaultNetworks { $val . '_ADDRESS' };
359 } elsif ( $val eq 'ALL' ){
361 } elsif ( $val eq 'Default IP' && $type eq 'dnat' ){
362 $result = '-d ' . $redip ;
363 } elsif ( $val eq 'Default IP' && $type eq 'snat' ){
366 foreach my $al ( sort keys %aliases ){
367 if ( $val eq $al && $type eq 'dnat' ){
368 $result = '-d ' . $aliases { $al }{ 'IPT' };
369 } elsif ( $val eq $al && $type eq 'snat' ){
370 $result = $aliases { $al }{ 'IPT' };
383 $minutes = & utcmin
( $val );
384 $ruletime = $minutes + & time_get_utc
( $val );
385 if ( $ruletime < 0 ){ $ruletime += 1440 ;}
386 if ( $ruletime > 1440 ){ $ruletime -= 1440 ;}
387 $time = sprintf " %02d : %02d " , $ruletime / 60 , $ruletime % 60 ;
392 # Calculates the UTCtime from a given time
394 my @localtime = localtime ( time );
395 my @gmtime = gmtime ( time );
396 my $diff = ( $gmtime [ 2 ]* 60 + $gmtime [ 1 ] %60 )-( $localtime [ 2 ]* 60 + $localtime [ 1 ] %60 );
402 my ( $hrs , $min ) = split ( ":" , $ruletime );
403 my $newtime = $hrs * 60 + $min ;
410 open ( FILE
, "< $p2pfile " ) or die "Unable to read $p2pfile " ;
413 my $CMD = "-m ipp2p" ;
414 foreach my $p2pentry ( sort @p2ps ) {
415 my @p2pline = split ( /\;/ , $p2pentry );
416 if ( $fwdfwsettings { 'POLICY' } eq 'MODE1' ) {
418 if ( " $p2pline [2]" eq "on" ) {
419 $P2PSTRING = " $P2PSTRING -- $p2pline [1]" ;
423 if ( " $p2pline [2]" eq "off" ) {
424 $P2PSTRING = " $P2PSTRING -- $p2pline [1]" ;
430 run
( "/sbin/iptables --wait -A FORWARDFW $CMD $P2PSTRING -j $DO " );
435 my $base = shift ; #source of checking ($configfwdfw{$key}[x] or groupkey
437 my $type = shift ; #src or tgt
444 my $key = & General
:: findhasharraykey
( $hash );
445 if ( $base eq 'src_addr' || $base eq 'tgt_addr' ){
446 if (& General
:: validmac
( $base2 )){
447 $ $hash { $key }[ 0 ] = "-m mac --mac-source $base2 " ;
449 $ $hash { $key }[ 0 ] = $base2 ;
451 } elsif ( $base eq 'std_net_src' || $base eq 'std_net_tgt' || $base eq 'Standard Network' ){
452 $ $hash { $key }[ 0 ]=& fwlib
:: get_std_net_ip
( $base2 , $con );
453 } elsif ( $base eq 'cust_net_src' || $base eq 'cust_net_tgt' || $base eq 'Custom Network' ){
454 $ $hash { $key }[ 0 ]=& fwlib
:: get_net_ip
( $base2 );
455 } elsif ( $base eq 'cust_host_src' || $base eq 'cust_host_tgt' || $base eq 'Custom Host' ){
456 $ $hash { $key }[ 0 ]=& fwlib
:: get_host_ip
( $base2 , $type );
457 } elsif ( $base eq 'ovpn_net_src' || $base eq 'ovpn_net_tgt' || $base eq 'OpenVPN static network' ){
458 $ $hash { $key }[ 0 ]=& fwlib
:: get_ovpn_net_ip
( $base2 , 1 );
459 } elsif ( $base eq 'ovpn_host_src' || $base eq 'ovpn_host_tgt' || $base eq 'OpenVPN static host' ){
460 $ $hash { $key }[ 0 ]=& fwlib
:: get_ovpn_host_ip
( $base2 , 33 );
461 } elsif ( $base eq 'ovpn_n2n_src' || $base eq 'ovpn_n2n_tgt' || $base eq 'OpenVPN N-2-N' ){
462 $ $hash { $key }[ 0 ]=& fwlib
:: get_ovpn_n2n_ip
( $base2 , 11 );
463 } elsif ( $base eq 'ipsec_net_src' || $base eq 'ipsec_net_tgt' || $base eq 'IpSec Network' ){
464 $ $hash { $key }[ 0 ]=& fwlib
:: get_ipsec_net_ip
( $base2 , 11 );
465 } elsif ( $base eq 'ipfire_src' ){
466 if ( $base2 eq 'GREEN' ){
467 $ $hash { $key }[ 0 ]= $defaultNetworks { 'GREEN_ADDRESS' };
469 if ( $base2 eq 'BLUE' ){
470 $ $hash { $key }[ 0 ]= $defaultNetworks { 'BLUE_ADDRESS' };
472 if ( $base2 eq 'ORANGE' ){
473 $ $hash { $key }[ 0 ]= $defaultNetworks { 'ORANGE_ADDRESS' };
476 $ $hash { $key }[ 0 ]= '0.0.0.0/0' ;
478 if ( $base2 eq 'RED' || $base2 eq 'RED1' ){
479 open ( FILE
, "/var/ipfire/red/local-ipaddress" );
480 $ $hash { $key }[ 0 ]= < FILE
>;
483 foreach my $alias ( sort keys %aliases ){
484 if ( $base2 eq $alias ){
485 $ $hash { $key }[ 0 ]= $aliases { $alias }{ 'IPT' };
495 #check AH,GRE,ESP or ICMP
496 if ($ $hash { $key }[ 7 ] ne 'ON' && $ $hash { $key }[ 11 ] ne 'ON' ){
497 return "$ $hash { $key }[8]" ;
499 if ($ $hash { $key }[ 7 ] eq 'ON' || $ $hash { $key }[ 11 ] eq 'ON' ){
500 #check if servicegroup or service
501 if ($ $hash { $key }[ 14 ] eq 'cust_srv' ){
502 return & fwlib
:: get_srv_prot
($ $hash { $key }[ 15 ]);
503 } elsif ($ $hash { $key }[ 14 ] eq 'cust_srvgrp' ){
504 return & fwlib
:: get_srvgrp_prot
($ $hash { $key }[ 15 ]);
505 } elsif (($ $hash { $key }[ 10 ] ne '' || $ $hash { $key }[ 15 ] ne '' ) && $ $hash { $key }[ 8 ] eq '' ){ #when ports are used and prot set to "all"
507 } elsif (($ $hash { $key }[ 10 ] ne '' || $ $hash { $key }[ 15 ] ne '' ) && ($ $hash { $key }[ 8 ] eq 'TCP' || $ $hash { $key }[ 8 ] eq 'UDP' )){ #when ports are used and prot set to "tcp" or "udp"
508 return "$ $hash { $key }[8]" ;
509 } elsif (($ $hash { $key }[ 10 ] eq '' && $ $hash { $key }[ 15 ] eq '' ) && $ $hash { $key }[ 8 ] ne 'ICMP' ){ #when ports are NOT used and prot NOT set to "ICMP"
510 return "$ $hash { $key }[8]" ;
512 return "$ $hash { $key }[8]" ;
516 if ( $SRC_TGT eq '' && $ $hash { $key }[ 31 ] eq 'dnat' && $ $hash { $key }[ 11 ] eq '' && $ $hash { $key }[ 12 ] ne '' ){
517 return "$ $hash { $key }[8]" ;
525 #Get manual defined Ports from SOURCE
526 if ($ $hash { $key }[ 7 ] eq 'ON' && $SRC_TGT eq 'SRC' ){
527 if ($ $hash { $key }[ 10 ] ne '' ){
528 $ $hash { $key }[ 10 ] =~ s/\|/,/g ;
529 if ( index ($ $hash { $key }[ 10 ], "," ) > 0 ){
530 return "-m multiport --sport $ $hash { $key }[10] " ;
532 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' ) ){
533 return "--sport $ $hash { $key }[10] " ;
535 return ":$ $hash { $key }[10]" ;
539 #Get manual ports from TARGET
540 } elsif ($ $hash { $key }[ 11 ] eq 'ON' && $SRC_TGT eq '' ){
541 if ($ $hash { $key }[ 14 ] eq 'TGT_PORT' ){
542 if ($ $hash { $key }[ 15 ] ne '' ){
543 $ $hash { $key }[ 15 ] =~ s/\|/,/g ;
544 if ( index ($ $hash { $key }[ 15 ], "," ) > 0 ){
545 return "-m multiport --dport $ $hash { $key }[15] " ;
547 if ($ $hash { $key }[ 28 ] ne 'ON' || ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'snat' ) ){
548 return "--dport $ $hash { $key }[15] " ;
550 $ $hash { $key }[ 15 ] =~ s/\:/-/g ;
551 return ":$ $hash { $key }[15]" ;
555 #Get ports defined in custom Service (firewall-groups)
556 } elsif ($ $hash { $key }[ 14 ] eq 'cust_srv' ){
557 if ( $prot ne 'ICMP' ){
558 if ($ $hash { $key }[ 31 ] eq 'dnat' && $ $hash { $key }[ 28 ] eq 'ON' ){
559 my $ports =& fwlib
:: get_srv_port
($ $hash { $key }[ 15 ], 1 , $prot );
563 return "--dport " .& fwlib
:: get_srv_port
($ $hash { $key }[ 15 ], 1 , $prot );
565 } elsif ( $prot eq 'ICMP' && $ $hash { $key }[ 11 ] eq 'ON' ){ #When PROT is ICMP and "use targetport is checked, this is an icmp-service
566 return "--icmp-type " .& fwlib
:: get_srv_port
($ $hash { $key }[ 15 ], 3 , $prot );
568 #Get ports from services which are used in custom servicegroups (firewall-groups)
569 } elsif ($ $hash { $key }[ 14 ] eq 'cust_srvgrp' ){
570 if ( $prot ne 'ICMP' ){
571 return & fwlib
:: get_srvgrp_port
($ $hash { $key }[ 15 ], $prot );
573 elsif ( $prot eq 'ICMP' ){
574 return & fwlib
:: get_srvgrp_port
($ $hash { $key }[ 15 ], $prot );
579 if ($ $hash { $key }[ 7 ] ne 'ON' && $ $hash { $key }[ 11 ] ne 'ON' && $SRC_TGT eq '' ){
580 if ($ $hash { $key }[ 9 ] ne '' && $ $hash { $key }[ 9 ] ne 'All ICMP-Types' ){
581 return "--icmp-type $ $hash { $key }[9] " ;
582 } elsif ($ $hash { $key }[ 9 ] eq 'All ICMP-Types' ){