Tag Archives: Open Source

Notify-send command

So the other day I was looking around and discovered the notify-send command. It basically sends notifications to the desktop. Pretty useful now adays.

[11:49:13] xavi@thinkpad: ~ $ sudo dpkg -S `which notify-send`
libnotify-bin: /usr/bin/notify-send
[11:49:15] xavi@thinkpad: ~ $

It is installed with libnotify-bin via aptitude.

[11:50:35] xavi@thinkpad: ~ $ sudo aptitude install libnotify-bin

So, once installed lets create a practical script. On my job I need to have a permanente VPN connection. Once in a while the VPN connection drops and we have to connect again. Lets create a simple script that notifies us when the connection drops.

#!/bin/bash

# Check tunnel interface
while "true"; do
        /sbin/ifconfig tun0 &> /dev/null
        while [ $? -ne 0 ]; do
                notify-send -t 5000 "VPN" "VPN is down"
        done
        sleep 300
done

We save and copy the script, give it execution permissions with chmod and send it to background.

[11:55:47] xavi@thinkpad: ~ $ chmod +x /tmp/check-vpn.sh; /tmp/check-vpn.sh &
[1] 15613
[12:00:43] xavi@thinkpad: ~ $

Here is a screenshot of it working.

vpn notify-send

Enjoy.

Connecting GNS3 simulator to the Internet

I know it’s been a while. No, I haven’t been lost, in Guantanamo or similar. I was just too lazy/busy to write a post. But luckily I’m back. 🙂

Today I’m going to write about how to connect GNS3 lab to the internet. For this we are going to have to create a tap interface on our Debian box. First thing would be to install the uml-utilities on your Debian box.

[10:52:55] xavi@lstkco14073: ~ $ sudo aptitude search uml-utilities
i uml-utilities            – User-mode Linux (utility programs)
[10:53:00] xavi@lstkco14073: ~ $

Now install with:

[10:53:00] xavi@lstkco14073: ~ $ sudo aptitude install uml-utilities

Once uml-utilities is installed you can execute the following script to bring up a tap interface.

#!/bin/bash
sudo tunctl -t tap0 -u `whoami`
sudo ifconfig tap0 192.168.1.1 netmask 255.255.255.252 up
/sbin/ifconfig tap0

[11:02:06] xavi@lstkco14073: ~ $ sh tap0
Set ‘tap0’ persistent and owned by uid 1000
tap0 Link encap:Ethernet HWaddr 5e:3c:9d:d8:ff:9a
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.252
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

[11:02:17] xavi@lstkco14073: ~ $

We would need to connect this tap interface to the GNS3 simulation. We also would need to configure iptables to allow routing on the Debian box. For that we need to execute the following script.

#!/bin/bash
# Script to enable IP packet forwarding and NAT
#
# eth0 is Internet connected interface

# Enable IP Forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# Clean up iptables
iptables -F
iptables -t nat -F
iptables -X

# Enable IP MASQUERADING/NAT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# Set firewall policies
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# Allow all connections not from wlan0
iptables -A INPUT ! -i eth0 -j ACCEPT

# Allow all ICMP connections
iptables -A INPUT -p ICMP -j ACCEPT

# Allow all already established connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

In our next post we would configure the GNS3 simulator. Comments are always welcome.

Squeeze is now stable

So squeeze is now stable. Together with the new Debian stable release the guys also updated the website.

I have created a small bash script to perform the upgrade. Here it is.

#!/bin/bash
echo "Moving to /etc/apt"
cd /etc/apt
echo "Backing up sources.list"
cp sources.list sources.list.`date +%F`
echo "Changing the sources for squeeze"
sed 's/lenny/squeeze/g' sources.list > squeeze.sources.list
echo "Copying squeeze to sources.list"
cp squeeze.sources.list sources.list
echo "Performing the upgrade."
apt-get update
apt-get dist-upgrade

Run the script as root or use sudo when executing.

Resulting file should be something like the following.

## main & security repositories
deb http://ftp.us.debian.org/debian/ squeeze main
deb-src http://ftp.us.debian.org/debian/ squeeze main
deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main

References:

  1. Go2Linux
  2. Linode