Hi,
it seems I found the right configuration for pfSense ver. 2.4.x by adding the following lines:
$cprules .= "# Rules to allow DNS queries to external servers from unauthenticated users\n";
$cprules .= captiveportal_create_ipfw_rule("add", $rulenum,
"allow udp from any to any 53 out");
$cprules .= captiveportal_create_ipfw_rule("add", $rulenum,
"allow tcp from any to any 53 out");
$cprules .= captiveportal_create_ipfw_rule("add", $rulenum,
"allow udp from any to any 53 in keep-state");
$cprules .= captiveportal_create_ipfw_rule("add", $rulenum,
"allow tcp from any to any 53 in keep-state");
above the section that starts with:
$cprules .= "# redirect non-authenticated clients to captive portal\n";
$cprules .= captiveportal_create_ipfw_rule("add", $rulenum,
"fwd 127.0.0.1,{$listenporthttp} tcp from any to any dst-port 80 in");
Remember that the basic prerequisite is to enable the redirecting of all dns requests to pfsense as shown in https://doc.pfsense.org/index.php/Redirecting_all_DNS_Requests_to_pfSense