{"id":1658,"date":"2026-11-20T10:26:12","date_gmt":"2026-11-20T15:26:12","guid":{"rendered":"https:\/\/blog.miguelsarmiento.com\/?p=1658"},"modified":"2026-11-20T10:33:12","modified_gmt":"2026-11-20T15:33:12","slug":"response-policy-zonesor-dns-firewall-oh-my","status":"publish","type":"post","link":"https:\/\/blog.miguelsarmiento.com\/?p=1658","title":{"rendered":"Response Policy Zones (or DNS Firewall), Oh My!"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Wanted to use Policy Response for a while, also called &#8220;DNS Firewall&#8221;. Created a lab to test the implementation and it is fairly straight forward.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 id=\"motivation\" class=\"wp-block-heading\"><strong>Motivation<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s assume a couple of scenarios:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You want to administer servers in the cloud, however you want to secure them as much as possible.\n<ul class=\"wp-block-list\">\n<li>You only allow connections from the Internet on the ports needed: HTTPS, DNS and perhaps another application<\/li>\n\n\n\n<li>For everything else you configure them to allow administration only via a VPN you have that connects from your network, home or enterprise.<\/li>\n\n\n\n<li>Of course you allow access via the local firewall for the VPN network.<\/li>\n\n\n\n<li>In addition you only allow Apache or NGINX connections to the Administration pages via VPN. This could include for example, phpMyAdmin, wp-admin, etc.<\/li>\n\n\n\n<li>You also allow SSH only via the VPN network.<\/li>\n\n\n\n<li>Of course you still have the tools that your cloud provider gives so you can always connect to your servers if you happen to shoot yourself on the foot!<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Or you have a developer network.\n<ul class=\"wp-block-list\">\n<li>You make changes and need to test.<\/li>\n\n\n\n<li>Testing needs to be done using the FQDN of your servers, if you have Apache for example.<\/li>\n\n\n\n<li>You could use hosts files, not a very scalable solution and would not work for virtual web servers.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A DNS firewall is suitable for this and other stuff as you will see.<\/p>\n\n\n\n<h2 id=\"dns-firewall\" class=\"wp-block-heading\"><strong>DNS Firewall<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">From ISC, the creators of the &#8220;DNS Firewall&#8221; in Bind.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;A DNS firewall selectively intercepts DNS resolution for known-malicious network assets including domain names, IP addresses, and name servers. Interception can mean rewriting a DNS response to direct a web browser to a \u201cwalled garden,\u201d or simply making the malicious network assets invisible and unreachable.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a security tool, it is a great asset. Since it can modify DNS responses, it can also be used to rewrite such responses to achieve a solution to the couple of scenarios we presented.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DNS Response Policy Zones (RPZ as it is also called), was invented at ISC. First implemented in Bind, however it is now an open and vendor-neutral standard for the interchange of DNS firewall configuration information.<\/p>\n\n\n\n<h2 id=\"dns-server\" class=\"wp-block-heading\"><strong>DNS Server<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following shows a conceptual diagram of what we just discussed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2026\/11\/response-policy.jpg\" target=\"_blank\" rel=\" noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"685\" height=\"482\" src=\"https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2026\/11\/response-policy.jpg\" alt=\"\" class=\"wp-image-1693\" srcset=\"https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2026\/11\/response-policy.jpg 685w, https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2026\/11\/response-policy-300x211.jpg 300w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We need to create a DNS Bind server, unless you already have one in place.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I will show a basic configuration as it was done for the lab, we created the DNS server on the DEV network since it will be the one requesting modified records. You could create a MGMT network in addition for management, I am only showing DEV connecting to it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Of course your clients need to point to this new DNS server, if you also have &#8220;normal&#8221; users that need to connect using unmodified records , you could just add this new server and make it a forwarder to your existing server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Records that are not modified will not be affected.<\/p>\n\n\n\n<h3 id=\"dns-setup\" class=\"wp-block-heading\"><strong><em>DNS Setup<\/em><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"> We will use the following parameters for our Bind configuration, adjust them for your setup.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>DNS_ZONE=&#8221;test.com&#8221;<\/li>\n\n\n\n<li>DNS_REVERSE=&#8221;192.168.1.in-addr.arpa&#8221;<\/li>\n\n\n\n<li>DNS_SERVER_IP=&#8221;192.168.1&#8243;<\/li>\n\n\n\n<li>DNS_SUBNET=&#8221;192.168.1.0\/24:<\/li>\n\n\n\n<li>DNS_ADMIN_EMAIL=&#8221;admin.test.com&#8221;<\/li>\n\n\n\n<li>VPN_NETWORK=&#8221;10.64.1.0\/24&#8243;<\/li>\n<\/ul>\n\n\n\n<h4 id=\"namedconfoptions\" class=\"wp-block-heading\"><strong>named.conf.options<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Create file under &#8220;\/etc\/bin\/named.conf&#8221;,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">options {<br>    directory \"\/var\/cache\/bind\";<br>    listen-on port 53 { 127.0.0.1; 192.168.1.1; };<br>    listen-on-v6 { none; };<br>    allow-query { 127.0.0.1; 192.168.1.0\/24; };<br>    recursion yes;<br>    allow-recursion { 127.0.0.1; 192.168.1.0\/24; };<br>    \/\/\"I have my own DNS server at 10.20.1.53\"<br>    forwarders { 10.20.1.53; 8.8.8.8; };<br>    forward only;<br>    dnssec-validation auto;<br>    auth-nxdomain no;<br>    \/\/\"It forces Bind to use a response policy zone\"<br>    response-policy { zone \"response-policy\"; };<br>};<\/pre>\n\n\n\n<h4 id=\"namedconflocal\" class=\"wp-block-heading\"><strong>named.conf.local<\/strong> <\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Edit the file &#8220;\/etc\/bin\/named.conf.local&#8221; and insert the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">zone \"test.com\" {<br>    type master;<br>    file \"\/etc\/bind\/db.test.com\";<br>    allow-query { any; };<br>};<br><br>zone \"192.168.1.in-addr.arpa\" {<br>    type master;<br>    file \"\/etc\/bind\/db.192.168.1\";<br>    allow-query { any; };<br>};<br><br>zone \"response-policy\" {<br>        type master;<br>        file \"\/etc\/bind\/db.response-policy\";<br>        allow-query { none; };<br>};<\/pre>\n\n\n\n<h4 id=\"forward-zone\" class=\"wp-block-heading\"><strong>Forward <\/strong>Zone<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Now we need to create the forward zone. In the same directory create a file &#8220;db.test.com&#8221; and add the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$TTL    604800<br>@       IN      SOA     ns1.test.com. mail@miguelsarmiento.com. (<br>                              4         ; Serial<br>                         604800         ; Refresh<br>                          86400         ; Retry<br>                        2419200         ; Expire<br>                         604800 )       ; Negative Cache TTL<br>;<br>@       IN      NS      ns1.tes.com.<br>ns1     IN      A       192.168.1.1<br>web     IN      A       192.168.1.10<br>db      IN      A       192.168.1.11<br>mail    IN      A       192.168.1.12<br>client  IN      A       192.168.1.212<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">IP 192.168.1.1 is the DNS server, the other records are the ones you do not want to modify the responses.<\/p>\n\n\n\n<h4 id=\"reverse-zone\" class=\"wp-block-heading\">Reverse Zone<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Now create the revers zone db.192.168.1:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">aa<br>$TTL    604800<br>@       IN      SOA     ns1.test.com. admin@test.com. (<br>                              4         ; Serial<br>                         604800<br>                          86400<br>                        2419200<br>                         604800 )<br>;<br>@       IN      NS      ns1.test.com.<br>1       IN      PTR     ns1.test.com.<br>10      IN      PTR     web.test.com.<br>11      IN      PTR     db.test.com.<br>12      IN      PTR     mail.test.com.<br>212     IN      PTR     client.test.com.<\/pre>\n\n\n\n<h4 id=\"rpz\" class=\"wp-block-heading\">RPZ<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Finally create the response policy zone &#8220;db.response-policy&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$TTL 3600<br>@    IN      SOA     ns1.test.com. mail@test.com. (<br>        5       ; serial number YYMMDDNN<br>     3600       ; refresh 1 hour<br>     600        ; retry 10 minutes<br>     86400      ; expiry 1 week<br>     600 )      ; min ttl 10 minutes<br><br>@ IN NS test.com.<br>\/\/\"Sites that will have their DNS rewritten\"<br>\/\/ Sites in the cloud managed via VPN<br>mysite1.mydomain.com A 10.64.0.10<br>mysite2.mydomain.com A 10.64.0.10<br>\/\/ Dev site for testing<br>mysite3.mydomain.com A 10.192.168.200<br><\/pre>\n\n\n\n<h3 id=\"test-and-restart-bind\" class=\"wp-block-heading\"><strong><em>Test and Restart Bind<\/em><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Test the configuration zones using the DNS tools.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use named-chekconf and named-check-zone.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use &#8220;named-checkconf -p&#8221; to print the parsed configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use &#8220;named-checkzone example.com \/etc\/bind\/db.test.com&#8221; for example.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If there are no issues restart Bind and check if it is running, check the syslog to see if all zones were loaded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If everything looks correct try doing a dig from a client on the correct network, it needs to have its DNS resolution pointing to the new server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my case I forgot to add the RPZ zone to the options configuration file, duh!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You should then see when you do a dig to &#8220;mysite1.mydomain.com &#8220;, you will see the new IP resolving and not the normal web address.<\/p>\n\n\n\n<h2 id=\"conclussions\" class=\"wp-block-heading\"><strong>Conclussions<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Congrats, you now have a DNS that can rewrite records, neat it is not?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Of course the initial intend of RPZ was to secure DNS records against malicious actors by rewriting responses and preventing access to questionable sites.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There you have it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ciao.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wanted to use Policy Response for a while, also called &#8220;DNS Firewall&#8221;. Created a lab to test the implementation and it is fairly straight forward.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1658","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts\/1658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1658"}],"version-history":[{"count":62,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts\/1658\/revisions"}],"predecessor-version":[{"id":1730,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts\/1658\/revisions\/1730"}],"wp:attachment":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}