Creating WAN rule using API
-
I am looking for the api so that i can create WAN rule
attaching the screenshot.
like i have created 2 IPv4 rules manually one is for the source and one is for the destination -
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 callspfctl
. -
@bmeeks
Thanks Bmeeks, but can you please help me with the example .
it would be really helpful. -
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 thepfctl
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."