?
Solved

PAC file for multiple subnets

Posted on 2014-02-04
6
Medium Priority
?
2,847 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 2000 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
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 

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 2000 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

Limited time offer using promo code EXPERTS25

Designed with a wealth of functionality and convenience, ATEN's new Thunderboltâ„¢ 2 Sharing Switch takes your Thunderbolt setup to the next level. Now through August 31, 2017, Experts Exchange members get 25% off the US7220 on the ATEN USA eShop using promo code EXPERTS25.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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.
Suggested Courses

743 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