]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
firewall.cgi: Bring back check for single IP when using DNAT.
authorStefan Schantl <stefan.schantl@ipfire.org>
Fri, 16 Jul 2021 18:20:22 +0000 (20:20 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 5 Sep 2021 08:41:12 +0000 (08:41 +0000)
This check has been removed by commit: bbe8e009b824aef745c9ab9718dce9a1b557f5fc

So it was able to create DNAT rules with a network as target.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
html/cgi-bin/firewall.cgi

index d8adb19f836d9c4c43daf8c19b6dc21aad6b92e8..8e17cef57630bfd73dda3fea429d0805b167f27f 100644 (file)
@@ -569,6 +569,24 @@ sub checktarget
        #check DNAT settings (has to be single Host and single Port or portrange)
        if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
                if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
+                       # Check if a manual entered IP is a single Host (if set)
+                       if ($fwdfwsettings{'grp2'} eq 'tgt_addr') {
+                               # Split input into address and prefix (if provided).
+                               my ($address, $subnet) = split ('/', $fwdfwsettings{$fwdfwsettings{'grp2'}});
+
+                               # Check if a subnet is given.
+                               if ($subnet) {
+                                       # Check if the prefix or subnetmask is for a single host.
+                                       unless ($subnet eq "32" || $subnet eq "255.255.255.255") {
+                                               # Set error message.
+                                               $errormessage=$Lang::tr{'fwdfw dnat error'}."<br>";
+
+                                               # Return the error.
+                                               return $errormessage;
+                                       }
+                               }
+                       }
+
                        #check if Port is a single Port or portrange
                        if ($fwdfwsettings{'nat'} eq 'dnat' &&  $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
                                if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){