• Block web spammers by their IP address

    Every so often someone tries to post spam to this blog using a computer program. They never manage to because even if their computer does solve the captcha I manually approve every post. It’s not like there are a lot of posts here after all.

    Anyway, I’ve been meaning for a long time to work out how to ban them from accessing web pages anywhere on my server. I always knew it wasn’t difficult, just a case of reading, testing, then making a note for the future. For future me, here’s how:

    iptables is already installed and running
    as the root user, running:

    iptables -I INPUT -s 1.2.3.4 -j DROP

    where 1.2.3.4 is the IP address to block, will block the user. If it becomes an issue, I can also block ranges and subnets and things… perhaps I’ll block the whole of China which is where most of the spam attempts seem to come from but that’s not very nice to 99% of the Chinese people, one of whom may want to find out what an English red mushroom with white spots looks like.

    To check the rule has been included:

    iptables -L -n

    the -L tells iptables to list all the current rules it’s working with
    the -n tells iptables NOT to try and work out the hosts name using DNS. Whilst my own office IP will resolve quickly, spammers generally don’t bother to setup reverse DNS and the list will take ages to display.

    Another thing, I *think* I set up iptables to save it’s configuration when the server is shutdown and reload it when it starts. It certainly remembers the important rules I setup a couple of years ago. However, I’m not really worried if it forgets these IP blocks as I don’t have to do it very often.

    While I’m here, I haven’t blogged at all lately. I’ve been very busy working on our new business web site (which will be at www.rkbb.co.uk sometime very soon). I thought it would only take 2 weeks over christmas to do but it’s turned out to be harder and more complicated. It’s been fun though, so not long and I’ll be able to write about thinks like the arduino based water flow meter I built for work (that was tough and fun too!)


  • Installing Sphinx on Mac OS X Lion

    Moving from Windows/Linux to Mac, one of my Ruby on Rails applications wasn’t working. I’d forgotten to install sphinx, and the error was a little cryptic for an amateur like me.

    Anyway, knowing the problem, installing sphinx I expected to be easy. 2 hours later and I realise it’s working. It was probably working within 5 minutes. These notes are here to remind me what I did next time I need to.

    Get the 2.0.2(beta) from http://sphinxsearch.com/
    I couldn’t work out what to do with the Mac Binaries, so I grabbed the source .tar.gz version.
    Installed ( `./configure` `make` `make install`)
    I didn’t realise it had installed fine – I should have typed “searchd” in bash to get a response like:

    Sphinx 2.0.2-beta (r3019)
    Copyright (c) 2001-2011, Andrew Aksyonoff
    Copyright (c) 2008-2011, Sphinx Technologies Inc (http://sphinxsearch.com)

    FATAL: no readable config file (looked in /usr/local/etc/sphinx.conf, ./sphinx.conf).

    Then carry on and get the config working.

    If anyone reading this knows what to do with the binary version, please share!


  • Windows to Mac continued

    Where did that month go! It seems only 2 weeks ago I was opening the box of my new macbook pro but it’s actually been a month already. So, what have I learned?

    Remember how I said how I found it strange the mouse wheel direction had reversed? Well, that’s a new ‘feature’ of OS X Lion. It’s called “natural scrolling”. Well, it might be natural if your on a touch screen grabbing the page, but I’m still used to considering the scroll controlled by mouse as moving the scroll bar down the side of the page. Fortunately, there’s an option to turn that off. Now I like keeping to as many software defaults as possible so that when I use someone elses machine things work the way I expect, but this change doesn’t seem ideal to me. It feels like a change for the point of change rather than a thought out user interface decision. That is, a nice idea in theory, but everyone is used to the standard so don’t change it. To me, this would be the same as changing the keyboard number pad (number 1 is at the bottom) to match a telephone keypad (number 1 is at the top). Or, why not make a desk calculator the same as a desk phone (calculator number 1 is at the bottom). That difference has been a minor irritation of mine for years, but I wouldn’t change it – not when so many devices are set that way and I’m used to it.

    What else? Ahh, disk and memory. So, I knew I need to put windows 7 on the mac, but I hadn’t realised just how much memory the two together would need. Some irritating slow performance of the Mac software has been caused by limiting it 3GB for the Mac, 1GB for Win 7. I know, that’s not a lot for Windows 7 but for the design software and MS Access database I use that should be sufficient. Maybe it’s not, maybe Parrallels is letting Win 7 use real memory as virtual memory (that would be clever), but I was constantly over the 4GB and noticing slow performance due to pages swapping in and out of Virtual Memory. For the geeks, on Friday after a couple of days use (I’m getting used to suspending the laptop, rather than not shutting down – I like that feature!) I had Page ins and outs of something like 20GB. So, I spend 35 on 8GB of memory chips (2 x 4GB) and after a day I have page ins of 3GB and page outs of 3MB (or 0.003GB). I haven’t noticed any slow downs either but the proof will be a full day of design work, rather than just opening a load of programs.

    Ruby, on the other hand, has been a pain in rear. I have at least become familiar with RVM (and I like the idea), JewleryBox (a GUI for RVM, which I like a lot) but I’ve yet to get one of my Ruby on Rails applications running. Things are falling down because Xcode 4.2 didn’t include C compilers, I spent the time installing 4.1 and I still can’t install Ruby. While I type this I’m downloading another set of compilers, uninstalling then reinstalling RVM and feeling every bit that all the people that rave about how Mac is great and doesn’t go wrong, simply don’t push their computers hard enough or far enough to experience the problems. That, or they accept the problems and don’t find ways to fix them. Pretty much the same as me and my car – having spent about 2 years without a light behind the rev counter simply because it didn’t really bother me a night knowing how many RPM’s the car was using, especially as it’s an automatic.

    322-IMAG1043-thumb-300x229-321.jpg Oh, I gave up using the windows keyboard, had to buy a Mac keyboard. It’s wired because I need the numberpad in my job. Although the wireless small version looked nice. I also have yet to get the Thunderbolt to HDMI adapter working. It may be my TV, but there’s video and no audio. Another work in progress.

    I’ll leave this post with a picture. This is my desk last month, with new Mac, existing monitor and old laptop. When seen together I realise why it was getting so hard to use my old laptop – the screen had dimmed so much. It will be interesting to see if this Macbook lasts as long (5 years).


Search this site


Free apps

  • birthday.sroot.eu – Your birthday or other celebration date based on [years on other planets] / [how many seconds/days] / [how far you’ve travelled around the sun]
  • stampulator.sroot.eu – Calculates the combination and how many 1st, 2nd, large 1st and large 2nd class Royal Mail stamps you need on large envelopes and packets

Recent posts


Archives


Categories