Purging DNS cache

Connection sharing, Firewall, Samba..etc
Forum rules
Before you post please read how to get help
User avatar
jelabarre59
Level 2
Level 2
Posts: 51
Joined: Thu Jan 20, 2011 6:57 pm

Purging DNS cache

Postby jelabarre59 » Wed Sep 20, 2017 5:42 pm

Is there a way to purge the DNS cache in Mint 18.2 after you have edited /etc/hosts (either manually or through Mintnanny)? The major failing with redirecting entries in the hosts file is it only works of someone hasn't already visited the website. If they *have* visited the site since the system was booted, the browser will go right to the site without looking at the change in /etc/hosts.

I'm not looking to do permanent blocking with this; it's more for my daughter getting distracted by some site (especially Youtube), and I want to temporarily block the site until her homework is done (and any chores). Eventually I'm building a DD-WRT or OpenWRT-based router to give better filtering, but for now I just want to readily SSH into her laptop and redirect sites temporarily (I have a very simple http server on the machine which brings up a page with the JMFlagg "Uncle Sam" and a message to tell her to go back to her homework. Only works for http though, not https).

ColdBootII
Level 3
Level 3
Posts: 169
Joined: Wed Aug 02, 2017 8:19 am

Re: Purging DNS cache

Postby ColdBootII » Wed Sep 20, 2017 6:06 pm

First off, check with ps ax | grep dnsmasq if DNS caching is enabled in your system. --cache-size=0 means that caching is disabled. I think that is the default in LM which is why it's not necessary to purge it.

User avatar
jelabarre59
Level 2
Level 2
Posts: 51
Joined: Thu Jan 20, 2011 6:57 pm

Re: Purging DNS cache

Postby jelabarre59 » Wed Sep 20, 2017 6:46 pm

dnsmasq is enabled, with "--cache-size=0". Still doesn't solve the problem. If someone has visited the page, the system will not switch to a local redirect in /etc/hosts without having to log out and back in. Looking for a method of forcing the system to change immediately.

ColdBootII
Level 3
Level 3
Posts: 169
Joined: Wed Aug 02, 2017 8:19 am

Re: Purging DNS cache

Postby ColdBootII » Wed Sep 20, 2017 7:10 pm

I see... What will do the trick, I think, is to simply kill her browser. Then when she restarts it, youtube (and other sites blocked in hosts) should not load.

Edit: I have tried this myself now. Even If I merely do a refresh on Youtube, once the site is blocked in hosts, it becomes unreachable. So, killing the browser(s) is a simple method to do it.

Edit2: still better, because you don't want to corrupt the browser's profile by frequent forceful killings, just close it with wmctrl -c "Firefox" or whichever browser is in use. I think, wmctrl is bundled in LM 18.1 ISO.

User avatar
trytip
Level 5
Level 5
Posts: 859
Joined: Tue Jul 05, 2016 1:20 pm

Re: Purging DNS cache

Postby trytip » Wed Sep 20, 2017 9:30 pm

the simplest way is to rightclick on your network tray icon and DISABLE Networking leave it for a few seconds and then ENABLE Networking

to disable/enable networking CLI use
sudo service network-manager stop
sudo service network-manager start
I love Windows, they give my walls personality.


Return to “Other networking topics”