API to remotely add NAT rule



  • 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.


  • Rebel Alliance Developer Netgate

    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. :-)



  • 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.


Locked