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

    API to remotely add NAT rule

    Scheduled Pinned Locked Moved NAT
    3 Posts 2 Posters 2.9k 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.
    • E
      elr90
      last edited by

      Hi

      I’m fairly new to pfSense, so before I start working on my upcoming project, I’d like to hear if there are any standard way of doing this – or if this exists already.

      I’m looking for a way to remotely add a NAT rule in pfSense. My current thought on how to do this is making a new php file that can be called via the URL with some GET params and then add the NAT rule. Fx:

      https://pfsense.domain.com/addNAT.php?intIp=xx.xx.xx.xx&intPort=yyyy&remIP=zz.zz.zz.zz&remPort=vvvv

      Then simply making the addNAT.php file a sort of modified version of firewall_nat.php so it uses the same functions and simply adds the NAT rule.

      That is my current idea on how to do this. But as I’m fairly new to pfSense I’m thinking that there could be a simpler way to do this – if it doesn’t exists already?

      Any help is very appreciated!

      Thanks a lot.

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

        No, we don't have any API for adding NAT rules like that. It wouldn't be terribly hard to script a one-off deal to do what you want..

        But a proper API and doing it right takes a lot more time. :-)

        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
        • E
          elr90
          last edited by

          I think that I'll be able to make such a script myself without much difficulty. I just wanted to know wether there was an existing solution to this problem or if there was a recommended approach. But I think I'll go "my way" then.

          Thanks.

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