Turning off ipV6 in Ubuntu 16

My home router doesn’t handle IPv6, and for that matter, neither does my ISP, so I get a lot of IPv6 related garbage in my syslog and kern.log. To turn it off, you need to create a new file, rather than editing a system file, and then reload these settings.

sudo nano /etc/sysctl.d/95-disable-ipv6.conf
#add the following lines
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
# reload kernel parameters
sudo service procps reload
# Check that its taken ... the result of this should be 1
cat /proc/sys/net/ipv6/conf/all/disable_ipv6


Blocking irritating PLDT Billing popups

So you forgot to pay your bill. It happens. PLDT used to set an automated phone call to call you once a day until you paid. Now they have something much more irritating, and something that feels borderline illegal. What they do is they hijack your internet connection. Every four or five page loads, they inject an HTML frame with a monster ad, which sits on top of all your work. You have no choice but to click on the button which takes you to a page with the amount you owe (which means they know which IP is your account BTW).

However there is no way to remove the popup, which sits on top of your browser. There is no ‘close window’ button, which means your only choice is to refresh the page, or close the window and re-open it. Too bad if you were working on something and hadn’t pressed the save button: that’s now gone. And even after you pay, the popup sticks around for a day or two … (how hard can it be to automatically cancel it?)

So how do we block it? The frame is an iframe which uses an IP address, so we can’t use DNS blocking or hostfile blocking. So changing the routing table seems to be the way to go.

On Linux, using sudo if necessary:

# check routing table
route -n
# Add rule
route add gw lo
# check routing table again
route -n
# check desired result
ip route get


More Control Over Logwatch Report Dates

I’ve been happily running Logwatch on several servers with the default ‘yesterday’ date range for several years. However I needed to run it for a client with a larger date range to check out a problem. But the options available for logwatch are only ‘today’, ‘yesterday’ and ‘all’. Or so it told me. And even worse, the ‘yesterday’ option takes the date from the previous day, and pulls out all the info on that date. So if you run your logwatch report at 4pm, you’re missing out on 16 hours worth of data! But it turns out logwatch is smarter than that …

Read more

How to change the time anacron runs.

Well this one took me a while to figure out, so I thought I’d blog about it in case I could save someone else some time. Anacron is installed on desktop / laptop orientated distributions as they’re often switched off. It basically makes sure the daily, weekly and monthly cron jobs are run by checking the time they were last run, and running them if they weren’t run in the last day, 7 days or 30 days respectively. It will also check these when the machine is rebooted. So it makes sense on machines that are rebooted frequently.

However I have a server where it is also installed, alongside cron, and I wanted to change the time logwatch ran every day. My first attempt was to simply change the times in /etc/crontab, which contained lines like this
25 00    * * *    root    test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
Changing the time was ineffective, although I gather that if I’d removed anacron (or specifically the file /usr/sbin/anacron ) then this approach would have worked.

My research let me next to the /var/spool/anacron directory where there are three timestamp files cron.daily, cron.weekly and cron.monthly. I experimented with changing the time on these to fool anacron into running earlier in the day. This was also ineffective.

Hmm. Finally I found the solution, which kinda makes sense, but is well hidden. In /etc/cron.d/ there is a file which runs anacron containing the line
30 23    * * *   root    test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/nul

Changing the time on this will make anacron run at your chosen time, and you’ll have your logwatch report before breakfast.


Ubuntu / Mint gvfsd-metadata kill script.

I’ve always had trouble with gvfsd-metadata. Not that I know what it actually is, I just know that once or twice a day my computer will become unresponsive, and the culprit is this little program running around in the background, doing whatever it does, and pegging my CPU up to 100%. I’ve searched many forums. A lot of people are affected, but there doesn’t really seem to be any solution, or any clear reasons why it happens.

So what I usually do is open up a Terminal, run top and see that gvfsd-metadata is at the top of the list redlining my CPU. From there, I press k to kill it (if its the topmost item, its PID will be automatically selected, otherwise enter the PID manually), and then retain the suggested kill signal value of 15. Not a terribly hard process, but as the CPU is maxed out, then opening a Terminal window and top can take a few minutes. Its that sluggish. So, like you do, I whipped up a quick script to handle this automatically, which I run every 5 minutes.

Read more