Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PAC file for multiple subnets

Posted on 2014-02-04
6
Medium Priority
?
3,141 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

597 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