Tag Archives: GNU

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.

Firefox 4 is out

So Firefox 4 is out. They have this nice site where you can watch live the downloads per minute. I also look at this site as a way of measuring the World developed regions. Look at how there is a lot of activity going on in California, North East USA, Japan and Northern Europe. There is almost no activity coming from Africa and most of Asia asides from some heavily populated cities. I guess it’s a different way to see the World development as a whole.

I like the new Firefox. It is better organized. I think space is better organized leaving more screen for the website you are watching.

Thanks to Denis for the URL.

Project Euler

So I was looking around for some programming information and found Project Euler. They have a number of problems to program. You can choose any programming language, it’s just to enhance your programming abilities.

So here is the answer to problem number one.

#!/usr/bin/perl

use warnings;
use strict;

my $sum;
my $count;

for ($count = 0; $count < 1000; $count ++) {
        if (($count % 3 == 0) || ($count % 5 == 0)) {
                $sum = $count + $sum;
                print "\$sum is $sum\n"; }
        }

It’s a really simple exercise. You just need to sum of all the multiples of 3 or 5 below 1000.

Savings script

So I was thinking about writing a script to calculate the savings over a certain matter of time and came up with the following.

#!/usr/bin/perl

use warnings;
use strict;

print "What is the yield?\n";
my $yield = <>;
print "How many years?\n";
my $years = <>;
print "How much money saved anually?\n";
my $savings = <>;
my $i;
my $new_savings = 0;

for($i = 1; $i <= $years; $i++) {
	$new_savings = $savings + $new_savings;
	$new_savings = $new_savings + $new_savings*($yield/100);
	printf "Savings for year $i are \$%.2f.\n", $new_savings;
}

Below is an usage example.

[19:43:04] xavi@ubuntu:/tmp $ ./yield.pl
What is the yield?
5.0
How many years?
5
How much money saved anually?
10000
Savings for year 1 are $10500.00.
Savings for year 2 are $21525.00.
Savings for year 3 are $33101.25.
Savings for year 4 are $45256.31.
Savings for year 5 are $58019.13.
[19:43:18] xavi@ubuntu:/tmp $

This just gives an idea of the money that can be saved over a short period of time with a five percent yield. It’s a really simple script.