Skip to content

Instantly share code, notes, and snippets.

@PiBa-NL
Created December 29, 2016 00:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PiBa-NL/7bc8cfb94556f0532c6e063cb5dab09c to your computer and use it in GitHub Desktop.
Save PiBa-NL/7bc8cfb94556f0532c6e063cb5dab09c to your computer and use it in GitHub Desktop.
adding custom rules on pfSense not supported by webgui
<?php
// Add this file as: /usr/local/pkg/CUSTOM_rules.inc
// pfSense will automatically add the rules defined here into the rules it loads in pf
require_once("util.inc");
function CUSTOM_rules_generate_rules($type) {
// called by filter.inc when pfSense rules generation happens
$rules = "";
switch($type) {
case 'nat':
$rules .= "# CUSTOM NAT RULES \n";
$rules .= "nat on em0 inet6 proto tcp from ! (em0) to any -> 123::456\n";
$rules .= "# END CUSTOM NAT RULES \n";
break;
case 'filter':
$rules .= "# CUSTOM RULES \n";
$rules .= "# END CUSTOM RULES \n";
break;
}
return $rules;
}
?>
@zlinuxboy
Copy link

hello,
It's awesome! I really need this code.
I would like to install tinc package on pfsense, but the default webUI configuration does not satify my need, I have to hack to add some custom rules. and I found your code.

two questions:

  1. how to reference this function on /etc/inc/filter.inc?
  2. any possible to delete the rules which generate from custom_rules.inc when some conditions meet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment