Say Goodbye to most Desktop and Mobile Adwares

Mario Raciti
Dec 18, 2019 · 7 min read

Some time ago I wrote an article where I described — read it here — an easy way to get rid of advertisements on your smart TVs. Since I was recently struggling with Android apps containing pervasive adwares, I suddenly remembered this simple way to solve, in part at least, the problem: DNS change. Although, I’ve already briefly outlined what a DNS is in the above mentioned article, so I won’t repeat myself. Thus, this time I want to show you a couple of easy ways aimed to change your mobile devices’ DNS, without root permissions, in order to restrict those annoying ads which are showed in the wild in (almost) every free applications and in a lot of websites. In addiction, I will explain how to turn the matter around also in desktop and laptop devices as well, gathering these cases together with the rooted devices scenario. But, before going ahead, let me point out that by altering the DNS addresses, despite the ads put down, you could be exposed to some security and privacy related risks, as the Domain Name Server might address you to a malicious (but apparently safe) website and anyway it is also able to know which websites you browse - the latter should not surprise you because that’s just the DNS work.


Basically, there are two — keep in mind that this first part is intended for non rooted phones — main methods to change the DNS values on an Android device. The first way consists of manually setting the WiFi configurations and unfortunately, as the “WiFi” term suggests, it can’t be applied on mobile data. For this purpose, the second method covers both WiFi and mobile data scenarios since it’s based on the use of a third-part application. Also, this second way is simpler than the former. Let’s proceed with order by describing these procedures.

Android WiFi DNS setting up

WiFI
WiFI
Photo by Jadon Kelly on Unsplash

When you connect to a WiFi network on an Android device, you can edit some interesting settings such as adding a proxy, setting a static IP address, et cetera. This little freedom of customization suits our aim, as we have to simply set up a static IP address in order to change the DNS values. For instance, let “MyPrettyWiFi” be your WiFi network. Thus, once you connected your device to the latter—note that you have to do this process on each WiFi network which you want to change the DNS values of — , just go in the WiFI settings and long press on “MyPrettyWiFi”. Then, just choose the Modify Network entry. At this point, check the Show advanced options box and you should have such a similar situation:

WIFi advanced settings
WIFi advanced settings
WiFi advanced settings

Now by just changing the value DHCP to Static in the IP settings option, suddenly the following options should be displayed:

WiFi advanced settings
WiFi advanced settings
WiFi advanced settings

Finally that’s where magic will happen. So, you have to set a static IP address for your mobile device. But before doing that, you have to search for some network settings in your router — this kind of default info changes from model to model, but you could follow this guide whether you aren’t a networks expert — , such as your router’s IP (gateway) and your subnet mask (network prefix length). Once you got these values, just put them into their corresponding entries. In my case, Gateway = 192.168.1.1 and Network prefix length = 24. At this point, you can finally choose a static IP for your mobile device. Anyway, in order to avoid any kind of addresses collision, I’d suggest to opt for the same IP address which your router assigned to your device — this info is displayed at the top of the Modify network page — or, as an alternative, you could choose (considering the subnet configuration) the fourth value of the IP address in a range [15, 30], for example. Thus, your new static IP address should look like 192.168.1.4, which is the address I opted to keep. Therefore, since the final step consists of changing the DNS values to the AdGuard’s addresses, you have to set DNS 1 = 176.103.130.130 and DNS 2 = 176.103.130.131 and just press the “Save” button. And we’re done! These should be the conclusive configurations:

WiFi advanced settings
WiFi advanced settings
WiFi advanced settings

Alternatively, to add the “Family protection” provided from AdGuard you could opt for DNS 1 = 176.103.130.132 and DNS 2 = 176.103.130.134.

Mobile data DNS work around

Phone speedtest
Phone speedtest
Photo by Mika Baumeister on Unsplash

Unfortunately, as we forewarned in the introduction of this article, unrooted Android devices don’t allow us to change the DNS addresses for mobile data connections. Although, to turn this annoying problem around we can rely on some third-part applications which bypass the problem by creating a Virtual Private Network (VPN) — this way, unlike the former method we’ve just seen, you don’t have to repeat any procedure for each WiFi network or mobile data connection. Indeed, despite unrooted devices prevent the DNS changing, they allow the use of VPNs. DNS Changer is one of the best free apps I’ve tried till now. It provides lots of famous DNS addresses, such as Cloudfare DNS, Open DNS, Google DNS, and it also allows you to add your custom ones. Thus, you have to simply add manually the AdGuard’s DNS addresses and that’s it, problem solved!

DNS Changer screen

Once again, set DNS 1 = 176.103.130.130 and DNS 2 = 176.103.130.131 and press on the “Start” button. Also in this case, remember that alternatively you could opt for DNS 1 = 176.103.130.132 and DNS 2 = 176.103.130.134 to add the “Family protection” provided from AdGuard.

Please note that since DNS Changer is a free app, it contains adwares itself. But you have to deal with ads only when you press the “Start” button, because when the VPN will be created, the DNS changes will affect all the applications, including DNS Changer.


A general method for Desktops and Laptops

Laptop and mobile phone
Laptop and mobile phone
Photo by Unsplash on Unsplash

The most general way to change the DNS addresses on a device which hosts a Unix-like distro and MacOS consists of simply editing the /etc/resolv.conf file. Since this change is permanent, I’d suggest you to backup the file before adding the changes. Eventually, you can edit the file with a text editor and override its content with these two rows:

nameserver 176.103.130.130
nameserver 176.103.130.131

Now save the changes and that’s all! For rooted Android devices you could try to edit /system/etc/resolv.conf. If that won’t work, then check out some of these methods. Note that perhaps a network restart might be needed whether you were not able to connect to the Internet firstly, though.

Windows OS devices

For devices which host Windows OS, you can change the DNS values by following this procedure:

  1. Open Control Panel.
  2. Click on Network and Internet.
  3. Click on Network and Sharing Center.
  4. Click the Change adapter settings option in the left pane.
  5. Right-click the network interface connected to the internet, and select the Properties option.
  6. Select and check the Internet Protocol Version 4 (TCP/IPv4) option.
  7. Click the Properties button.
  8. Click the Use the following DNS server addresses option.
  9. Set the values:
Preferred DNS Server = 176.103.130.130
Alternate DNS Server = 176.103.130.131

Now you can click on the “Ok” button and then “Close”.

That’s all folks!


Conclusions

Adwares are such an annoying problem, especially on mobile devices. But we’ve just seen how some easy tricks based on DNS changing could help us to get rid of them. We can end this article by pointing out that this method of modifying the DNS addresses on a device to avoid lots and lots of unwanted advertisements, it’s based on a blacklist technique. Indeed, AdGuard blacklists all the known IP addresses related to ads services. This can be locally done by making our host resolve those “malicious” IP addresses with another arbitrary address or, simpler, the loopback address (127.0.0.1). In conclusion, this trick, together with some ad hoc router configuration settings, can be used to achieve a more effective solution to block adwares on your whole LAN.


References

  • https://medium.com/@zMrDevJ/how-important-may-an-ad-blocker-be-5059d9855b05
  • https://en.m.wikipedia.org/wiki/Domain_Name_System
  • https://www.cloudflare.com/learning/dns/dns-security/
  • https://en.m.wikipedia.org/wiki/Adware
  • https://adguard.com/en/welcome.html
  • https://www.lifewire.com/how-to-find-your-default-gateway-ip-address-2626072
  • https://en.wikipedia.org/wiki/Private_network
  • https://en.m.wikipedia.org/wiki/Virtual_private_network
  • https://forum.xda-developers.com/general/xda-university/guide-how-to-change-dns-android-device-t3273769
  • https://www.windowscentral.com/how-change-your-pcs-dns-settings-windows-10

The Startup

Medium's largest active publication, followed by +586K people. Follow to join our community.

Mario Raciti

Written by

$~: whoami 'Master Student in Network Systems and Security' https://marioraciti.ml

The Startup

Medium's largest active publication, followed by +586K people. Follow to join our community.

More From Medium

More from The Startup

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade