Switch to full style
Use this forum to post questions relating to WinGate, feature requests, technical or configuration problems
Post a reply

wpad.dat for two gateway?

Sep 05 13 2:00 am

Hi Wingate Team :)

This is example, if my server have 3 NIC :
-NIC 1 = external (DSL modem)
-NIC 2 = internal 192.168.0.1 (gateway for office)
-NIC 2 = internal 192.168.1.1 or 10.0.0.1 (gateway for others)

so in my DHCP service (DHCP Settings) it will have two range of ip address
so how to configure wpad.dat for automatically served to two different gateway in two different ip range correctly?

here example I try edit from wpad.template, can I used this?
if cannot, what is the correct setting i need write into wpad.dat

Code:
function FindProxyForURL(url, host)
{
  if ((url.substring(0, 5) == "http:") ||
      (url.substring(0, 4) == "ftp:")  ||
      (url.substring(0, 6) == "https:"))
  {
    return "PROXY 192.168.0.1:80;DIRECT";
  }
  else if (isInNet(myIpAddress(),"192.168.1.0","255.255.255.0"))
  {
   return "PROXY 192.168.1.1:80;DIRECT";
  }
 
}



other example i get from internet
Code:
function FindProxyForURL(url, host)
{
  if (isPlainHostName(host) ||
    isInNet(host, "10.0.0.0", "255.0.0.0") ||
    isInNet(host, "172.16.0.0", "255.255.224.0") ||
    isInNet(host, "192.168.0.0", "255.255.0.0") ||
    isInNet(host, "127.0.0.0", "255.0.0.0"))
    return "DIRECT";
   
  if ((url.substring(0, 5) == "http:") ||
      (url.substring(0, 4) == "ftp:")  ||
      (url.substring(0, 6) == "https:"))
      return "PROXY 192.168.0.1:80;DIRECT";
 
  if (isInNet(myIpAddress(),"192.160.1.0","255.255.255.0"))
  return "PROXY 192.168.1.1:80;DIRECT";
  } ;



thanks :)

Re: wpad.dat for two gateway?

Sep 05 13 5:36 pm

another example :
Code:
function FindProxyForURL(url, host)
{
// DEFAULT RULE: All other traffic, use below proxies.
      return "PROXY 192.168.0.1:80;DIRECT";

// If the IP address of the local machine is within a defined
// subnet, send to a specific proxy.
   if (isInNet(myIpAddress(),"192.160.1.0","255.255.255.0"))
      return "PROXY 192.168.1.1:80;DIRECT";

}



So, what is the best configuration if I have 2 different ip range/subnet?

Re: wpad.dat for two gateway?

Sep 06 13 9:47 am

Hi

do you mean 2 different interfaces in WInGate, or just 2 different subnets of clients on the same WinGate interface?

You can use replaceable parameters in the template file, that get replaced by the relevant data when the WPAD.dat file is served.

This normally resolves issues like multi-homing, so you don't enter IP addresses (in terms of proxy IP) into the template file, but rather use

%PROXY% - gets replaced by the local IP:port of the WWW proxy that is serving the WPAD.dat file (so this will work for multi-homing)
%IP% - same as %PROXY%
%SOCKS% - gets replaced by the IP:port of the SOCKS server in WinGate if there is one - IP is still local interface (so still works for multi-homing).

Adrien

Re: wpad.dat for two gateway?

Sep 17 13 5:53 pm

what I mean is...

my network have two different ip range/subnet
ip range/subnet 1 = 192.168.0.1
ip range/subnet 2 = 182.168.1.1

so in my DHCP have to scope off ip range.

let say DHCP give laptop A ip 192.168.1.5, can ip 192.168.1.5 connect to wingate using 192.168.0.1 gateway?
or I need to put some script into wpad.dat to make sure all client get 192.168.1.x ip will point to gateway 192.168.1.1

my server have 3 network card interface 1 for cable modem
and other 2 network card is connect to different network switch.

below a simple diagram i try to draw :-D
wingate.jpg
wingate.jpg (79.11 KiB) Viewed 5735 times


i try configure my wpad.dat like this... but dont know wingate will recognise it or not...
(by the way, after we edit wpad.dat in wingate folder, how long DHCP take time to update to latest edited wpad.dat?)
Code:
function FindProxyForURL(url, host)
{
   if (isInNet(host, "192.168.0.0", "255.255.255.0"))
   {
   return "PROXY 192.168.0.1:80;DIRECT";
   }
   
   if (isInNet(host, "192.168.1.0", "255.255.255.0"))
   {
   return "PROXY 192.168.1.1:80;DIRECT";
   }
   
   if    (isPlainHostName(host) ||
      isInNet(host, "10.0.0.0", "255.0.0.0") ||
      isInNet(host, "172.16.0.0", "255.255.224.0") ||
      isInNet(host, "192.168.0.0", "255.255.0.0") ||
      isInNet(host, "127.0.0.0", "255.0.0.0"))
   {
   return "DIRECT";   
   }
   
   else
   return "PROXY 192.168.0.1:80;DIRECT";
}

Re: wpad.dat for two gateway?

Sep 18 13 9:40 am

Hi

when serving the WPAD.dat file, WinGate only reads the WPAD.template file.

This template file has replaceable paramaters replaced, and then is served. It doesn't matter if there are replaceable parameters in there or not.

As for DHCP. Clients use DHCP only to get the URL for the wpad file, this is then retrieved with http.

We normally use the URL of http://wingate/wpad.dat

and store this in global options. Then it is also available to non-DHCP clients (who use DHCP_INFORM to get config parameters even when they don't get an IP address assigned).

I think your best bet may be to use DNS. For instance you can use the name "wingate" for proxy, and this will resolve to whatever address the request was received on.

There's also a "hack" you can use for DNS with the hosts file on the WinGate server. If you enter a name in the hosts file and make the IP 0.0.0.0, then WinGate will reply with the IP of the interface the request was received on.

Regards

Adrien
Post a reply