Oct 25

Reconnectivity

So this is a script — really a series of scripts — I bashed (heh) together in a few minutes last night to check when my VPN connection goes down, with a tiny pinhole in the firewall just enough to send an email, and then send another one when it comes back up. Obviously this is useless if the whole internet connection is down, but that isn’t the use case as I don’t have a backup internet connection anyway (although two ISPs with multihomed BGP and my own /24 on each would be damn sweet). I’m using Ubuntu 16.10, by the way.

This first thing to do was putting an entry at the bottom of /etc/network/interfaces like this:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
up vpnup

The “up vpnup” might not be strictly necessary, but some guides suggested it was and it works, so I’m leaving it. This kicks off a script in /etc/network/if-up.d called vpnup that deletes a file present in /var/run. I’ll explain why later. (If you don’t know, the contents of /var/run are deleted on each reboot.)

Do sudo chmod +x /etc/network/if-up.d/vpnup

That script looks like this:

#!/bin/sh

if [ "$IFACE" = tun0 ]; then
rm /var/run/vpnup
fi

The tun0 is my VPN connection.

Then in crontab I have an entry that runs every minute that does some things and kicks off some other bits in a script depending on what events occur. That crontab entry looks like this:

*/1 * * * * /usr/local/bin/vpndrop.sh >> /dev/null 2>&1

That script “vpndrop.sh” is below, but first I’ll explain it.

The first bit is a ping of four packets that attempts to ping a VPN gateway. If it can’t be pinged, then (after a function declaration and some other crap I should really move), it echoes to a log file and then sends an email (if the base internet connection still works). No leaks — only port 587 is open, and only to a specific address range.

Then it sleeps for three seconds and restarts the Network Manager service. This is because there are a few bugs in Network Manager (actually loads of bugs, but two I care about) that requires restarting it when VPN drops. One is that DNS resolution doesn’t work when VPN drops and then reconnects — at least with certain providers. Hmm, the other bug I seem to have forgotten but there is a second one, not as major. Will add if I recall it.

Then it sleeps again to allow the network connection to fully recover, and then attempts to reconnect to the VPN.

Another five second sleep to allow that to happen, and then it looks for the file in /var/run. If it does find that file (meaning that tun0 and thus the VPN did not come back up), it does nothing in this bit. It just exits. Then it sleeps for 10 and always attempts to write the file I am looking for when the VPN comes up.

There is probably a better way to to do this, but I care the most about knowing for sure when the VPN comes up again so I want that file to be destroyed when it is definitely up so I get an email.

I won’t even go through the nightmare it is configuring an MTA in Linux to relay mail to an outside server. I’m using exim4, and for being an “easy” MTA it took me a long time to get anything to work and many painful steps. Explaining all that would require another tutorial five times as long as this one, so you are on your own there.

Do sudo chmod +x /usr/local/bin/vpndrop.sh

But here’s the script:

#!/bin/bash
if ! ping -c 4 10.15.20.2; then
timestamp()
{
date +"%Y-%m-%d %T"
}

FLAGFILE=/var/run/vpnup
echo "$(timestamp): Damn! That sumbitch disconnected." >> /home/myusername/vpndisconnect.log
echo "VPN disconnected at $(timestamp)" | mail -s "VPN disconnection notice" -r "VPN Alert" myemaile@myemail2.com
sleep 3
sudo systemctl restart NetworkManager.service
sleep 3
nmcli con up id YourVPNConnectionHere
fi
sleep 5
if [ -e $FLAGFILE ]; then
exit 0
else
echo "VPN reconnected at $(timestamp)" | mail -s "VPN reconnection notice" -r "VPN Alert" myemaile@myemail2.com
fi
sleep 10
if [ ! -e $FLAGFILE ]; then
touch $FLAGFILE
fi

Note that I’ve replaced all my private info — including IP addresses — with dummies and aliases.

Yes, I could replace the “sleep” statements with better checking, but the script works for me and I don’t really need (or want) that complexity. I’m not launching rockets here.

Any questions, put on your own rocket and send them my way. I’ll answer with as much as I know.

Oct 24

Rationality

That both sides are rational doesn’t make nuclear war less likely, but rather most often makes it more probable.

The delusions of rationality and empiricism increase the likelihood of nuclear war because it’s easy to calculate a possible “win,” whereas raw emotionalism in almost all cases obviates the possibility of even thinking about it in those terms.

In other words, technocrats can end the world because it looks fine in a spreadsheet….

Oct 24

DR

It’s not fair that some people are intelligent, kind, interesting, lovely, empathetic and strong.

I say this only with affection — but screw you, Daisy Ridley, let other people have a chance! I mean damn.

Oct 23

Being Kurt

As a writer (even though he is not my favorite writer), I’ve always felt the most commonality with Kurt Vonnegut.

I am more like he was than I even realized, though.

INTERVIEWER

Did you take a degree in chemistry at Cornell?

VONNEGUT

I was flunking everything by the middle of my junior year. I was delighted to join the army and go to war. After the war, I went to the University of Chicago, where I was pleased to study anthropology, a science that was mostly poetry, that involved almost no math at all.

Another very observant high-IQ person who has no ability at all in math. Supposedly we don’t exist, but actually it turns out we really, really do.

I understand how scientific reasoning and playfulness work, even though I have no talent for joining in. I enjoy the company of scientists, am easily excited and entertained when they tell me what they’re doing. I’ve spent a lot more time with scientists than with literary people.

I could never be a scientist, either, because being untrainably terrible at math precludes that, and also finding it excruciatingly boring certainly doesn’t help. At the same time, though, I feel no commonality at all with the pretentious and usually incredibly-ignorant lit set.

Back to Vonnegut, though. In 1993, I saw him speak in an auditorium at the University of Florida. As with writing, he had a talent for it and was insightful, droll and did what few teachers actually did in that he actually conveyed some important knowledge to me.

Very much worth the drive and what for me at the time was expensive gas. The talk itself like most of the best things in life was, however, free.

Oct 23

A heaping helping of not helping

Calling people or implying that people are racist Nazi slimeballs for not enthusiastically embracing Clinton is not helpful, most especially if those people are other women. What the progressive left should be doing is holding Clinton to her commitments and statements made during the campaign when Bernie was a real threat, not demeaning women who aren’t blindly cheering Clinton’s coronation.

As they say, just sayin’.

Oct 22

Leaks

I had high hopes for Wikileaks as compared to what it’s delivered. It been obvious for a while that the org is not really about transparency, but rather about being partisan hacks.

However — and this is a big however — what it releases is either true or not regardless of why it was released. The two have absolutely nothing to do with one another.

The moronic left (which I alas now include Sarah Kendzior as a part of*) now believes that Wikileaks is unconscionably terrible and are all racist Nazis because they released items about Clinton and because David Duke tweeted something supportive about the org.

As far as anyone can tell, all the doc dumps were real, the beliefs and statements genuine; none were ersatz in any way. Their truth value is not affected at all even if Hitler himself rises from the grave and declares them, like, the best doc dumps of all time. How can this not be obvious to everyone?

Yes, Clinton’s staff really did write emails where it seems they’d rather self-immolate than give a crap about the poor. True whether or not Clive Bundy prints the documents out, throws them on a four-poster bed and rolls around them while moaning periodically.

It’s just so disheartening to see so many people you thought were better than this go full moron. I can’t make sense of it. Fear? Or are all humans just this broken and it emerges mainly when they care about something enough, that they essentially lie to themselves about reality?

*And if you think this means I am on the right, oh god you really don’t know me at all. I am far, far to the left of Kendzior, who would’ve been in 1970 a barely-left centrist Democrat.

Oct 21

Entangled

Driving in Israel
Across from Gaza
Tanglefoot stretched across the Negev scrub
And you think
People live this way

Every day they see this thin wire
Leading lines for a photograph of a dual captivity
And that’s just how it is

On the beach in Tel Aviv,
A topless woman with a rifle
(Really cuts down on the sexual harassment)
And a few miles away women
Who can’t leave their own house
Without a male minder

I’ve seen these things
And wondered
How we made it this far

Just dumb luck
Intelligence is a parasite
Piggybacking for a time
And soon will abandon its host

I saw the world and it saw me
But wires pulled taut across
The desert of my own mind
Have so far kept me from the answers

Oct 21

HM

One thing I do really like about Timeless is that the main character, Lucy, is in the humanities. She’s a historian. Rare to see in a show like this and welcome.

She doesn’t fight (much). She doesn’t shoot people. She figures out things with an unbelievable treasure trove of facts and historical context.

That I can get behind.

Another thing: both episodes I’ve watched have explicitly dealt with the racist history of the country and not just swept it under the rug. Damn admirable.

Show won’t be renewed, I’d guess.

Oct 20

Hoo

I really like all the new electronica/dubstep/trap that sounds like an Atari 2600 having sex with a lawnmower in a microwave.

I would not have liked this music at all when I was 16, but now I fucking love it.