accidental coder

the life and times of a twentysomething sysadmin
May 12th, 2008

Doncaster’s political landscape just got wierder…

Mayor ‘forms new political party’

Seems everything isn’t so rosy in the Labour camp in Doncaster. Word is that the Mayor, Martin Winter, has registered a new party - ‘The Labour Group’ - along with two as-yet unnamed councillors.

The Labour party, meanwhile, are understood to be a bit miffed, giving the trio 14 days to reregister with them, or face having their party membership cancelled.

Things should become a little clearer on Wednesday, when the Mayor is due to address a meeting of the local Labour group on Wednesday.

Update @22:59: Okay, the Free Press has more information, and it appears there may be a motive behind this.

It appears the two councillors involved are Stuart Exelby (Central) and Eva Hughes (Wheatley).

From the article:-

Mr Winter is currently in the last year of his second term as mayor. He has previously announced his intention to stand for re-election next year.

However, current Labour rules restrict candidates standing for a third term.

A cynic could argue that this is to allow Mr Winter to stand for a third term. Please feel free to draw your own conclusions.

May 10th, 2008

RIP Chris Drane

Suicide project student took life.

I didn’t know Chris amazingly well, but we knew each other through the alternative music scene in Doncaster. Chris used to take photos for SSI, a music community website I set up in 2002.

Chris was an excellent photographer (see his flickr page here), and his passing is a great loss to the world.

RIP, Chris.

April 26th, 2008

A fuss about nothing

The newspapers this morning are full of woe, doom, gloom and predictions of the end of civilisation/the world as we know it, and fuel is once again the cause.

Oil refinery workers at the INEOS refinery in Grangemouth are staging a 48-hour strike in a dispute over pensions.

The upshot of all this is that 30% of the UK’s daily oil output will be unavailable. This - apparently - is no big deal from a supply point of view as the UK has about two months’ worth of reserves. However, no matter what the real story is, a combination of the fuckwittery of the national press and the ability of the Great British Public to go into a mass panic and follow each other sheep-like can never be underestimated.

The Daily Heil is right in there with its usual mix of fear-mongering and doom-saying, which can only mean there’s no stories about illegal immigration requiring their usual right-wing Nazi mouth-foaming take on things. A few choice quotes from the article:-

  • ‘A major fuel crisis will send petrol and diesel prices soaring this weekend.’
  • ‘The crisis is being deepened by clear signs that motorists are panic-buying, despite pleas for calm from Gordon Brown. There have also been allegations of profiteering by garages.’
  • Billy Brit will be sat at home, and he’ll read this and go “Fuck that, nobody’s scabbing me out of a few pence a litre. Best go and fill up every single container I can lay my hands on!”.

  • ‘Experts are also warning that if a large proportion of the UK’s 33million motorists panic and fill up their tanks simultaneously, the whole oil company storage system could be drained.
  • …however…

  • ‘Experts say the UK has 67 days of reserves in the system.’
  • Come on, you twats. At least make your minds up! The old ‘expert’ is a favourite of papers like the Mail, usually warning that your street is going to fill up with Eastern Europeans and/or your house price is going to plummet, and is this time invoked to create more panic. The ‘67 days’ quote is obviously buried further down the page, as it doesn’t make for good, wholesome, fearmongering journalism.

    But the best part of the article is this:-

  • ‘But energy minister Malcolm Wicks sparked controversy when he admitted he could not guarantee that every garage and forecourt would have petrol every time motorists arrived to fill up.’

    To anybody with more braincells than they have fingers, I know that with Labour’s obsession with surveillance that they should be all-seeing and all-knowing, but saying they can’t guarantee every garage will have fuel all of the time is a bit like saying that they can’t guarantee it won’t rain next Tuesday, or that next time your nip to the local Tesco they’ll have your favourite brand of tramp juice. It’s stating the fucking obvious, and it’s being twisted into something that, to be frank, is irresponsible.

    As with the fuel protests in 2000, if people carried on using the petrol station as they usually do, everything will be fine. But as the British attitude nowadays is to just fuck everybody else, as long as you’re alright, people will act like dicks and queue up just to stick 20p worth of fuel in their car.

    It’s about this time that I’d wish fiery death on people for being pricks, but since there’s images of people filling up jerrycans in the article linked above, I guess Darwin will probably perform that job quite admirably.

  • April 22nd, 2008

    Cheap and easy tunnels: GRE and Linux

    There’s quite a few different ways in which to set up tunnels between Linux machines, and using GRE tunnels is probably the quickest. There’s a number of reasons why it might not be the best for you, but for certain things it gets the job done.

    GRE (Generic Routing Encapsulation) is a tunnelling protocol (protocol 47 - cheers Wikipedia) developed by Cisco. Since this is a quick guide I won’t bore you with the details, but if you’re interested the Wikipedia article linked in the previous sentence is a good start.

    So why might you want to use it? I’ve used it in the past to create a ‘private network’ between my box at home and my hosted box, and in turn used it to route parts of my IPv6 block over. It’s also useful to allow one private network access to another, where normally (i.e. directly over the Internet) it wouldn’t be possible. Whatever the reason, setting it up takes less than a couple of minutes.

    I mentioned earlier that there’s a number of reasons why this may not be what you want. Two of the main ones are:-

  • NAT - if either of the boxes at either end of the proposed tunnel are behind a NATed IP, forget it. You may be able to magic something up that will look like it works, but it won’t. For the time it’d take to fart about getting round this, you’d be better off using something like OpenVPN. This also has the advantage of covering the next one…
  • Security - if you want an encrypted tunnel, then this isn’t for you. You should treat anything going over the tunnel as if you were sending it over the public Internet - which, in reality, you are. The packets are merely encapsulated (i.e. ‘wrapped up’) in an extra layer of routing, which is then de-encapsulated at the other end. Examining the contents of the packets whilst in transit across the internet would be no more difficult that peeking into normal, non-GRE packets. Overall, this means you should still use SSH, and use SSL for anything you consider sensitive. Or, as above, use a proper VPN solution.
  • Once you’ve considered the above, it’s time to get stuck in.

    Let’s assume you have two boxes, named ‘tea’ (with a public IP of 192.168.10.1) and ‘coffee’ (192.168.20.1). Glossing over my flagrant abuse of RFC1918 addresses, we’ll assume that ordinarily these machines can see each other over the public internet. Behind each machine is a network - tea has 10.0.10.0/24, and coffee has 10.0.20.0/24.

    At this point I’ll introduce you to ‘ip‘, which is part of the iproute2 suite. If you’re running a distro made this century, chances are it’ll already be there, waiting to be used. The ip command serves as a replacement for ifconfig, netstat -rn and a whole host of other things, but that’s out of the scope of this post…

    Anyhow, before we start it may be neccessary to turn on IP forwarding in the kernel on both machines. If they’re being used as an internet gateway then it’s probably already turned on. To check:-


    tea:~# sysctl net.ipv4.ip_forward
    net.ipv4.ip_forward = 1

    If it’s a 1, it’s on. 0 (suprise suprise) is off. To turn it on:-


    tea:~# sysctl -w net.ipv4.ip_forward
    net.ipv4.ip_forward = 1

    You can also use the older method:-


    tea:~# echo 1 >/proc/sys/net/ipv4/ip_forward

    Once you’ve finished with that, we can get started on the tunnel. To get started, on tea do:-


    ip tunnel add mytun mode gre local 192.168.10.1 remote 192.168.20.1 ttl 255
    ip link set mytun up

    …and on coffee:-


    ip tunnel add mytun mode gre local 192.168.20.1 remote 192.168.10.1 ttl 255
    ip link set mytun up

    …and that’s it. You should now see an interface appear on both machines called ‘mytun’. The name isn’t important, and doesn’t have to be the same on both ends, so feel free to choose something more descriptive.

    At this point, the tunnel is pretty useless. Before we can use it properly we need to assign an IP to each end of the tunnel. As I mentioned earlier, ip lets us do this pretty quickly:-

    on tea:-

    ip addr add 10.0.30.1/30 dev mytun

    and on coffee:-

    ip addr add 10.0.30.2/30 dev mytun

    As you can see, we now have two IPs from a small /30 subnet assigned to either end of our tunnel. To test this, try pinging one end of the tunnel from the other:-


    tea:~# ping 10.0.30.2
    PING 10.0.30.2 (10.0.30.2) 56(84) bytes of data.
    64 bytes from 10.0.30.2: icmp_seq=1 ttl=64 time=51.6 ms

    If you’re seeing responses, it’s working, and you can give yourself a pat on the back.

    The final part of this is to add some routing into the mix, to allow our private networks to see each other. Again, with ip this is a doddle:-

    on tea:-

    ip route add 10.0.20.0/24 via 10.0.30.2 dev mytun

    on coffee:-

    ip route add 10.0.10.0/24 via 10.0.30.1 dev mytun

    And that’s it. As an example, a host named ‘biscuit’ (IP 10.0.10.2, behind ‘tea’), and another host named ‘cake’ (IP 10.0.20.2, behind coffee) should now be able to route to each other. This assumes tea and coffee are their respective default gateways - if not, then routes will need to be added on them. This can then be tested with a traceroute:-

    on biscuit:-

    biscuit:~# traceroute 10.0.20.2
    traceroute to 10.0.20.2 (10.0.20.2), 30 hops max, 46 byte packets
    1 10.0.30.2 (10.0.30.2) 53.798 ms 52.029 ms 52.037 ms
    2 10.0.20.2 (10.0.30.2) 51.609 ms 53.006 ms 51.176 ms

    At this point, you’re done! If you were to draw a little diagram, it would probably look a bit like this:-

    [biscuit]<->[tea](192.168.10.1) <-- *internet* --> (192.168.20.1)[coffee]<->[cake]
    10.0.10.2       [(10.0.30.1)       <--tunnel-->       (10.0.30.2)]       10.0.20.2
    

    Problems?
    There’s a couple of things you may run into. If this doesn’t work for you, check:-

  • that you’re not blocking incoming GRE packets at one (or both) end(s). You can allow this by doing something like:-
    iptables -I INPUT -s -p gre -j ACCEPT
  • that you’re not blocking outgoing GRE packets. See above.
  • Otherwise, it might be time to break out tcpdump. tcpdump will allow you to sniff on the virtual ‘mytun’ device, and you’ll see only traffic related to the tunnel.

    April 12th, 2008

    Meat-free bacon… what?

    Despite being a fatty (or probably because of it), Saturday mornings tend to be fry-up day. A trip to Tesco this morning yielded the neccessary ingredients for such an event, with the notable exception of turkey bacon, which SWMBO eats instead of the thinly-sliced pig version I’m happy to ingest. To replace the lack of said product, some “Tesco Meatfree Streaky bacon style rashers” were purchased…


    Meatfree? You’ll wish you were tastebudfree by the end of it

    Oh dear. Usually companies make their produce at least look edible on the packaging, but with this, apparently not. To say it looks like something you’d find dried, in a tin, in the sale aisle at Lidl is an understatement.

    But that’s just the packaging…


    Alternative uses: Ice scraper, shoe insole replacement

    Ladies and gentlemen, this is what’s inside. It’s frozen, and as such has the consistency of cheap icecream. You’ll also notice that Tesco aren’t fucking about - it’s streaky, just like it says on the tin box.


    Yes, it’s solid


    Don’t let this picture mislead you. Up close, it looks like frying felt

    To at least give it a bit of flavour, I fried it in the same oil as I was doing my regular sliced-pig-bacon. After a few minutes, it at least starts to smell like bacon. Then, it just burns. And it smells like plastic in the process of burning.

    Which brings us onto the finished product…


    Burnt, fried soya? Check!

    It’s not often I’m disgusted, but I occasionally make exceptions

    The verdict? Unsuprisingly, it tastes like shit. Shit that smells of burnt plastic. Shit that tastes like it was placed inside a bag of cheap bacon-flavoured crisps and shaken to within an inch of its soya-and-wheat-protein life. There’d be a picture here with me ‘enjoying’ the meat-free taste, but I was too busy wondering if I should just drink the oil from the frying pan to get rid of the taste.

    Next week: Quorn sausages that smell like a mixture of weed, cardboard and the contents of your Hoover.

    April 11th, 2008

    Disturbing.

    BBC News is reporting that Poole Borough Council has been using its powers under the Regulation of Investigatory Powers Act to spy on a family it suspected of lying to gain places at a school for their children.

    As always, if authorities have the powers, they will use them, no matter what the intention of the legislation was to start with. Poole aren’t the only ones, either, with Stoke-on-Trent apparently making over 100 separate applications last year alone.

    Your phone, postal and browsing records - available to a local council near you… now.

    April 9th, 2008

    Stopping hotlinking for dummies

    I had a look through the logs today for www.captionmykitten.com

    and discovered that the vast majority of the referrers were people hotlinking to the images. Now, I’m not in the slightest bit bothered about people nicking images off it, because they’re uploaded by other people anyway, but using my bandwidth is a little be rude to say the least.

    So huzzah! It’s been a while since I used .htaccess files, but this is a handy little guide to doing it to stop hotlinking of images from elsewhere.

    December 9th, 2007

    ninjas, pirates and zombies

    “Claustrophobic pirates vs. hypercondriac ninjas. Who would win?”

    (via)

    December 1st, 2007

    BBC Travel + Highways Agency + Google Maps = ???

    I’ve been having a play with the Jamcams that the BBC now have on their site for some of the areas in the UK, such as mine. I’ve also discovered that the Highways Agency (who maintain the national Motorway network in the UK have RSS feeds of their traffic information.

    I noticed that the XML the Jamcams site uses and the RSS feeds from the Highways Agency have location information in them. Coupled with Google Maps… and you get this.

    It only covers South Yorkshire, West Yorkshire and Greater Manchester properly at the moment, but keep an eye out if you’re interested in seeing more.