Count SYNs

A while back I was deploying a new high volume TCP application and I was interested in the number of connections from particular hosts I was seeing over a period of time. Who was connecting the most, that kind of thing. This one liner accomplishes that rather well. Replace 70.164.19.160 with your servers IP address and should get a list of top connecting hosts and the number of times each host as connected in ascending order. Alter -c 100 to specify the number of packets to capture. Basically what this does is capture the fist 100 SYN sent to the destination host, extract the send IP, sorts them and then counts the number of SYN packets from each host. Simple but effective. I love one liners like this.

1
time tcpdump -ieth0 -c 100 -nn dst 70.164.19.160 and 'tcp[13] & 2 == 2' | awk 'split($3,ip,".") {print ip[1] "." ip[2] "." ip[3] "." ip[4]}'| sort | uniq -c | sort -n

Imdb Url Grabber

Here’s a quick and dirty shell script that will attempt get the correct IMDB link based on a files name. I use this to copy media into the appropriate places on my media server along with an NFO file that xbmc can use to download the appropriate movie info. This technique can be used to fetch links from google for a lot of different things from the command line. Be careful though, if you use this too many times (1000s?) in a short amount of time google will ban you for a while. I think the correct thing to do is use their API. I did say quick and dirty though :) Adjust path’s, etc. accordingly and try your luck.

1
2
3
4
5
#!/bin/bash

SEARCHSTRING=`echo $1|cut -d. -f1|sed 's/ /_/g'|sed 's/-/_/g'|sed 's/_/+/g'`
IMDBURL=`curl -iIs -A "Mozilla/5.0" "http://www.google.com/search?&q=site+www.imdb.com+$SEARCHSTRING&btnI" | grep Location | awk {'print $2'}`
echo $IMDBURL

Dynamic IP Checker / DNS / V6 Tunnel Updater

Here’s a script I wrote that will check the IP address of my FIOS connected firewall, update DNS and IPv6 tunnel settings and send me an email. This script assumes you have control of a DNS server somewhere that has resource records related to your firewall host. I use he.net’s tunnelbroker for my IPv6 tunnel and this script uses their facility to update the tunnel end point configuration and then restarts the tunnel on my side. Details and script are below.

Xbox 360 Open Nat

A friend asked me about this the other day and I told him to google it. Unfortunately I was unaware that there is a lot of bad information out there about how to achieve an “open NAT” status on your xbox 360. The only ports you need to forward to your xbox are:

1
2
3
TCP port 88
TCP port 3074
UDP port 3074

Zoneminder With Megapixel Cameras

I’m continuing to post technical articles from the old blog. This is a zoneminder how-to I wrote for work a while back. The most interesting thing about this article is that I got zoneminder to work with cameras that previously did not work due to their proprietary nature. The particular cameras, the Megapixel MPix13D and MPix1339WIR only work with Internet Explorer which makes getting them to work with zoneminder difficult if not impossible.  I was able to get them working though. See the details below.

Macbook Fan Control in Linux

Update: Since Karmic came out I no longer need to run this….

Update: I have gone back to using this script because my laptop was getting too hot. I also tweaked it a bit for my new macbook pro 7,1.

Here’s a daemon written in python to monitor the temperature and control the fan speed in linux. It depends on the applesmc module available from: https://wiki.ubuntu.com/MactelSupportTeam/PPA.

Main Script: copy to /usr/local/sbin/mb-fancontrol (note that the .py is removed!) link: http://planetfoo.org/files/mb-fancontrol.py

Init Script: copy to /etc/init.d/mb-fancontrol  (note the .sh is removed!) and run ‘update-rc.d mb-fancontrol defaults’ link: http://planetfoo.org/files/mb-fancontrol.sh

MAME Cabinet

A friend gave me an old video game cabinet a while back and I set about making it into a MAME cabinet. The ultimate goal was to relive a favorite part of my youth through the wonders of modern emulation technology.

This article is not a complete how-to but I will continue to update it as I come up with additional details which may make it qualify as a comprehensive guide some day. I’m writing this because while doing research I found that a lot of the references available on the Internet were dated which made using modern versions of MAME difficult. Also, I wanted to use Linux, I don’t do Windows without good reason. There is information about Linux based MAME cabinets out there but I did not find any comprehensive sources. The good news is that Linux works very well with MAME and other emulators. In my opinion it is the ideal platform for building a MAME cabinet because it is lean, extremely customizable and you have the source code which can come in handy (and it did for this project in my case).