Blocking China

Tired of seeing Chinese IP addresses in my server logs trying SSH access, I decided to completly block it off.

Easy way todo this? Yup.


#!/bin/sh

cd /home/michael/System\ Scripts/Sineo_IPTABLES_Block/

wget http://www.okean.com/antispam/iptables/rc.firewall.sinokorea

sed -i 's/INPUT/SINEO/g' /home/michael/System\ Scripts/Sineo_IPTABLES_Block/rc.firewall.sinokorea

sed -i '/iptables -A SINEO -m state --state ESTABLISHED,RELATED -j ACCEPT/d' /home/michael/System\ Scripts/Sineo_IPTABLES_Block/rc.firewall.sinokorea

chmod +x /home/michael/System\ Scripts/Sineo_IPTABLES_Block/rc.firewall.sinokorea

sudo /home/michael/System\ Scripts/Sineo_IPTABLES_Block/rc.firewall.sinokorea

This will download a formatted list of chinese and Korean IP addresses, change the iptables chain to point to a new chain rather than the input chain, remove the now pointless established rule, and install the chain. Obviously, change the file paths to suit your structure.

It will however, require root to install the chain.

Backup, Its Important!

Recently I switched my last computer over to linux, and this meant I had to rethink my backup strategy. I like to copy all important files over to a central area, maybe even to a remote NAS box. In windows this was done via a simple batch file each user ran when they felt like it to copy it to a shared drive on the network. On linux, I can utilise the power of rsync, and do it all from a local terminal. So I cooked up the following bash script.
There are a few dependencies this has, it requires the following:

  1. s3cmd installed and configured to the S3 account
  2. rsync installed on all machines. (Not installed as standard on Debian systems.)
  3. An available drive or NAS box attached.
  4. If passwordless required for connecting to the other boxes, you will need to set up passwordless SSH, which I’ll not cover here, but there are countless other tutorials to cover this.

It can be run from a simple cron job, or manually when required. There are command line options that can be run

  1. -clean
    1. -clean command line will cause rsync to delete any files that are no longer on the source from the archive. It will also remove any files that have been copied, but now excluded from the exclusion file.
  2. -s3
    1. Will cause an upload event and syncronise the Amazon S3 archive with the local. This will not however trigger a local update event
  3. Empty command line
    1. Will simply backup files to the target machine from the sources, this will not clean the archives, nor will it trigger a S3 upload.

So, lets break down the source and have a look.

</p><p>if mountpoint -q $BCK_DEST<br>then<br>echo "Backup Location is mounted"</p><p>if [ -z "$1" ];<br>then<br>echo rsync command is: -$RSYNC_CMD_STD<br>#--------------------------------------------------------------------------------------<br>#Copy To Local Storage<br>echo Backing Up<br>rsync -$RSYNC_CMD_STD -e ssh --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/1<br>echo Backing up $HOSTNAME<br>rsync -$RSYNC_CMD_STD --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/2</p><p>#--------------------------------------------------------------------------------------<br>fi</p><p>

This first section is the overall backup, responsible for copying the source to the target. We initially connect the rsync over to the target via SSH, and copy the entire home folder, minus the excluded files and directories. Its only run, should the command line be empty, the default run if you like. The variable $1 is the first command line option passed to the script. One of the important things we do here, is ensure that the drive is actually mounted in the system. If this is not mounted, everything else will fail.

<br>if [ "$1" = "-clean" ];<br>then<br>echo RSync Clean Command is: -$RSYNC_CMD_STD$RSYNC_CMD_CLEAN<br>echo Backing Up<br>rsync -$RSYNC_CMD_STD$RSYNC_CMD_CLEAN --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/1<br>echo Backing up $HOSTNAME<br>rsync -$RSYNC_CMD_STD$RSYNC_CMD_CLEAN --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/2<br>fi<br>

This section is the clean up. It runs the standard backup, along with the rsync options “–delete-after –delete-excluded” which clean up the archives.

<br>if [ "$1" = "-s3" ];<br>then<br>echo S3 destination is: $S3_BUCKET<br>echo Amazon Upload Proceding<br>s3cmd sync $S3_CMD $BCK_DEST/1 $S3_BUCKET/1<br>exit<br>fi</p><p>

This section is the amazon upload. Its not quite complete,.and there are more directories to add to the upload. However, uploading to amazon, is not the quickest thing in the world, and I’ll add the other important directories as and when the uploads complete.

And here it is, in its entire bash like glory.

<br>#!/bin/bash</p><p>#VARIABLES<br>BCK_DEST=/mnt/sdc1<br>EXCLUDE_FILE=rsync_exclude<br>S3_BUCKET=S3 Bucket<br>RSYNC_CMD_STD=avzh<br>RSYNC_CMD_CLEAN=" --delete-after --delete-excluded"<br>S3_CMD="-rH --skip-existing --delete-removed --acl-private"</p><p>echo backing up systems<br>echo ______________<br>echo Exclude File Path: $EXCLUDE_FILE<br>echo running on: $HOSTNAME<br>echo destibation is: $BCK_DEST<br>echo Command line passed: $1</p><p>#ENSURE DRIVE IS MOUNTED<br>if mountpoint -q $BCK_DEST<br>then<br>echo "Backup Location is mounted"</p><p>if [ -z "$1" ];<br>then<br>echo rsync command is: -$RSYNC_CMD_STD<br>#--------------------------------------------------------------------------------------<br>#Copy To Local Storage<br>echo Backing Up<br>rsync -$RSYNC_CMD_STD --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/1<br>echo Backing up $HOSTNAME<br>rsync -$RSYNC_CMD_STD --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/2</p><p>#--------------------------------------------------------------------------------------<br>fi</p><p>if [ "$1" = "-clean" ];<br>then<br>echo RSync Clean Command is: -$RSYNC_CMD_STD$RSYNC_CMD_CLEAN<br>echo Backing Up 1<br>rsync -$RSYNC_CMD_STD$RSYNC_CMD_CLEAN --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/1<br>echo Backing up $HOSTNAME<br>rsync -$RSYNC_CMD_STD$RSYNC_CMD_CLEAN --exclude-from $EXCLUDE_FILE REMOTE SYSTEM $BCK_DEST/2<br>fi</p><p>if [ "$1" = "-s3" ];<br>then<br>echo S3 destination is: $S3_BUCKET<br>echo Amazon Upload Proceding<br>s3cmd sync $S3_CMD $BCK_DEST/1 $S3_BUCKET/1<br>exit<br>fi</p><p>else<br>echo "Backup Location is not mounted"<br>exit<br>fi<br>

Hope you find this useful, and if you have any ideas how to improve it, let me know.

Another stupid maintenance story.

The bearings have gone in my fulcrum quattro, not unusual as Fulcrum ship with bearings that are sealed on one side only. So they do tend to go quite quick.

But I couldn’t be bothered to change them out yet. So I grabbed a spare set of wheels, a Mavic Aksium pair. Cassette and tyres mounted, on the bike and spinning. They are certainly not the best wheels in the world, but they work.

Off I went for a ride. Noise. Rubbing noise. Any noise on a bike annoys me. I checked the tyre clearances, break pads. All fine. Noise was still there. I adjusted the pads on the front wheel, I could swear the noise was coming from the front wheel. Checked spokes, all appeared to be tight enough with a simple squeeze test.

No idea what this noise was. Then, all of a sudden it disappeared, nothing, no noise apart from the road noise.

Shifted up into the large chain ring, and there it was again. I thought the cable may of come slightly loose as I hadn’t adjusted it since changing the cables, so turned the barrel adjuster a turn, span the cranks and the noise was worse. What the hell.

On look, the cable end was rubbing on the wheel…

Still chasing a rattle

So, this rattle that I’ve been chasing, while slightly better with a different wheel, is still there under certain conditions.

However, I have an idea it could be the Wahoo mount I’ve been using. So, I’ve swapped it for the Garmin mount while I try and work out what it is. I have cranked down in the Puck bolts, but will first see what happens with the garmin mount.

  • Tried numerous times remove and clean headset
  • Replaced carbon expander bung
  • Replaced front wheel
  • Checked skewers
  • Replaced wheel bearings
  • Checked for visible cracks and damage

So, after a ride with just the garmin mounted, no noise. Nothing, not a damn rattle anywhere. I’ll give it a couple more rides to make sure, but it maybe cured.

So what is it about the mount I have for the Wahoo? Well, it could be a couple of things.

The Elemnt is a bigger unit, and heavy. So it could be moving, and hitting the handlebar clamp bolts as it sits very close to them. Which, I suppose could be the reason I went all out for a headset issue. Or it could of been the actual Puck on the mount being loose. I’ve really tightened them down. So if it does it after I refit, I’m likely to go down the route of it hitting the stem bolts.

The solution to that would obviously be a longer mount, like the k-edge. But I’m not really wanting to spend £50 on a mount.

Wheel Damage

My last post was about issues with the headset. I think I’ve cured that now, but onw of the symptoms was a judder under breaking.

I’d assumed this was the headset suffering from the forces of breaking. However, I was reading about brake judder and it got me wondering if that was the cause of the juddering.

Mounted the bike up in the work stand, removed the front wheel and cleaned both the brake track and sanded the pads down. I was putting the wheel back on, and by gently holding the brakes while spinning the wheel, I could feel a slight rubbing in a section of the track.

Looking closer at the rim, there is a chunk missing, maybe couple of millimeters, and that slightly catches the pads as they contact. That, could very well be the reason I’ve got such bad judder on breaking.

So I’ll fit my spare wheels for my next ride and see how they feel on the bike.

Hopefully, this will be the conclusion of this drawn out saga.

Back to Garmin

I’ve been using a wahoo elemnt for a while now, and the Garmin 520 has Sat all forlorn on the shelf.

Today however saw it dusted off, and remounted after the elemnt mount broke. It’s a bit of a bad design. You can never have it just tight enough on the bar not to slip. Which meant I tightened it, only to pull the brass press fit screw thread out.

But going back to the garmin, made me realise that there is actually stuff I’d missed that the elemnt hasn’t got. And the opposite too. I missed some of the features of the Elemnt.

So, in no particular order here is what I miss when using the 520

  • Screen and font size. The elemnt screen is huge compared to the garmin, and easier to glance at to get the information quickly
  • Button location. The buttons on the garmin are awkward, and located oddly
  • Maps. Maps are a hell of alot easier and clearer on the elemnt.

That’s just what comes from the top of my head. I’m sure there’s more.

Things I miss when using the Elemnt

  • Recovery advisor, Vo2 and auto FTP. A small and insignificant feature set, but one I like to have.
  • Varia light control. I’ve got a full set of Varia lights which obviously don’t work with the Elemnt. Yet. With See.Sense working on their Ace light set, it might get supported.
  • Beeps and other bongs. The Elemnt is mute when compared to the 520, with a much smaller speaker.
  • Not having to correct speed spikes after autopause. Seriously wahoo, that’s annoying

Again, just off the top of my head.

But weighing up the pros and cons of each unit, it’s clear to me that the elemnt is the first computer I reach for when getting ready.

Icon+

As you know, I recently picked up a pair of See.Sense Icon+ lights, and have now ridden a couple of rides with them. Safe to say I love these lights.

They increase my visibility on the road, and give me a sense of safety. Seeing the front light I’ve sort of worked out the responses they have;

  • Senses decrease in speed
  • Senses drop in ambient light
  • Senses increase in ambient light
  • Senses tilt to react to hill climb
  • Senses lateral tilt for sharp cornering
  • Senses a sprint

And any combination of the above. They are ideal daytime running light, as they are bright enough to be seen from a fair distance.

Build wise, they are solid. No movement in the plastic face or back.

Mounting them onto the bike is easy with the supplied straps

, however I’ve noticed a tendency for them to move. While not a major issue, I find it annoying. I mount the rear on the saddle post, which unfortunately means no saddle bag will fit. And the front on the lower head tube. My one criticism would be the button on the units. They are a little tough to turn on. The cover over the button is significantly larger than the button, meaning you some times miss all together. Not a major gripe but it does get annoying.