Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Firewall Rules Interface Order

    Scheduled Pinned Locked Moved 2.3-RC Snapshot Feedback and Issues - ARCHIVED
    8 Posts 3 Posters 2.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N Offline
      NOYB
      last edited by

      Does the order of interfaces matter in $config['filter']['rule']?

      For instance does it matter if all the rules of an interface end up at the top or bottom of the saved config.?

      Reason I ask is that if the order of interfaces does not matter it would be really easy to simplify the $_POST['order-store'] code in firewall_rules.php.  Boil it down to just grab the rules posted for the selected interface, followed by all the rules of other interfaces from config.

      1 Reply Last reply Reply Quote 0
      • jimpJ Offline
        jimp Rebel Alliance Developer Netgate
        last edited by

        In theory, no, in practice: maybe.

        Try swapping the order around and observe the differences in /tmp/rules.debug, you'll see what I mean.

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • N Offline
          NOYB
          last edited by

          Yeah it will change the interfaces order.  But does it matter?  What determines the initial interface order to begin with?

          Also observed that the order doesn't always seem to strictly follow what is in saved config.  Don't know what to make of that either.

          1 Reply Last reply Reply Quote 0
          • P Offline
            phil.davis
            last edited by

            It should not make any difference, as long as the code that implements the floating rules keeps doing what it does now. Rules that specify an interface only apply to that interface, so do not match traffic arriving on another interface. Thus it does not matter in which order of interface the interface-based rules appear in the rule set.

            So if it is convenient to code so that the rules for an interface are grouped together in the 'rule' array then I don't expect it to break anything.

            But it will mean that the config diff after changing rule(s) might be a lot bigger than it is now, making it more difficult for a human to see the real change - if anybody cares.

            As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
            If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

            1 Reply Last reply Reply Quote 0
            • jimpJ Offline
              jimp Rebel Alliance Developer Netgate
              last edited by

              @phil.davis:

              It should not make any difference, as long as the code that implements the floating rules keeps doing what it does now.

              +Interface groups

              @phil.davis:

              But it will mean that the config diff after changing rule(s) might be a lot bigger than it is now, making it more difficult for a human to see the real change - if anybody cares.

              Plenty of people do care about that, not just with the built-in config history either. IIRC there are some out there who check the config into their preferred type of VCS/RCS/SCS repo.

              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

              1 Reply Last reply Reply Quote 0
              • P Offline
                phil.davis
                last edited by

                Plenty of people do care about that, not just with the built-in config history either. IIRC there are some out there who check the config into their preferred type of VCS/RCS/SCS repo.

                In that case you would need to do something like re-sorting into a fixed order on save - e.g. the "ordinary"rules by interface (wan, lan, opt1, opt2…) - so that the rule set in the config would have minimal diff after a change. Of course the first time after an upgrade there would be a bigger diff when the rules got first sorted like that.

                As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
                If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

                1 Reply Last reply Reply Quote 0
                • jimpJ Offline
                  jimp Rebel Alliance Developer Netgate
                  last edited by

                  An upgrade producing a large diff is expected, a simple rule change having a large diff would be a shock to some. Also makes rolling back simple changes with manual config edits a bit more confusing.

                  Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                  Need help fast? Netgate Global Support!

                  Do not Chat/PM for help!

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    NOYB
                    last edited by

                    Looks like 2.2 went to pretty extensive lengths to preserve the order.  So probably good idea to stay with that.  Even though it probably doesn't make any functional difference, as Jim and Phil point out it probably wouldn't be as external processes friendly.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.