Categories: Pfsense

Filter DNS traffic after blocking websites with Squid

&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2524 " id&equals;"quads-ad2524" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<p>Let&&num;8217&semi;s assume that you have installed and configured Squid Proxy to block several categories of websites that you don&&num;8217&semi;t want your users or clients to visit &period;&period; <&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2528 " id&equals;"quads-ad2528" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2530 " id&equals;"quads-ad2530" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2523 " id&equals;"quads-ad2523" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;&NewLine;&NewLine;&NewLine;<p>In some places maybe interference on client machines or applying group policy on AD is not strict thing and might give the option to users to pass through proxy rules &period;&period; so I have considered the same thought and said after I have configured squid proxy to block certain websites &lpar;Porn&comma; chat&comma; social&&num;8230&semi;etc&rpar; using the Wpad autodiscover method&period;&period; I said in case I change the DNS the user will pass through the proxy and find away to connect to those blocked websites&period; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>Then I thought what if I can block external DNS queries and let all the DNS queries pass through the Pfsense or my internal DNS&period;&period;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>To do so I have configured my PFsense&&num;8217&semi;s WAN DNS IP to Google &lpar;System&gt&semi;General Setup&gt&semi; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image"><img src&equals;"https&colon;&sol;&sol;lh6&period;googleusercontent&period;com&sol;TtSK30UzmbEEvJkLqvG-NhR54m6E2NPc1VRSCz0gct3&lowbar;vm&lowbar;jC&lowbar;LloBgMlawHPz3BpI2s7yJUH8QGHqZBndTorLc5bHYlbj2pq-RKXvqutl92gb6sBmM-&equals;w1175" alt&equals;""&sol;> &NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2526 " id&equals;"quads-ad2526" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine; &NewLine;<&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>I have added my Local DNS to the DNS resolver &lpar;Pfsense Version 2&period;2&rpar; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image"><img src&equals;"https&colon;&sol;&sol;lh3&period;googleusercontent&period;com&sol;Kq0iSAluAzq2ma3wwWtAtkiMHORbpLbIP-OMJfnmSFZO9kHlP7inJzAhMP7-ZceGZNJjJL-v82EQPqj&lowbar;MY9qadoRF-sy9H5N8NFP81IMWiKLucvzDkI&equals;w1175" alt&equals;""&sol;><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>Next I will go to the Rules and go to my LAN &lpar;DMZ in my case&rpar; and create 3 rules in total as following&colon;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>The rules in the figure below will allow any DNS query request from any source through only &lpar;Local Address of the Pfsense&rpar; and the second rule will allow DNS requests from the local DNS Server to any DNS server&period; <&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2522 " id&equals;"quads-ad2522" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;&NewLine;&NewLine;&NewLine;<p>Third rule will blcok any DNS request from anywhere else&period; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image"><img src&equals;"https&colon;&sol;&sol;lh3&period;googleusercontent&period;com&sol;kDyHscAQvIFCcMLDDcLIuuWLY7n-tYI87j8ujn&lowbar;-rWH74qp7hp&lowbar;6EdYFlEE&lowbar;fHwfgWMDYIllvQvhXSD23bsOzJT5vZYyvshnslUbtRzOZUDIt99fclg&equals;w1175" alt&equals;""&sol;><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>Which in result will allow all clients to forcefully use the local DNS to resolve names and resolve IPs&comma; but still even if the user changed his Local LAN&sol;Wifi DNS IP to Google still he&&num;8217&semi;ll be able to connect to the allowed websites from SQUID but he&sol;she won&&num;8217&semi;t be able to resolve FQDNs through &lpar;Nslookup command&rpar; for example&period; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>I&&num;8217&semi;m attaching screenshots to demonstrate how this is working flawlessly&period; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>As you can see below I have opened google&comma; Flickr&comma; Facebook&comma; gmail&comma; searched for local time and it all worked according to the Squid rules and while still using &lpar;8&period;8&period;8&period;8&rpar; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image"><img src&equals;"https&colon;&sol;&sol;lh5&period;googleusercontent&period;com&sol;TNSEZokVxzmAk1UMa2AzflzjOenUyRypPacqT&lowbar;AtKALi2oydzlqxkaQLd6ktH&lowbar;UorEyhpC7weseJFNePBQ5maBL0RAQ3Gf3ZwpLhCq4rQfUqcaWH1AY&equals;w1175" alt&equals;""&sol;><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>Now I will change the DNS back to the local DNS IP and see if i can resolve internet addresses without an issue and connect as well&comma; which worked fine too&period;<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2531 " id&equals;"quads-ad2531" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image"><img src&equals;"https&colon;&sol;&sol;lh5&period;googleusercontent&period;com&sol;4vLZ2ZAAKEoeomnY7FJIHEXP535Kfch1qdqziI0ebehsg7q7m087w4rva8SDf5s8xOiOjgkNx-qFEEI2AIvIEkwvDYaUIJm880rQAlAgNFk12I5Qmck&equals;w1175" alt&equals;""&sol;><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>This is a simple article but I&&num;8217&semi;m sure it could be very useful for those companies who want to block wide range of categories and force it on to their employees&period; or for families who want to avoid their kids from doing naughty stuff or watch violent websites&period; <br><&sol;p>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2527 " id&equals;"quads-ad2527" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;

moh10ly

Share
Published by
moh10ly

Recent Posts

Reset passwords for Active Directory Users

Reset and manage your Active Directory users' Passwords Active Directory is one of the most…

3 years ago

Finding Exchange Database hidden mailboxes. ​

Finding Exchange Database hidden mailboxes. Story:Maybe you have been in this situation before, trying to…

3 years ago

Setting up ADConnect and PTA (Password auth through) servers agents behind proxy

If you're using a Proxy server in your firewall or in your network and have…

3 years ago

Get Report of Active Directory Locked Accounts and Machine they logged in from

Story:I got some clients  that have reported some of their users being locked out and…

3 years ago

Checking and Providing Full and SendAs delegate access on O365 Exchange Online

Delegate Permissions This is a code that I have wrote recently to check if an…

3 years ago

Retrieving attachments from Exchange mailbox using python

Story: I got a request from a client who constantly gets CVs and have to…

4 years ago

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298