]> git.ipfire.org Git - people/dweismueller/ipfire-2.x.git/blobdiff - config/firewall/rules.pl
firewall: Fix SNAT rules that use a default network as source
[people/dweismueller/ipfire-2.x.git] / config / firewall / rules.pl
index a475e2d60ea7cb880746471ea8623e10cb64ffbd..97b8897af87bba6f84ec2e961e3bbb62849a17ef 100755 (executable)
@@ -368,20 +368,12 @@ sub buildrules {
                                                push(@source_options, ("-s", $source));
                                        }
 
-                                       if ($source_intf) {
-                                               push(@source_options, ("-i", $source_intf));
-                                       }
-
                                        # Prepare destination options.
                                        my @destination_options = ();
                                        if ($destination) {
                                                push(@destination_options, ("-d", $destination));
                                        }
 
-                                       if ($destination_intf) {
-                                               push(@destination_options, ("-o", $destination_intf));
-                                       }
-
                                        # Add time constraint options.
                                        push(@options, @time_options);
 
@@ -476,6 +468,17 @@ sub buildrules {
                                                }
                                        }
 
+                                       # Add source and destination interface to the filter rules.
+                                       # These are supposed to help filtering forged packets that originate
+                                       # from BLUE with an IP address from GREEN for instance.
+                                       if ($source_intf) {
+                                               push(@source_options, ("-i", $source_intf));
+                                       }
+
+                                       if ($destination_intf) {
+                                               push(@destination_options, ("-o", $destination_intf));
+                                       }
+
                                        push(@options, @source_options);
                                        push(@options, @destination_options);