Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autodetection of Proxy for IE

Proxy Server Settings

Autodetection of Proxy for IE

by  SwapSawe  Posted    (Edited  )
Environment-
ISC-DHCP3
FreeBSD 4.11
Apache2.0

Requirements-
A DHCP Server
A Web Server (both are same m/c in my case)
A Microsoft Client


Server-side Procedure-
Install isc dhcp in my case the version was 3.0, once dhcp server is installed, the next step is to configure dhcpd.conf file.

Configuring dhcpd.conf file

Code:
# dhcpd.conf
#
#

# option definitions common to all supported networks...
option domain-name "swapsawe.com";
option domain-name-servers 82.216.140.12;

default-lease-time 600;
max-lease-time 7200;

#Declare the proxy file here.
option wpad-url code 252 = text;
option wpad-url "http://192.168.99.123/proxy.pac\n";

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# ad-hoc DNS update scheme - set to "none" to disable dynamic DNS updates and ad-hoc to enable.
ddns-update-style none;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;


# A slightly different configuration for an internal subnet.
subnet 192.168.99.0 netmask 255.255.255.0 {
  range 192.168.99.200 192.168.99.210;
  option routers 192.168.99.1;
  option broadcast-address 192.168.99.255;
  default-lease-time 600;
  max-lease-time 7200;
}

In the text box we see a bare minimum DHCP Configuration file, this configuration is used by /usr/local/sbin/dhcpd or usr/sbin/dhcpd to run the dhcp server. This configuration file is located as /usr/local/etc/dhcpd.conf or /etc/dhcpd.conf. It is advisible to create links so that the files are available at both the locations. In this configuration file these two lines are of higher significance in study of auto-detection of proxy.

Code:
option wpad-url code 252 = text;
option wpad-url "http://192.168.99.123/proxy.pac\n";

These lines tell the DHCP server that whenever the Internet explorer requests for Auto-detection of the proxy, the server should return this address of proxy auto-configuration file. When the above file is received by IE it stores the proxy information returned by proxy auto-configuration file in its cache and doesnot look for proxy settings,unless the settings are changed (i.e. from Auto-detect to Manual) or the IP Address of machine changes.

Proxy Auto Configuration script (the .pac file)
The ô.pacö file contains the javascript code for to resolve which proxy should be used in given condition. The ".pac" files are a seperate topic for exploration which is out of scope of this discussion. For the intended purpose a very simple two-line code was written -

Code:
function FindProxyForURL(url, host)
{
	   return "PROXY 192.168.99.123:5080";
}

This file is stored in root directory of Web Server, in this case the WebServer used was Apache2 and the file was hence stored in /usr/local/www/data.

Now start running DHCP Server, from the command prompt,
Code:
/usr/local/sbin/dhcpd

Client-side Procedure-

Connect the client (the Windows machine) in the LAN. This would give a new IP-Address to the client in the connected subnet. Now open Internet Explorer, goto û
Tools Menu-> Internet Options-> Connection-> LAN Settings


Now check ôAutomatically Detect Settingsö and uncheck all others, close IE. Open another window and now surf the internet the traffic would be redirected through the intended proxy server. You can check the flow of packets using ethereal.

This is mostly useful in an environment where the nodes are mobile and can be plug in to different subnets any given time. In this scenario, autodetection saves the pain of changing internet explorer's settings again and again.

THis scenario pained me for almost a week.
(-:
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top