To create a virtual network in FITS Testbed, you need to follow the next steps:
For example, guanabara is a FITS node.
ssh root@guanabra
Creating a new test network (guanabra). Using 3 clients, one router and one server as an example (each client is connected, exclusively, to the router and so is the server):
1. Create a new directory to store the VMs images:
mkdir /net/10.2.2.1/home/xen/domains/client1 mkdir /net/10.2.2.1/home/xen/domains/client2 mkdir /net/10.2.2.1/home/xen/domains/client3 mkdir /net/10.2.2.1/home/xen/domains/router mkdir /net/10.2.2.1/home/xen/domains/server
2. Copy the images that already exist to the created directories.
PS: The images are in the directory /net/10.2.2.1/home/xen/images
When inside the images directory:
cp * ../domains/client1 cp * ../domains/client2 cp * ../domains/client3 cp * ../domains/router cp * ../domains/server
3. Create the VMs configuration files (.cfg) in the directory /net/10.2.2.1/home/xen/cfgvms
You can find more about configuration files in : Named Data Networking
PS: You can use a configuration file that already exists but you MUST CHANGE:
*Change the images directory *Change the name of the new machine *Change the MAC address of the new machine but be careful not to use an existing one *Change the file name ( ex : client1.cfg, client2.cfg, client3.cfg, router.cfg, server.cfg)
You ought to estabilish a number to each bridge that will be made:
Bridge between client1 and router : "1001" Bridge between client2 and router : "1002" Bridge between client3 and router : "1003"
Inside the cfg file, there will be a topic called networking. An example is shown for client 1:
vif = [ 'mac=00:16:3E:01:91:A2,bridge=OVS0|191', #defines the eth0, that will be used in the future 'mac=00:16:3E:01:90:13,bridge=OVS0|1001'] #defines the eth1, that will be the connection with client1
In this case, the MAC addres defined for this machine is 00:16:3E:01:90:13 and the bridge 1001.
The first MAC addres refers to the control network that has bridges with all others VMs. ( For now, we won't use it, but it will be explained later).
For the router configuration, the connections it establishes with each machine must be configured separately:
vif = [ 'mac=00:16:3E:01:91:A1,bridge=OVS0|191', # defines the connection with the network controller 'mac=00:16:3E:20:12:13,bridge=OVS0|1001', # defines the connection with client1 'mac=00:16:3E:20:12:14,bridge=OVS0|1002', # the connection with client2 'mac=00:16:3E:20:12:15,bridge=OVS0|1003', # the connection with client3 'mac=00:16:3E:20:12:16,bridge=OVS0|2000'] # the connection with server
4. After the cfg files have been edited for each machine, you can create them
xm create /net/10.2.2.1/home/xen/cfgvms/name
In our case:
xm create /net/10.2.2.1/home/xen/cfgvms/client1.cfg xm create /net/10.2.2.1/home/xen/cfgvms/client2.cfg xm create /net/10.2.2.1/home/xen/cfgvms/client3.cfg xm create /net/10.2.2.1/home/xen/cfgvms/server.cfg xm create /net/10.2.2.1/home/xen/cfgvms/router.cfg
It's done, the VMs are created!
Creation of Virtual Network with static route
1. On each machine configure the file /etc/network/interfaces as follows:
PS: Do not copy the comments to the file
For client1:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static #define the settings for eth0 (interface connected to the control network)
address 10.0.0.222
netmask 255.255.255.0
gateway 10.0.0.1
auto eth1
iface eth1 inet static #define the settings for eth1 (interface connected to the network between the router and the client1)
address 192.168.101.2 #interface ip
netmask 255.255.255.0 #network mask
gateway 192.168.101.1 #default gateway of the network (ip router for that network)
The same goes for other customers, just swapping 101 for 102 (client2) and 103 (client3). The last three digits of the address of eth0 should also be different.
For the router:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static #define the settings for eth0 (interface connected to the control network)
address 10.0.0.225
netmask 255.255.255.0
gateway 10.0.0.1
#client1
auto eth1
iface eth1 inet static #define the settings for eth1 (interface connected to the network between the router and the client1)
address 192.168.101.1 #interface ip
netmask 255.255.255.0 #interface mask
#client2
auto eth2
iface eth2 inet static #define the settings for eth2 (interface connected to the network between the router and client2)
address 192.168.102.1 #interface ip
netmask 255.255.255.0 #interface mask
#client3
auto eth3
iface eth3 inet static #define the settings for eth3 (interface connected to the network between the router and client3)
address 192.168.103.1 #interface ip
netmask 255.255.255.0 #interface mask
#server
auto eth4
iface eth4 inet static #define the settings for eth4 (interface connected to the network between server and router)
address 192.168.200.1 #interface ip
netmask 255.255.255.0 #interface mask
For the server:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static #define the settings for eth0 (interface connected to the control network)
address 10.0.0.224
netmask 255.255.255.0
gateway 10.0.0.1
auto eth1
iface eth1 inet static
address 192.168.200.2 #define the settings for eth1 (interface connected to the network between server and router)
netmask 255.255.255.0 #interface ip
gateway 192.168.200.1 #interface mask
These settings create the links of the network. In our example, both the clients and the server are connected to the router, but are not interconnected.
2.Add the access routes to the server and other clients:
Routes can be added by the Linux command:
ip route add [ip network we want to see]/[mask of this network] via [ip router that has network access]
To avoid having to run this command every time, a virtual machine is turned on, it can be added to the file /etc/rc.local .
In our example, the following lines must be added to the rc.local file:
PS: Do not copy the comments to files.
For client1:
ip route add 192.168.200.0/24 via 192.168.101.1 #acess to 200 link (server) by router (192.168.101.1)
ip route add 192.168.102.0/24 via 192.168.101.1 #acess to 102 link (client2) by router (192.168.101.1)
ip route add 192.168.103.0/24 via 192.168.101.1 #acess to 103 link (client3) by router (192.168.101.1)
For the other clients, it suffices to change the links IP´s for the respective client´s IP´s and the routers interface IP for the IP refferring to this client´s interface (with the router)
For the server:
ip route add 192.168.101.0/24 via 192.168.200.1 #acess to 101 link (client1) by router (192.168.200.1)
ip route add 192.168.102.0/24 via 192.168.200.1 #acess to 102 link (client2) by router (192.168.200.1)
ip route add 192.168.103.0/24 via 192.168.200.1 #acess to 103 link (client3) by router (192.168.200.1)
For the router:
echo 1 > /proc/sys/net/ipv4/ip_forward #To enable packet forwarding
Then restart each machine, and the virtual network is created!