• My Pfsense system has a hostname of "wifi" and a domain of "pubname" (pubname being the pubname).

    If I ping "wifi" or "wifi.pubname" I get a response from the Pfsenses LAN IP.

    I would like to change the IP to a FQDN for the captive portal, and can see I need to change the code in captiveportal.inc and the index.html in the captiveportal directory.  Indeed, I can get this working.

    http://wifi:8000 and http:wifi.pubname:8000 resolve and the captive portal appears.

    Looking at the original code, I am not sure what this function does and why?

    $ifip = portal_ip_from_client_ip($clientip);

    if (isset($config['captiveportal']['httpslogin']))
        $ourhostname = $config['captiveportal']['httpsname'] . ":8001";
    else {
        $ifip = portal_ip_from_client_ip($clientip);
        if (!$ifip)
        	$ourhostname = $config['system']['hostname'] . ":8000";
        	$ourhostname = "{$ifip}:8000";

    If this function does not return an ip, the captive portal uses the hostname as the FQDN, so commenting out $ifip = portal_ip_from_client_ip($clientip); forces it use the hostname.

    What does this function call actually do and why?


  • Personally i would assign it an external fully qualified domain name. Alot simpler. Then i would disable loop back for Nat in the advanced setting, so when in on the lan side of pfsense i can ping the FQDN on the inside and get a response from the WAN

  • Is there a way to put a FQDN into PFsense DNS without registering a domain name externally?  Almost like an lmhosts file in Windows?  Looks like you can add a DNS "Host Override" under advanced in DNS forwarder?  Is it a good idea to do this?  For example, the FQDN for the pub is an external hosted website, but could add wifi.puburl.com into the hosts override and assign this to the captive portal ip?

    Still not really sure what that call to the function does mentioned above?

    Looks like it would only be useful if you had more than one interface using the Captive Portal.  It seems to look at the interfaces in use for the portal, get the IP/Subnet for those interfaces, look to see which the clientIP 'matches', and then assigns the IP address for the captive portal according to which interface the client is on?

    So if using just one interface, you could opt to loose the call to this function, as you are always going to get the same result from the call.

    Is there a reason to NOT use the hostname of the pfsense server?