Wednesday, April 04, 2007

301 redirect

I've incorporated work-related posts in Coredump. Read the rest of the gory details there.

Monday, January 16, 2006

Ubuntu LTSP reinstall

Fragged my Ubuntu LTSP install. I thought doing a

sudo apt-get remove openoffice.org;sudo apt-get install openoffice.org2

would upgrade OpenOffice.org. Well, it did, but it also removed xserver-xorg. Ack!

Dumb me.

So I tried Breezy and MueCow. No dice. The tftpd-hpa service won't start. So back to Hoary, I did.

X on the clients won't start. The XSERVER = auto directive in lts.conf didn't work for some reason. Turns out XDCMP wasn't allowing requests. I just had to remove the hash in /etc/X11/xmd/Xaccess:

#*        #any host can get a login window

Slap my forehead! Ten times. :P

Wednesday, January 04, 2006

Using hashlimit to foil SSH bruteforce attempts

Add this to the iptables ruleset:

iptables -I INPUT -m hashlimit -m tcp -p tcp --dport 22 --hashlimit 1/min --hashlimit-mode srcip --hashlimit-name ssh -m state --state NEW -j ACCEPT

The rule limits one connection to the SSH port from one IP address per minute.

For more information, man iptables and iptables -m hashlimit --help.

Monday, January 02, 2006

Miscellaneous Siemens TC35i AT commands

  • AT^SCKS? - SIM connection
  • AT+CSMS=1 - Message service
  • AT+COPS? - Operator selection
  • AT+CREG? - Network registration
  • AT+CSQ - Signal strength
  • AT&V - Status
  • AT+CNMI=1,2,0,1,1 - Modem init string

Thursday, December 22, 2005

CLI shortcuts, 5

To get error code of last executed command:

echo $?

Simple script to switch IPs

#!/bin/bash
# Switch IP script, v.1 - iandexter@philrice.gov.ph

CONFIG_DIR=/etc/sysconfig/network-scripts
ROOT_UID=0
ERRROR_XCD=66
ERROR_NOTROOT=67

# Run as root
if [ "$UID" -ne "$ROOT_UID" ]
then
   echo "Must be root to run this script."
   exit $ERROR_NOTROOT
fi

cd $CONFIG_DIR || {
   echo "Cannot change to config dir."
   exit $ERROR_XCD
}

if [ -z "$1" ]
then
   echo "Usage: `basename $0` [afrdis|preginet]"
   exit 1
else
   if grep -q $1 ifcfg-eth0
   then
      echo "Already linked. Not switching anymore."
      exit 0
   else
      echo "Switching to $1 link..."
      cp ifcfg-eth0.$1 ifcfg-eth0
      ifdown eth0
      ifup eth0
      ifconfig eth0
      exit 0
   fi
fi