This is a simple bash script that is run by crontab every 5 minutes on a linux box.
It e-mails me the new address when a change of IP address is detected.
The script (ipchangemail.sh)
#!/bin/bash
# Check if IP-address has changed. If a change has occured, mail me the new address
# Add the following line to crontab if you would like it to be run every 5 minutes:
# */5 * * * * ./ipchangemail.sh
# The network interface I want to monitor
NET_INTERFACE=eth0
# File to keep the latest IP address
IP_FILE=myip.txt
# Mail to this address when a change occur
MAILTO=mail@example.com
# Read the previous IP address from file
source $IP_FILE
CURRENT_IP=`/sbin/ifconfig $NET_INTERFACE | sed -n "/inet addr:.*255.255.25[0-5].[0-9]/{s/.*inet addr://; s/ .*//; p}"`
if [ "$CURRENT_IP" != "$OLD_IP" ]
then
# Send email about address change
`echo "New IP address detected: $CURRENT_IP" | mail -s "New IP address" $MAILTO`
# Write new address to file
`echo "OLD_IP=$CURRENT_IP" > $IP_FILE`
fi
The script can be downloaded here.
Tags: bash, ifconfig, mail, sed
Posted by Hans-Henry Jakobsen
This post describes how I upgraded my Ubuntu (Hardy Heron) 8.04 server installation to (Intrepid Ibex) 8.10 from the command line.
First you’ll need to make sure you are running the latest packages
# sudo aptitude update # sudo aptitude safe-upgrade
Then you will need to install the Ubuntu upgrade package
# sudo aptitude install update-manager-core
You can start the upgrade when the package is installed
# sudo do-release-upgrade
Then you just have to follow the on-screen instructions and answer the questions as they pop up. One thing to note is the fact that it is not suggested to perform the upgrade via a remote ssh connection. I have done earlier upgrades multiple times before without any problems, but I might just have been lucky.
Tags: 8.04, 8.10, Hardy Heron, Intrepid Ibex, Ubuntu, upgrade
Posted by Hans-Henry Jakobsen
First you remove this line from /etc/modprobe.conf if this line exists.
alias net-pf-10 ipv6
Add the following line to /etc/modprobe.conf
alias net-pf-10 off
Reboot the system. IPv6 is now disabled.
To re-enable IPv6, remove the alias net-pf-10 off line from /etc/modprobe.conf and reboot the machine.
I’ve also made a post about how to disable IPv6 on RHEL5.
Posted by Hans-Henry Jakobsen
Please note that you have to be the root user to use this command because it puts the network card in promiscuous mode.
# tcpdump -i eth0 -A -s 0 udp port 1514 and host 192.168.0.1
The example above command listens on port 1514 which is the port ossec-hids uses on its secure communication between server/agent.
Options
-i Listen on interface. -A Print each packet (minus its link level header) in ASCII. -s Snarf snaplen bytes of data from each packet rather than the default of 68 (with SunOS’s NIT, the minimum is actually 96). Setting snaplen to 0 means use the required length to catch whole packets. udp - listen to UDP traffic port - the port you want to listen to host your host IP address
Tags: tcpdump
Posted by Hans-Henry Jakobsen
This post describes how to disable IPv6 on a Redhat (RHEL5) installation. I haven’t had the time to test it on other version of Redhat.
Edit /etc/sysconfig/network and change
NETWORKING_IPV6=no
Edit /etc/modprobe.conf and add these lines
alias net-pf-10 off alias ipv6 off
Stop the ipv6tables service
# service ip6tables stop
Disable the ipv6tables service
# chkconfig ip6tables off
IPv6 will be disabled after the next reboot.
Edit
This also works on RHEL6/CentOS6
Tags: ip6tables, RedHat, rhel5, rhel6
Posted by Hans-Henry Jakobsen