Skip to content

iPad does IPv6

23-Oct-11

Upon connecting to the wireless network in the hotel I was staying in over the weekend, I decided to do a packet capture just to see what was going on. (Similar to reading log files, it’s worthwhile to be able to recognize the kind of entries/packets you expect to see and those that might be suspicious.)

This turned out to be a learning experience: my iPad (named ‘kepler’) has IPv6 functionality; I definitely did not know that until I saw UDP packets like this:

I subsequently found some documentation online confirming this.

Minimalist Squid configuration

14-Jul-11

Squid is one of the first open-source programs I got into. I have spent a lot of time looking at squid.conf The default squid.conf (reference copy in /usr/share/doc/squid/examples/squid.conf) is about 5000 lines by default. It’s great that everything is well-documented but who wants to deal with a massive config file like that? Not me. This was generated with Squid 2.7STABLE9:


acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 873 # rsync
acl purge method PURGE
acl CONNECT method CONNECT
http_access deny manager
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
icp_access allow localnet
icp_access deny all
http_port 3128
hierarchy_stoplist cgi-bin ?
access_log /var/log/squid/access.log squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
refresh_pattern . 0 20% 4320
acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9]
upgrade_http0.9 deny shoutcast
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
extension_methods REPORT MERGE MKACTIVITY CHECKOUT
hosts_file /etc/hosts
coredump_dir /var/spool/squid
useragent_log /var/log/squid/useragent.log
cache_mgr squid@yummypi.com

That is basically the default squid.conf with the comments removed. I removed some of the safe_ports. (Who uses Gopher anymore?) I added in two options that I like to use. The last one is useful in a corporate environment where you want feedback from users (which you can promptly redirect to /dev/null).

I have placed this file at unixsysadmin.org/squid.small.conf and a copy of the default file at unixsysadmin.org/squid.conf if you’d like to wget it or whatever.

apt-get via cron

08-Mar-11

IRL I’ve had a few people ask me about updating Ubuntu installations via cron. If you add something like 05 0 * * * /usr/bin/apt-get -y update ; /usr/bin/apt-get -y upgrade to root’s crontab, you’ll get errors like this:

dpkg: warning: 'ldconfig' not found in PATH or not executable.
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable.
dpkg: warning: 'update-rc.d' not found in PATH or not executable.
dpkg: 3 expected program(s) not found in PATH or not executable.
NB: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
E: Sub-process /usr/bin/dpkg returned an error code (2)

Those errors should not surprise those who have troubleshooted cron jobs before. Cron 101 teaches us to use always use the full path. If you want to apt-get update via cron, add the following to root’s crontab:

05 0 * * * PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/aleida ; /usr/bin/apt-get -y update ; /usr/bin/apt-get -y upgrade

(You can use output redirection to prevent receiving mail about it but if you’re going to auto-pilot your updates, I recommend having them at least sent to you. You can add a line like MAILTO=cron@example.com to your crontab and direct that email somewhere less noisy than your primary address.)

Don’t run screen if…

06-Mar-11

This should go without saying but make sure you are not running screen if you want your .screenrc customizations to take effect. I was trying to redo my .screenrc and none of my changes were taking effect and I was extremely frustrated.  The .screenrc I was using is from my FreeBSD systems but I was working on an Ubuntu one and I thought there was some difference in how things were specified cross-platform. Not the case.

Exiting screen and then running it again initialized all of my changes. This is the kind of dumb, annoying, obvious stuff that halts progress. It’s so stupid. Ugh. If this can help one person not go through what I just went through, I’ll be a little happier.

Better Ruby gem search for newbies

26-Jan-11

When you’re just starting out with Ruby, the output of ‘gem list’ may be the null set, rendering ‘gem search’ basically useless. To learn what gems can be installed, one tends to look outside of the gem command. However, there’s a switch that makes this easier:

gem search prime --both

AdBlock Plus Statistics

24-Jan-11

Use this one-liner of which I am rather proud to gather how many hits AdBlock Plus has recorded:

find ~/.mozilla/firefox/*/adblockplus -name patterns.ini -exec cat {} \; | grep hitCount | cut -d"=" -f2 | awk '{s+=$0} END {print s}'

Tested with FreeBSD and Ubuntu.

Use of the w command

19-Jan-11

Primarily a FreeBSD user, I am used to seeing the output of w like this:

(Excellent uptime on the above…FreeBSD FTW. :-P .

However, in Ubuntu (10.04 anyway), it looks like this:

I’d prefer to see what commands others are using. Who would have thought that a single letter command had useful switches?:

Nothing interesting is going on at the moment but I still prefer to know. :) .

Self-hosted twitpic alternative

02-Jan-11

There are several write-ups on creating a self-hosted Twitpic alternative. Most are ridiculously convoluted and not worth the time.

Jeremy Kessel (a Twitter employee) has a great write-up here that is worth the read and the time to set everything up. It does not require much technical expertise and most people can do it within 20 minutes or so.

I’ve set my one up at briepix.com.

Now that everything’s set up, I use the WordPress app for Android to tweet instead of the Twitter app. Or the WordPress web interface or the WordPress app for iPad. It’s pretty smooth.

A few things to note:

  • Jeremy’s article does not cover this but you do need to go to Settings -> Writing and enable XML-RPC.
  • You also need to have curl enabled in your PHP install or it will fail in a not nice way.
  • Finally, I recommend setting ‘Set this on by default’ to Yes in order to have your pix automatically tweeted when the post is published.

That’s basically it. Enjoy!

Never type your MySQL password again

26-Dec-10

Some of my personal machines are running local, test versions of MySQL, mostly so that I can play around without breaking anything production. Access to these boxes is limited. (some are not even on the Internet) and I hate having to type my password over and over again. The solution to this is to create a ~/.my.cnf file containing the database password for that user.

MySQL completely documents this option here.

Rather than read through all of that, just create a file in your home directory called .my.cnf. The contents of that file should be:

[client]
password=Your-password-goes-here

It’s that simple. Now you can do things like mysqladmin ping via cron or mysqladmin pr from the console without having to bother with a password.

Snipe Bad IPs (and good ones)

21-Nov-10

Like most people in this business, I am lazy…and that’s a good thing. I use infosniper.net (among other tools) to gather more information about different IP addresses. You can access the infosniper.net page for a URL directly by typing: http://infosniper.net/index.php?ip_address=69.163.239.213. It’s my opinion that that is *way* too much to type. So with the following in my .htaccess, I set up an easier way to do this with my four letter domain name:

Redirect / http://infosniper.net/index.php?ip_address=

So, you can just type something like qxhp.com/69.163.239.213. That’s more like it!