Solved

PAC file for multiple subnets

Posted on 2014-02-04
6
2,375 Views
Last Modified: 2014-02-05
I have setup a pac file for mobile/laptop domain users which is pushed out via GPO.
I've set 'Use automatic configuration script'. It works well with the exception of when I add in other subnets to the statement 'if (isInNet(myIpAddress()'

Here is the pac file below. How could add another subnet to this?

function FindProxyForURL(url, host)
{
// variable strings to return
var proxy_yes = "PROXY IP:3128";
var proxy_no = "DIRECT";
if (shExpMatch(url, "http://website1*")) { return proxy_no; }
if (shExpMatch(url, "http://website2*")) { return proxy_no; }
// Proxy if PC is on local LAN
if (isInNet(myIpAddress(), "192.168.100.0", "255.255.255.0"))
return "PROXY:3128";
else
return "DIRECT";
}

Thanks.
0
Comment
Question by:BerryGardens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:BerryGardens
ID: 39833119
So this is what i'm attempting which fails:

function FindProxyForURL(url, host)
{
// variable strings to return
var proxy_yes = "PROXY IP:3128";
var proxy_no = "DIRECT";
if (shExpMatch(url, "http://website1*")) { return proxy_no; }
if (shExpMatch(url, "http://website2*")) { return proxy_no; }
// Proxy if PC is on local LAN
if (isInNet(myIpAddress(), "192.168.100.0", "255.255.255.0"))
if (isInNet(myIpAddress(), "192.168.101.0", "255.255.255.0"))
return "PROXY:3128";
else
return "DIRECT";
}
0
 
LVL 22

Assisted Solution

by:dan_blagut
dan_blagut earned 500 total points
ID: 39834970
you can try tris one

function FindProxyForURL(url, host)
{
// variable strings to return
var proxy_yes = "PROXY IP:3128";
var proxy_no = "DIRECT";
if ((shExpMatch(url, "http://website1*"))||(shExpMatch(url, "http://website2*"))) { return proxy_no; }
// Proxy if PC is on local LAN
if ((isInNet(myIpAddress(), "192.168.100.0", "255.255.255.0"))|| (isInNet(myIpAddress(), "192.168.101.0", "255.255.255.0"))) {return "PROXY:3128";}
else
return "DIRECT";
}

Dan
0
 

Author Comment

by:BerryGardens
ID: 39834986
I'll test now thanks.
0
Create Professional Looking Email Signatures

Create "Professional HTML Email Signatures" with ease.
7 Day Money Back Guarantee if not 100% Satisfied.
Affordable - Try it out for 7 Days Totally Risk Free.
Installers provided for over 45 Email clients.
Both Windows & MAC Supported.
Highly Recommended!

 

Author Comment

by:BerryGardens
ID: 39835032
Genius thanks worked a treat!

I assume if in future I wanted to add another subnet it would look like this?

// Proxy if PC is on local LAN
if ((isInNet(myIpAddress(), "192.168.100.0", "255.255.255.0"))|| (isInNet(myIpAddress(), "192.168.101.0", "255.255.255.0"))|| (isInNet(myIpAddress(), "192.168.102.0", "255.255.255.0"))) {return "PROXY:3128";}

Sorry just one more bit of advice, if I wanted to add a fail over proxy IP would that be simple to add to the script?
0
 
LVL 22

Accepted Solution

by:
dan_blagut earned 500 total points
ID: 39835046
for the future network is correct
in fact "||" means "or" as logical operators
here you have more help about
http://www.proxypacfiles.com/proxypac/index.php?option=com_content&view=article&id=56&Itemid=85
and a tools for testing pac files
https://code.google.com/p/pactester/

for your other question:
http://en.wikipedia.org/wiki/Proxy_auto-config
Advanced functionality
More advanced PAC files can reduce load on proxies, perform load balancing, fail over, or even black/white listing before the request is sent through the network. One can return multiple proxies:
return "PROXY proxy1.example.com:8080; PROXY proxy2.example.com:8080";

Dan
0
 

Author Closing Comment

by:BerryGardens
ID: 39835067
Excellent links, you are a life saver. If I could award a million points I would. Thank you so much.
0

Featured Post

RoboForm Secure Password Management System

RoboForm Everywhere - Superb Browser Support
Windows / Apple / IOS / Android / Linux / Chrome OS
Use different complex passwords everywhere
Best Secure Password Management by far
Synchronize all of your devices instantly
Safe, Secure & Highly Recommended!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
An article on effective troubleshooting
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question