Solved

PAC file for multiple subnets

Posted on 2014-02-04
6
2,159 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
  • 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 21

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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 21

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

OfficeMate Freezes on login or does not load after login credentials are input.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now