Solved

PAC file for multiple subnets

Posted on 2014-02-04
6
2,598 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
OfficeMate Freezes on login or does not load after login credentials are input.
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). …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

718 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