SOLVED: (WPAD) Export Proxy Config through DHCP



  • Hi,

    how can I export additional dhcp options? I want to export a Proxy PAC file through the webserver of Captive Portal. Is that possible?

    For those that are interested: http://www.ietf.org/proceedings/99nov/I-D/draft-ietf-wrec-wpad-01.txt

    Regards,
    Manuel



  • use a wpad.domain.com hostname/webserver with a wpad.dat proxy pac

    Enforce it using AD Group Policies
    Click autodetect in the browser



  • Well, the problem is that I don't have admin rights on the maschine using the internet connection. So I wanted to set the option 252 in dhcp (auto-proxy-config) to the proxy.pac exported by captives lighttpd.

    Is it possible to set a custom option in dhcpd?



  • We currently don't support custom options besides the ones listed at services>dhcp server. Setting a prox is unfortunately not one of these options.



  • Hi, I have integrated the automatic proxy configuration by myself. It is integrated in the gui. Feel free to adopt.

    The files to edit:

    • /usr/local/www/services_dhcp.php

    • /etc/inc/services.inc

    The modifications:

    /usr/local/www/services_dhcp.php

    
       $pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
       $pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
    +  $pconfig['wpad'] = $config['dhcpd'][$if]['wpad'];
    
       $ifcfg = $config['interfaces'][$if];
    
    -----
    
    		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
    		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
    +		$config['dhcpd'][$if]['wpad'] = $_POST['wpad'];
    
    		write_config();
    
    		/* static arp configuration */
    		interfaces_staticarp_configure($if);
    
    -----
    
    				Leave blank to disable.  Enter the REAL address of the other machine.  Machines must be using CARP.
    
    +                      
    +                        Automatic Proxy URL
    +                        
    +                          
    +                          
    
    +                          This is the URL to the automatic proxy script.
    +			
    +                      
    
                            Static ARP
    
    

    /etc/inc/services.inc

    
    one-lease-per-client true;
    deny duplicates;
    
    EOD;
    
    +	if (isset($dhcpifconf['wpad'])) {
    +		$dhcpdconf .= "option wpad-url code 252 = text;"."\n";
    +		$dhcpdconf .= "option wpad-url \"".$dhcpifconf['wpad']."\\n\";"."\n";
    +	}
    
    	$dhcpdifs = array();
    
    	/*    loop through and deterimine if we need to setup
    	 *    failover peer "bleh" entries
    
    

    With these slight modifications, there will be an extra field in the dhcp configuration where you can enter the URL to your proxy.pac. I have copied my proxy.pac to /usr/local/captiveportal/captiveportal-proxy.pac and have entered in the Automatic proxy field http://192.168.0.1:8000/captiveportal-proxy.pac.

    My proxy script looks like this:

    
    function FindProxyForURL(url, host)
    {
    if (
         (isPlainHostName(host)) ||
         (dnsDomainIs(host, ".dsl.local")) ||
         (isInNet(host, "10.0.0.0", "255.0.0.0")) ||
         (isInNet(host, "172.16.0.0", "255.240.0.0")) ||
         (isInNet(host, "169.254.0.0", "255.255.0.0")) ||
         (isInNet(host, "192.168.0.0", "255.255.0.0"))
       )
         return "DIRECT";
    
     else
    
    if (
         (isInNet(myIpAddress(), "192.168.0.0", "255.255.255.0"))
       )
         return "PROXY 192.168.0.1:3128";
    }
    
    

    Cheers,
    Manuel


Log in to reply