Ubuntu Idyll Cisco Study Environment

I have written a few posts in which I mentioned the amazing GNS3/Dynamips/Dynagen set of tools that enable you emulate a Cisco network …. also a great too used to prepare for the Cisco CCIE lab exam [Professor of Internetworking]

Here are a couple of things I have used that make creating and using labs a nirvana experience in Ubuntu … [constant flow for those who understand Emotional Intelligence]

  1. Because I hate having multiple console windows open, one for each router which is the default behaviour of GNS3, I wrote the script [tamonet.sh] in the previous post that essentially takes as an arguement your topology (.net) file and then opens each router console in a separate tab in gnome-terminal.
  2. I modified my gnome-terminal profile so that my background is translucent. That way, I can have a document (e.g a workbook) I refer to in the background and read instructions or make references without having to switch windows.
  3. Initially, to launch my lab with my tamonet.sh script, I would open up either a terminal or the RUN application box [Alt-F2] and issue the command …. that is until I discovered awn-terminal. Boy! …. first of all, AWN is a cool dock application for Ubuntu and one of its applets is a nifty cool terminal that you just click and it pops up a next-gen-like translucent terminal. You just type in your command and as soon as u move focus from it, it automatically closes … no clutter on your desktop!!
  4. And finally … when I am doing such work, I play music. Mozart is ideal for me but I generally prefer any kind of music without vocals. It is the vocals I find distracting. So for me, to complete the ensemble, it is Mozart, Beethoven, Tchaikovsky or soundtrack music [Prison Break, Stargate etc]

Given what I mostly do these days [putting in my 10000 hours to master my craft as a network engineer] and my passion for Ubuntu … I enjoy every single moment I spend building and executing scenarios and everyday, I say thank you to the guys who selflessly make all this possible …and it reminds me to keep sharing what little I know. Happy Valentines day guys and babes … do spend vals with someone real … far away from your laptop ok?

Open GNS3 Router Consoles in Multiple Tabs in a Single Window [GNOME]

As a follow up to my previous post of the above topic, I finally put together a script. I have two scripts, one specifically written for the Internetworkexpert Dynamips topology. The second one can will log into any topology – it takes the name of the .net file as an argument for example:

$./tamonet.sh BGPlab.net

Just copy this code, put them in a file with the .sh extension and  make then run them from a command line AFTER you have started your routers in GNS3.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
 
# The purpose of this scrip is to launch all running Dynamips router consoles in such a way that all consoles exist
# as tabs in a single terminal windows, rather than the
#default behavior to open multiple windows that just clutters the desktop.
#Script written by Mukom Akong TAMON [mukom to tamon at gmail dot com] .....
#Use and distribute freely .... just give me credit for creating it ok? ... <span class="wp-smiley emoji emoji-wink" title=";-)">;-)</span>
#Save this with an sh extension, make it executable and then you can run either from
#inside an existing terminal or you press ALT+F2 and then run it. You must pass it the name of the .net file of your current lab
#e.g ./tamonet.sh BGP-Lab01.net
#It is best if you copy the script so it is in the same directory as the directory in which the .net file is.
#Obviously, this script only works for Linux distributions that are using GNOME eg Ubuntu.
 
 
PORTS=/Users/mukom/tmp/ports
NAMES=/Users/mukom/tmp/devicenames
TELNETCMDS=/Users/mukom/tmp/telnetcmds
TELNETTABNAME1=/Users/mukom/tmp/telnettabname1  #Initial set of command arguments for gnome terminal
TELNETTABNAME2=/Users/mukom/tmp/telnettabname2  #Strip away the tab from the commands -- just in case
TELNETTABNAME=/Users/mukom/tmp/telnettabname        #the commands sorted so we have things sequentially
LASTCMD=/Users/mukom/tmp/lastcmd.sh
 
#First delete the files if they exit
rm -f  $PORTS
rm -f  $NAMES
rm -f $TELNETTABNAME
rm -f $TELNETCMDS
rm -f $TELNETTABNAME1
rm -f $TELNETTABNAME2
rm -f $LASTCMD
 
#Xtract the ports from .net file and put them into ports file in /tmp
grep -E console  $1 | sed s/console\ =\ // | tr -d [] | tr -s '[:blank:]' >> $PORTS
 
#Create corresponding file that containts the names
#grep -E ROUTER  $1 | sed s/ROUTER\ // | tr -d [] | tr -s '[:blank:]' >> $NAMES
grep -E '\[\[ROUTER'  $1 | sed s/ROUTER\ // | tr -d [] | tr -s '[:blank:]' >> $NAMES
 
#This block constructs the telnet commands for each router and writes them to $TELNETTABNAME
#inst=0
for i in $( cat $PORTS ); do
#   let inst=inst+1
    #echo >> $TELNETCMDS "telnet localhost $i -t"
#   echo >> $TELNETCMDS "\"telnet localhost $i\" -t"
    echo >> $TELNETCMDS "\"telnet localhost" "$i\"" ' -t'
      
done
 
#Combine the telnet command with the device name on same line
paste $TELNETCMDS $NAMES>>$TELNETTABNAME1
 
#replace all tabs with a single space.
expand -t 1 $TELNETTABNAME1>>$TELNETTABNAME2
#cat $TELNETTABNAME #| tr '\t' '" -t "'
 
#Now sort the file
sort $TELNETTABNAME2>>$TELNETTABNAME
 
#how many lines [routers] in the file?
routers=`wc -l $TELNETTABNAME`  #count lines in the file and set result as variable routers.
routers=${routers%$TELNETTABNAME}  #Make the routers variable an integer?
echo "There are $routers Routers in this topology"
let "routers = $routers+1"
#declare -i routers    #This seems not to serve any useful purpose that I know of
# echo "I now start with a router count of $routers"
 
#This block reads in the commands from a file and assign each line to a dimensioned variable R[x]
{
    counter=0
    while [ "$counter" -lt "$routers" ]
    do
        read R[$counter]
        let "counter=$counter+1"
    done
}  < $TELNETTABNAME
 
#This block just prints out the contents of the dimension - I want to be sure I read the right things into the variables
counter=0
while [ "$counter" -lt "$routers" ]
do
    echo ${R[$counter]}
    let "counter=$counter+1"
done
 
#Build the gnome-terminal command and options from the contents of the R[x] dimension
counter=0
let "routers=$routers-2"  #One main window and then the -2 so we cover just the right number of tabbed auxilliary windows
command="gnome-terminal --window --maximize -e ${R[$counter]}"
while [ "$counter" -lt "$routers" ]
    do
        let "counter=$counter+1"
        command="$command --tab -e ${R[$counter]}"
        #echo $command
    done
echo >>$LASTCMD $command
chmod 777 $LASTCMD
#I can delete these files now, since I no longer need them --- just house cleaning
rm -f  $PORTS
rm -f  $NAMES
rm -f $TELNETTABNAME
rm -f $TELNETCMDS
rm -f $TELNETTABNAME1
rm -f $TELNETTABNAME2
$LASTCMD

I appreciate any modifications …. and this works for me … so I don’t have to get KDEbase libararies just for konsole4KDE. I hope u enjoy it.

Making GNS3 Routers Open in Tabs in Ubuntu

If you use GNS3 network emulator with a significant number or routers, each usually opens up in its own terminal window which just makes your workspace a mess.

While I know I can install konsole-for-KDE4 in Ubuntu to sort out the clutter, I don´t like to have to download more than 30MB extra software [KDE base libraries and other dependencies] so I opt to create this scrip which I can easily edit.

Just download the script, make it executable and after running the your lab from GNS3, rather than use the toolbar button to log into to all consoles, instead press ALT+F2 and type in the path to the script [do remember to make it executable] and voila!!!

On Vista, I use Teraterm for my console and so the above problem does not exist. If you use the default Vista command prompt you will run into the same problem. I read a nice GNS3 tutorial that suggested a free Windows utililty called Wintabber to tame those multiple windows.

If your Linux distribution uses KDE, install konsole-for-KDE4 and use it as your terminal program in GNS3 to get the same results.

I am working on some scripts to automate the process for Ubuntu and gnome-terminal — I don’t want to install all the KDE base packages just to get konsole-for-KDE … will post the scripts [bash] when I am done.

Saving Router Configurations Across GNS3 Sessions

For those who use GNS3 to emulate Cisco networks, sooner you get to a point where you would love to save the configuration and pick off from where you left. Uptill recently, I used the crude method of exporting my configuration files and then manually setting them as the startup config for each router. I however found a better way of recent … just save your lab as a GNS3 Project. Here is the procedure:
1. Lay out your lab: U know, place devices, connect them, configure switches and even default router configs (if you have a default config you typically use eg aliases, idlepcs and logging synchronous)
2. Run your lab (click Start/Resume all IOS)
3. Telnet into each of the routers and configure it to your heart´s desire. Make sure you do a copy run start or a write terminal after you finish configuring each router.
4. With your lab still running, switch back to the GNS3 window and click File->New Project. Type in a name for the project and be sure to check the ¨Export router configuration files¨ option.

5.
Click Ok and GNS3 will ask whether you want to apply the project settings to which you say yes.
6. GNS3 will extract the config from your routers and save them for you and automatically set them as startup config for the next time.
If you look in the directory where you saved the project, you will find that GNS3 creates the following:

  • A project file eg lab.net
  • A directory to store config files with the same name as the .net file of your project eg lab01_configs. In it you will find files with the name of your routers and the .cfg extension eg (R1.cfg, R2.cfg etc)
  • If you selected the option in the New Project dialog box, a working directory folder is also created eg lab01_working.

Next time, you can just open your lab, launch right in and start having fun.

Dumping Ntop Data

One of the most common questions people as is how to dump ntop data into a database. Well there are scripts to do that for a MySQL database on sourceforge.net.

However, within ntop, just click Utils|Data Dump to show the following dialog box:

You can dump data about different objects into different formats – see the ntop guide for the formats. Some of these formats are importable into a spreedsheet and from there you can unleash the full power of Open Office Calc or Excel unto your traffic data.

Displaying a Host’s Active TCP/UDP Sessions

Ok, suppose your sleuthing aroung with ntop finally identifies a particular host as the major consumer of bandwidth, what if you want to find out just what exactly s/he is doing online that is consuming so much bandwidth? Here is how ntop can help:

1. Identify the host you are interested in [one way is to sort on the Data for Network Traffic stats for local hosts.

2. Click on that host to bring up the Info about xxxxx page where xxxx is the name or IP address of the host you are interested in.

3. Scroll down to the bottom of the page to the Active TCP/UDP Sessions table. A screenshot is shown which "lays it all out for you". It almost something like you'd get running netstat on the host albeit cuter?

 

Active TCP/UDP Sessions for a Host

Active TCP/UDP Sessions for a Host

NTOP Bandwidth Monitoring on Ubuntu 8.04

I have been working on deploying the latest version of the popular ntop bandwidth monitoring application. Here is a guide I wrote to get other started. I will make updates whenever I learn new things on this blog. You will also be able to download the latest copy of the guide from here.

ntop Guide 1.1

I think ntop is a brilliant tool for seeing what is happening on your network in realtime. It is Open Source, Free [as in both free speech and free beer] and in active development. Check back on this page not ony for latest copy of documentation but also for some screenshots and use cases for ntop as well as other cool stuff I come across.