{"id":19051,"date":"2020-07-29T16:58:50","date_gmt":"2020-07-29T20:58:50","guid":{"rendered":"https:\/\/nuxx.net\/blog\/?p=19051"},"modified":"2021-08-06T11:21:43","modified_gmt":"2021-08-06T15:21:43","slug":"simple-pac-file-pilot-testing-including-wpad","status":"publish","type":"post","link":"https:\/\/nuxx.net\/blog\/2020\/07\/29\/simple-pac-file-pilot-testing-including-wpad\/","title":{"rendered":"Simple PAC File Pilot Testing (including WPAD)"},"content":{"rendered":"\n<p>In a network that&#8217;s isolated from the public internet, such as many enterprise networks, proxy servers are typically used to broker internet access for client computers. Configuring the client computers to use these proxies is often done via a <a href=\"https:\/\/findproxyforurl.com\/\">Proxy Auto-Config (PAC) file<\/a>,  code that steers requests so traffic for internal sites stays internal, and public sites go through the proxies.<\/p>\n\n\n\n<p>Commonly these PAC files are made available via <a href=\"https:\/\/en.wikipedia.org\/wiki\/Web_Proxy_Auto-Discovery_Protocol\">Web Proxy Auto-Discovery Protocol (WPAD)<\/a> as well, because some systems need to automatically discover them. Specifically, in a Windows 10 environment which uses proxies, WPAD is needed because many components of Windows (including the Microsoft Store and Azure Device Registration) will not use the browser&#8217;s PAC file settings; it&#8217;s dependent on WPAD to find a path to the internet.<\/p>\n\n\n\n<p>WPAD is typically configured via DNS, with a hostname of wpad.companydomain.com (or anything in the DNS Search Suffix List) resolving to the IP of a webserver [1]. This server must then answer an HTTP request for <code>http:\/\/x.x.x.x\/wpad.dat<\/code> (where x.x.x.x is the server&#8217;s IP) or <code>http:\/\/wpad.company.com\/wpad.dat<\/code> with a PAC file, with a <code>Content-Type<\/code> of <code>x-ns-proxy-autoconfig<\/code> [2].<\/p>\n\n\n\n<p>Because WPAD requires DNS, something which can&#8217;t easily be changed for a subset of users, putting together a mechanism to perform a pilot deployment of a new PAC file can be a bit complicated. When attempting to perform a pilot deployment engineers will often send out a test PAC file URL to be manually configured, but this misses WPAD and does not result in a complete system test.<\/p>\n\n\n\n<p>In order to satisfy WPAD, one can set up a simple webserver to host the new PAC file and a DNS server to answer the WPAD queries. This DNS server forwards all requests except for those for the PAC file to the enterprise DNS, so everything else works as normal. Testing users then only need to change their DNS to receive the pilot PAC file and everything else will work the same; a true pilot deployment.<\/p>\n\n\n\n<p>Below I&#8217;ll detail how I use simplified configurations of <a href=\"https:\/\/nlnetlabs.nl\/projects\/unbound\/about\/\">Unbound<\/a> and <a href=\"https:\/\/nginx.org\/\">nginx<\/a> to pilot a PAC file deployment. This can be done from any Windows machine, or with very minor config changes from something as simple as a <a href=\"https:\/\/www.raspberrypi.org\/\">Raspberry Pi<\/a> running Linux.<\/p>\n\n\n\n<p>[1] WPAD can be configured via DHCP, but this is only supported by a handful of Microsoft applications. DNS-based WPAD works across all modern OS&#8217;.<\/p>\n\n\n\n<p>[2] Some WPAD clients put the server&#8217;s IP in the Host: field of the HTTP request.<\/p>\n\n\n\n<p><strong>DNS via Unbound<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/nlnetlabs.nl\/projects\/unbound\/about\/\">Unbound<\/a> is a DNS server that&#8217;s straightforward to run and is available on all modern platforms. It&#8217;s perfect for our situation where we need to forward all DNS queries to the production infrastructure, modifying only the WPAD\/PAC related queries to point to our web server. While it&#8217;s quite robust and has a lot of DNSSEC validation options, we don&#8217;t need any of that.<\/p>\n\n\n\n<p>This simple configuration forwards all requests to corporate Active Directory-based DNS&#8217; (10.0.1.2 and 10.0.2.2) for everything except the PAC file servers. For these, <code>pacserver.example.com<\/code> and <code>wpad.example.com<\/code>, it&#8217;ll intercept the request and return our webserver&#8217;s address of 10.0.3.25.<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p><code>server:<br>  interface: 0.0.0.0<br>  access-control: 0.0.0.0\/0 allow<br>  module-config: \"iterator\"<br><br>  local-zone: \"wpad.example.com.\" static<br>  local-data: \"wpad.example.com. IN A 10.0.3.25\"<br><br>  local-zone: \"pacserver.example.com.\" static<br>  local-data: \"pacserver.example.com. IN A 10.0.3.25\"<br><br>stub-zone:<br>  name: \".\"<br>  stub-addr: 10.0.1.2<br>  stub-addr: 10.0.2.2<\/code><\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p>This configuration allows recursive queries from any hosts, but by specifying one or more subnets using  <code>access-control<\/code> clauses to you can restrict from where it is usable. The <code>stub-zone<\/code> clause to send all requests up to two DNS&#8217;. If these upstream DNS&#8217; handle recursion for the client, the <code>forward-zone<\/code> clause can be used instead.<\/p>\n\n\n\n<p><strong>PAC File via nginx<\/strong><\/p>\n\n\n\n<p>For serving up the PAC file, both for direct queries and those from WPAD, we&#8217;ll use <a href=\"https:\/\/nginx.org\/\">nginx<\/a>, a powerful but easy to use web server to which we can give a minimal config.<\/p>\n\n\n\n<p>Put a copy of your PAC file at <code>\u2026\/html\/wpad.dat<\/code> under nginx&#8217;s install directory so the server can find it. (There is great information on writing PAC files at <a href=\"http:\/\/findproxyforurl.com\/\">FindProxyForUrl.com<\/a>.)<\/p>\n\n\n\n<p>This simple configuration will set up a web server which serves all files as MIME type <code>application\/x-ns-proxy-autoconfig<\/code>, offering up the <code>wpad.dat<\/code> file by default (eg: <a href=\"http:\/\/pacserver.example.com) \">http:\/\/pacserver.example.com) <\/a>or when directly referenced (eg: <a href=\"http:\/\/10.0.3.25\/wpad.dat\">http:\/\/10.0.3.25\/wpad.dat<\/a> or <a href=\"http:\/\/wpad.example.com\/wpad.dat\">http:\/\/wpad.example.com\/wpad.dat<\/a>), satisfying both standard PAC file and WPAD requests.<\/p>\n\n\n\n<p><code>events {<br>  worker_connections 1024;<br>  }<br><br>http {<br>  default_type application\/x-ns-proxy-autoconfig;<br>  sendfile on;<br>  keepalive_timeout 65;<br><br>  server {<br>    listen 80;<br>    server_name localhost;<br><br>    location \/ {<br>      root html;<br>      index wpad.dat;<br>    }<br>  }<br>}<\/code><\/p>\n\n\n\n<p><strong>Putting It All Together<\/strong><\/p>\n\n\n\n<p>With all the files in place and unbound and nginx running, you&#8217;re ready to go. Instruct pilot users to manually configure the new DNS, or push this setting out via Group Policy, VPN settings, or some other means. These users will then get the special DNS response for your PAC and WPAD servers, get the pilot PAC file from your web server, and be able to test.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a network that&#8217;s isolated from the public internet, such as many enterprise networks, proxy servers are typically used to broker internet access for client&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/nuxx.net\/blog\/2020\/07\/29\/simple-pac-file-pilot-testing-including-wpad\/\">Continue reading<span class=\"screen-reader-text\">Simple PAC File Pilot Testing (including WPAD)<\/span><\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-19051","post","type-post","status-publish","format-standard","hentry","category-computers","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/19051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/comments?post=19051"}],"version-history":[{"count":10,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/19051\/revisions"}],"predecessor-version":[{"id":19411,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/19051\/revisions\/19411"}],"wp:attachment":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/media?parent=19051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/categories?post=19051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/tags?post=19051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}