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).
Purging DNS cache
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
-
- Level 2
- Posts: 83
- Joined: Thu Jan 20, 2011 6:57 pm
Purging DNS cache
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Purging DNS cache
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.-
- Level 2
- Posts: 83
- Joined: Thu Jan 20, 2011 6:57 pm
Re: Purging DNS cache
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.
Re: Purging DNS cache
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.
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.
Re: Purging DNS cache
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
to disable/enable networking CLI use
sudo service network-manager stop
sudo service network-manager start