detiuaveiro / PECI-05-2022-23

https://detiuaveiro.github.io/PECI-05-2022-23/
0 stars 0 forks source link

Deploy a BMV2 as a Container #47

Open davidjosearaujo opened 1 year ago

davidjosearaujo commented 1 year ago

Container BMV2

In order to later use the systems in real-life scenarios, the system must be able to programmatic deploy VMs where the BMV2 will run, create interfaces, program IPs, and all other requirements.

How to manage links between services and BMV2 switches?

davidjosearaujo commented 1 year ago

Run simple_router_grpc inside a Vagrant and bind its interfaces to no the script ports

davidjosearaujo commented 1 year ago

AS this evolved, using a container instead of a VM has proven itself to be viable, now I need to understand how the switch script interacts with the system's veth interfaces.

davidjosearaujo commented 1 year ago

I now understand that in order to connect containers to one another, from the use I must create "virtual cables" using veth pairs. To do this, in the container with the bmv2 switch I have create multiple interfaces (VLAN or MACVLAN) that can be linked to on end of a veth pair created by the host.

This simplifies the process from the container side, but it means more configurations on the side of the host, which will have to create a new veth pair each time it want to connect a new service to the bmv2 swithc.

Reading material

davidjosearaujo commented 1 year ago

ChatGPT for the win !

https://novaappai.page.link/kxrK9uYanazDQVsXA

  1. Create a veth pair on the host. You can do this using the following command: sudo ip link add veth0 type veth peer name veth1

  2. Assign one end of the veth pair (say veth0) to the first container and the other end (veth1) to the second container. You can do this using the following commands: sudo ip link set veth0 netns <container1> sudo ip link set veth1 netns <container2> Where <container1> and <container2> are the names or IDs of the respective containers.

  3. Inside each container, set the veth interface as the default gateway. You can do this using the following command: sudo ip route add default via <veth-peer-ip-address> where <veth-peer-ip-address> is the IP address assigned to the other end of the veth pair on the host.

  4. Now, you can set the corresponding eth0 interfaces of the containers as the master of the veth pairs. This can be done by running the following command on the host: sudo ip link set dev eth0 master veth0 sudo ip link set dev eth0 master veth1