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

    Creating WAN rule using API

    Scheduled Pinned Locked Moved Firewalling
    4 Posts 2 Posters 480 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.
    • K
      kshitij
      last edited by

      I am looking for the api so that i can create WAN rule
      attaching the screenshot.
      rule.png
      like i have created 2 IPv4 rules manually one is for the source and one is for the destination

      1 Reply Last reply Reply Quote 0
      • bmeeksB
        bmeeks
        last edited by

        There is really no API exposed for this. About the nearest thing is to create a pf table, create a rule in the GUI referencing that table name, and then populate the table with IP addresses using an external script that calls pfctl.

        K 1 Reply Last reply Reply Quote 0
        • K
          kshitij @bmeeks
          last edited by

          @bmeeks
          Thanks Bmeeks, but can you please help me with the example .
          it would be really helpful.

          1 Reply Last reply Reply Quote 0
          • bmeeksB
            bmeeks
            last edited by

            Here is a link to the official documentation for the pfctl utility in FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=pfctl&apropos=0&sektion=8&manpath=FreeBSD+12.2-stable&arch=default&format=html.

            Within pfSense, "aliases" are actually implemented as pf tables. So you could create one or more aliases, and then use the pfctl utility to populate those aliases (or tables) with IP address info. But you can't literally create an entire rule this way. Tables hold only IP information. They do not hold rule action or traffic protocol information. So that goes back to my original reply -- "there really is no API exposed for this."

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