{"id":1468,"date":"2015-03-29T19:56:50","date_gmt":"2015-03-29T18:56:50","guid":{"rendered":"http:\/\/www.nathankowald.com\/blog\/?p=1468"},"modified":"2016-11-13T17:42:37","modified_gmt":"2016-11-13T17:42:37","slug":"easy-dns-switching-on-os-x","status":"publish","type":"post","link":"https:\/\/www.nathankowald.com\/blog\/2015\/03\/easy-dns-switching-on-os-x\/","title":{"rendered":"Easy DNS switching on OS X"},"content":{"rendered":"<p>I&#8217;m currently using my Raspberry Pi B+ as an ad-blocker. It works great.<\/p>\n<h2>Install Ad-blocker on your Raspberry Pi<\/h2>\n<p>If you have an up-to-date Raspberry Pi running Raspbian, you can install this by running a single command, here: <a href=\"http:\/\/jacobsalmela.com\/instant-raspberry-pi-ad-blocker\/\">http:\/\/jacobsalmela.com\/instant-raspberry-pi-ad-blocker\/<\/a><\/p>\n<p>Make sure you assign a static IP to your Raspberry Pi: <a href=\"http:\/\/www.modmypi.com\/blog\/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address\">http:\/\/www.modmypi.com\/blog\/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address<\/a><\/p>\n<p>By default your Pi will be assigned a dynamic IP by your router. Assigning a static IP means you can connect using the same IP address every time, and setup easy DNS switching below.<\/p>\n<h2>Point your DNS server to your Raspberry Pi<\/h2>\n<p>To use your new Ad-blocker, set your DNS server to the static IP of your Raspberry Pi.<br \/>\nIn this example I&#8217;m using OS X.<br \/>\nChanging your DNS in OS X is done by opening <strong>System Preferences &gt; Network &gt; Advanced &gt; DNS<\/strong> and setting the static IP here.<\/p>\n<p><a href=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.11.04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1469\" src=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.11.04-1024x865.png\" alt=\"Set DNS server on OS X\" width=\"600\" height=\"507\" srcset=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.11.04-1024x865.png 1024w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.11.04-300x253.png 300w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.11.04.png 1352w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h2>Try it out<\/h2>\n<p>Your Raspberry Pi ad-blocker should now be working. You can test if it&#8217;s working by visiting this URL: <a href=\"http:\/\/ads-blocker.com\/testing\" target=\"_blank\">http:\/\/ads-blocker.com\/testing<\/a>.<br \/>\nIf you don&#8217;t see ads on the page, it&#8217;s working.<\/p>\n<h2>Disabling Ad-blocking<\/h2>\n<p>I ran into an issue using my Raspberry Pi ad-blocker where clicking sponsored Google Ads in search results does not redirect to the link.<br \/>\nI wondered if there was an easier way to switch back to my default DNS server in OS X, than manually changing it in System Preferences.<\/p>\n<p>Enter OS X&#8217;s Automator. It comes with OS X.<\/p>\n<h2>Easy DNS switching on OS X using Automator<\/h2>\n<p>1. Open Automator<\/p>\n<p>2. Choose the &#8216;Application&#8217; type<\/p>\n<p><a href=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.22.09.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1476\" src=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.22.09-943x1024.png\" alt=\"Automator - Application Type\" width=\"600\" height=\"652\" srcset=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.22.09-943x1024.png 943w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.22.09-276x300.png 276w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.22.09.png 1116w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>3. Type &#8216;Shell&#8217; into the filter to find the &#8216;Run Shell Script&#8217; action. Double-click it to open the action in the right hand pane.<\/p>\n<p><a href=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-19.07.23.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1498\" src=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-19.07.23-1024x787.png\" alt=\"Screenshot 2015-03-29 19.07.23\" width=\"600\" height=\"461\" srcset=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-19.07.23-1024x787.png 1024w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-19.07.23-300x231.png 300w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-19.07.23.png 1676w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>4. Copy and paste this shell script, replacing 192.168.0.69 with YOUR Raspberry Pi&#8217;s static IP:<\/p>\n<pre lang=\"bash\">\r\n#!\/bin\/bash\r\n# Use the DNS server hosted on my Raspberry Pi\r\nnetworksetup -setdnsservers Wi-Fi 192.168.0.69\r\n<\/pre>\n<p><a href=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.24.31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1475\" src=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.24.31-1024x783.png\" alt=\"Automator - Run Shell Script\" width=\"600\" height=\"459\" srcset=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.24.31-1024x783.png 1024w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.24.31-300x229.png 300w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.24.31.png 1718w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><strong>Note: <\/strong>If you use an Ethernet cable instead, change <em>Wi-Fi<\/em> above to <em>Built-in Ethernet<\/em>. I can&#8217;t bring myself to buy the \u00a325 Thunderbolt to Ethernet adapter so I use Wi-Fi.<\/p>\n<p>If you connect another way, you can find a list of all the network services on the server&#8217;s hardware ports by typing:<\/p>\n<pre lang=\"bash\">\r\nnetworksetup -listallnetworkservices\r\n<\/pre>\n<p>Change <em>Wi-Fi<\/em> to the network service you use to connect to the Internet.<\/p>\n<p>5. Save and choose a name for your app, something like &#8216;Block-ads.app&#8217;<\/p>\n<p>6. By default, your app will have the Automator icon. If you&#8217;d like to change the icon that&#8217;s easily done. All you need is to find a 128&#215;128 PNG.<\/p>\n<p><a href=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.28.05.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1474 size-thumbnail\" src=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.28.05-150x150.png\" alt=\"Default automator icon\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p>7. Using the excellent <a href=\"www.iconfinder.com\" target=\"_blank\">www.iconfinder.com<\/a> makes this simple. I found a nice free Raspberry Pi 128&#215;128 PNG icon &#8211; <a href=\"https:\/\/www.iconfinder.com\/icons\/386490\/raspberry_icon#size=128\">https:\/\/www.iconfinder.com\/icons\/386490\/raspberry_icon#size=128<\/a><\/p>\n<p>8. Download the PNG to your computer, open it in &#8216;Preview&#8217; and copy the icon using \u2318C.<\/p>\n<p>9. Right click your app&#8217;s icon and select &#8216;Get Info&#8217;. Click on the current Automator icon in the top left.<\/p>\n<p><a href=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.05.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1473\" src=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.05-683x1024.png\" alt=\"Change icon\" width=\"350\" height=\"525\" srcset=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.05-683x1024.png 683w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.05-200x300.png 200w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.05.png 776w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<p>10. Press \u2318V to change the icon to the icon in your clipboard<\/p>\n<p><a href=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.38.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1472\" src=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.38-679x1024.png\" alt=\"Screenshot 2015-03-29 18.33.38\" width=\"350\" height=\"528\" srcset=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.38-679x1024.png 679w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.38-199x300.png 199w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/Screenshot-2015-03-29-18.33.38.png 768w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<p>You can now use this app to easily turn ad-blocking on.<br \/>\nIt will prompt for your password when you run it.<\/p>\n<p>11. To\u00a0create your\u00a0&#8216;Show ads&#8217; app, repeat the above steps and change the DNS server to your default DNS server address.<\/p>\n<p>For my &#8216;Show ads&#8217; app I used this icon: <a href=\"https:\/\/www.iconfinder.com\/icons\/386450\/apple_ios_icon#size=128\">https:\/\/www.iconfinder.com\/icons\/386450\/apple_ios_icon#size=128<\/a><\/p>\n<h2>Icon Downloads<\/h2>\n<p>&#8211; <a href=\"http:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/icon-raspberry-pi.png\">Download Raspberry Pi icon<\/a>\u00a0(block ads) &#8211; 128&#215;128 PNG<br \/>\n&#8211; <a href=\"http:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2015\/03\/icon-osx.png\">Download Apple icon<\/a> &#8211; (show ads) 128&#215;128 PNG<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m currently using my Raspberry Pi B+ as an ad-blocker. It works great. Install Ad-blocker on your Raspberry Pi If you have an up-to-date Raspberry Pi running Raspbian, you can install this by running a single command, here: http:\/\/jacobsalmela.com\/instant-raspberry-pi-ad-blocker\/ Make sure you assign a static IP to your Raspberry Pi: http:\/\/www.modmypi.com\/blog\/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address By default your Pi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25,14],"tags":[],"class_list":["post-1468","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","category-useful-information"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/1468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/comments?post=1468"}],"version-history":[{"count":51,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/1468\/revisions"}],"predecessor-version":[{"id":1784,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/1468\/revisions\/1784"}],"wp:attachment":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/media?parent=1468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/categories?post=1468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/tags?post=1468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}