Friday, May 29, 2009

Iptraf with bonding support

Default iptraf build that comes with RedHat or CentOS does not support bondX interfaces, or vlan (ethX.Y) interfaces,
however there's a version on bugzilla.redhat.com that does support it.
More details:
https://bugzilla.redhat.com/show_bug.cgi?id=441081
Also, for you the lazy ones out there, quick install procedure (done on CentOS5 x86_64) :
#remove current iptraf version
root@host ~# yum remove iptraf
root@host ~# wget "https://bugzilla.redhat.com/attachment.cgi?id=304745" -O iptraf-3.0.0-6.el5.src.rpm
root@host ~# rpmbuild --rebuild iptraf-3.0.0-6.el5.src.rpm
root@host ~# rpm -Uvh /usr/src/redhat/RPMS/x86_64/iptraf-3.0.0-6.x86_64.rpm

Ready to go.
If there's no `rpmbuild` command, install rpm-build, and also you'll have to add some packages like `ncurses-devel`

Wednesday, April 1, 2009

Detecting Conficker with nmap

As the Conficker worm is vastly discussed and getting a lot of attention, latest nmap version can detect it, won't post here how, here's the direct link to the resource:

http://www.net-security.org/secworld.php?id=7252

Monday, March 16, 2009

Restoring the MBR on RHEL/CentOS servers

It happens that the MBR is getting bad (after os updates/power failures, etc)
We can restore it in a few minutes if we have a RHEL/CentOS install CD at hand, or if we have a PXE server nearby.

Boot the system from the install cd,
at the boot prompt choose:
text rescue

After booting the rescue system, perform the following commands (actually only the chroot and grub-install may be needed, but sometimes the rescue system does not see all devices under the mounted system tree):
chroot /mnt/sysimage
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /dev
mkdir dev/pts
mount -t devpts devpts /dev/pts
/sbin/udevstart
/sbin/grub-install hd0
quit
quit

The system will reboot, and hopefully all will work right away.
If it doesn't - you will need to dig further :)
P.S - Don't sue me if these commands do some nasty things to your server ;)

Wednesday, March 4, 2009

Quick shell script to convert ifcfg-ethX-rangeY to ifcfg-ethX:Y format

Quick shell script to convert ifcfg-ethX-rangeY to ifcfg-ethX:Y format:
for i in `ls ifcfg-eth1-range*`; 
do
. ./$i
D1=`echo $IPADDR_START|cut -d. -f4`;
D2=`echo $IPADDR_END|cut -d. -f4`;
D=`expr $D2 - $D1`;
echo $D;
S=`echo $IPADDR_START|cut -d. -f1,2,3`;
for j in `seq 0 $D`;
do
echo "DEVICE=eth1:`expr $j + $CLONENUM_START`
BOOTPROTO=static
ONBOOT=yes
IPADDR=$S.`expr $D1 + $j`
NETMASK=$NETMASK" > ifcfg-eth1:`expr $j + $CLONENUM_START`;
done
done

Thursday, January 29, 2009

Freebsd php-fpm fastcgi server init script


#!/bin/sh

# PROVIDE: phpfpm
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable php-fpm:
#
#phpfpm_enable="YES"
#
#

. /etc/rc.subr

name=phpfpm
rcvar=`set_rcvar`

command="/usr/local/sbin/php-fpm"
command_args=""
pidfile=/usr/local/logs/php-fpm.pid
required_files=/usr/local/etc/php-fpm.conf

# set defaults

phpfpm_enable=${phpfpm_enable:-"NO"}

start_cmd="phpfpm_start"
stop_cmd="phpfpm_stop"
restart_cmd="phpfpm_restart"

phpfpm_start()
{
if [ -f ${pidfile} ]
then
echo "php-fpm already running!"
exit 1;
fi
echo "Starting php-fpm server..."
/usr/local/bin/php-cgi --fpm
}
phpfpm_stop()
{
if [ ! -f ${pidfile} ]
then
echo "${name} is not running or pidfile not found!";
exit 1;
fi
echo "stopping ${name}..."
kill -SIGQUIT `cat ${pidfile}`
}
phpfpm_restart()
{
if [ ! -f ${pidfile} ]
then
echo "${name} is not running or pidfile not found!";
exit 1;
fi
echo "sending SIGUSR2 to php-fpm master"
kill -SIGUSR2 `cat ${pidfile}`
}

load_rc_config ${name}
run_rc_command "$1"

Wednesday, January 21, 2009

How to check SpamAssassin version

Quick one-liner for checking spamassassin version:
[root@server ~]# perl -MMail::SpamAssassin -e 'print $Mail::SpamAssassin::VERSION;'
3.002004

Tuesday, January 13, 2009

OpenSUSE developers announced csync

Andreas Schneider has unleashed the first public release candidate of csync 0.42, which is now available as source from the csync Web site, or via one-click for openSUSE 11.0 and 11.1.

Project homepage: http://www.csync.org/

This tool looks like a promising alternative to unison, which was written in ocaml, while csync is written in C

Did not have time to test it yet, but as soon as it proves that is working ok - i plan to replace unison with it.