Awesome
Tacatá
Tacatá is a lightweight Python script which creates Netkit and Kathará labs using an enriched version of the lab.conf
file with a simple syntax.
You can find some examples of lab.confu
configuration files in labs
folder.
!!! WARNING !!!
Keep in mind that Tacatá is only intended to be used during Intermediate Tests for the Infrastructures of Computer Networks course at the Roma Tre University. We're not trying to support all the Kathará features (like P4 programming or NFV approaches). However, you can still create all the files/folders manually in the generated lab.
How it works
- Create a
lab.confu
in the directory wheretacata.py
is stored. - Write all you need to reproduce the lab in the
lab.confu
file. - From a Terminal, launch
python tacata.py
. - The generated lab will be placed in a new
lab
folder - You can normally launch the lab from the
lab
folder without extra steps!
Currently Supported
- Terminals/Routers
- Web Servers (with autogenerated
index.html
file in/var/www/html
& Apache Mods support) - Load Balancer Templates (with ONLY support for nth and random modes)
- DNS and Named Hosts (currently, only master mode is supported) - Local NS (for hosts)
Syntax
All the configuration is based on function calls which affect the current device and/or the current interface unless otherwise specified. The current device and the current interface are those defined in the line in which the function is called. For example in the configuration line
pc[0]=A
the current device is pc
. while the current interface is eth0
.
Each line is composed of two parts separated by the special character $
. The first part of the line is a standard
netkit/Kathará device definition whereas the second part is a sequence of commands separated by ;
.
Interface Configuration
Setting ip addresses
To set the ip address of the current interface the ip
function is used. This function expects a single
parameter which is the ip address to set along with the length of the netmask.
For example, the following line assigns the ip address 1.0.0.2/24
to the eth0
interface of pc
.
pc[0]=A $ip(1.0.0.2/24);
Gateways
You can set the gateway towards a certain lan with the command to
. The command to
is always referred
to the output interface used to reach that lan.
For example, if all the packets towards the lan 1.2.0.0/24
should be forwarded to 1.1.0.2
through the interface
eth1
of r1
the following line should be used
r1[1]=B $ip(1.1.0.1/24); to(1.2.0.0/24, 1.1.0.2);
As it is possible to see to
expects two parameters. The first is the lan to reach, while the second is the gateway to use to reach that lan.
In order to set the default gateway for a certain interface, default
can be used in place of a lan ip.
pc[0]=A $ip(1.0.0.2/24); to(default, 1.0.0.1);
Device Configuration
Load Balancers
To use a specific device as a Load Balancer, the balancer
command is used. The function expects at least four parameters: the name of the device
that we want to use as Load Balancer, the balancing mode (nth
or random
), the interface used to receive packets, device names and interfaces of the "balanced" devices
(the ones "behind" the Load Balancer).
As an example:
/------eth0---WEB1
---eth1---LB
\------eth0---WEB2
The LB
device acts as Load Balancer for WEB1
and WEB2
devices. It is configured as follows:
LB[0]=C $ip(10.0.0.1/24);
LB[1]=B $ip(1.2.0.3/24); to(default, 1.2.0.1);
$balancer(LB, nth, eth1, WEB1|eth0, WEB2|eth0);
Keep in mind that the generated configuration is only a template and you must complete it replacing placeholdes inside iptables
commands inside .startup
file.
Web Servers
To configure a device as a Web Server, the webserver
command is used. It takes at least a parameter (the device name) and other optional parameters
which are the names of the apache2 mods to activate on startup.
Using the example from the previous section, we want to configure WEB1
as a webserver running apache2 with rewrite
mod activated.
WEB1[0]=C $ip(10.0.0.3/24); to(default, 10.0.0.1);
$webserver(WEB1, rewrite);
An autogenerated index.html
file is placed into /var/www/html
and contains the device name of the webserver.