Giter Site home page Giter Site logo

j-mata / networkplugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from katharaframework/networkplugin

0.0 0.0 0.0 125 KB

Docker Network Plugin used by Kathará to create pure L2 networks.

Home Page: https://www.kathara.org/

License: Apache License 2.0

Shell 0.24% C 21.28% Go 62.10% Makefile 11.79% Dockerfile 4.59%

networkplugin's Introduction

Kathará Network Plugin

This repository contains the source code for the Docker Network Plugin used by Kathará.

The plugin has two different versions, which are divided in the two main folders:

  • vde: creates pure L2 LANs using VDE (Virtual Distributed Ethernet) software switches and tap interfaces (which is built using the kathara/katharanp_vde tag).
  • bridge (legacy): creates pure L2 LANs using Linux bridges and veth pairs (which is built using the kathara/katharanp tag).

Build from source

The plugin is compiled and released for both amd64 and arm64 architectures. The tag of the plugin identifies the architecture.

To build both the plugin versions, type on terminal (in the root of the project):

$ make all_<arch>

Where <arch> can be: amd64 or arm64.

NOTE: since the vde version relies on C code, you can only build the Docker plugin for your target architecture!

You can also build only a specific version of the plugin by entering its directory, for example:

$ cd vde && make all_<arch>

The build process leverages on Docker, so you don't need any dependencies installed in your machine.

Use the Plugin without Kathará

It is possible to leverage on this plugin as a standalone Docker Network Plugin, in order to create pure L2 networks. Please check the README of each version (inside the corresponding folder) for specific information.

Assign MAC Addresses to network interfaces

katharanp supports two different ways to assign a MAC Address to a network interface:

  • Pass a specific MAC Address, this can be achieved by leveraging the kathara.mac_addr driver option while connecting a container to a network:
docker network connect --driver-opt kathara.mac_addr=aa:bb:cc:dd:ee:ff l2net container
  • Compute a deterministic MAC Address using the container name and the interface index, this can be done with the kathara.machine and kathara.iface driver options (they are required together):
docker network connect --driver-opt kathara.machine=container --driver-opt kathara.iface=1 l2net container

The formula to compute the MAC address is the following:

  1. Join the two strings, separating the two values by a dash, e.g., container-1
  2. Compute the MD5 of the resulting string: b588c219865f6fe336908e5991216b13
  3. Take the first 6 hex bytes of the string, starting from the left: b588c219865f -> b5:88:c2:19:86:5f
  4. Clean the first byte to obtain a locally administered unicast MAC Address: 0xb5 | 0x02 = 0xb7 & 0xfe = 0xb6
  5. The resulting MAC Address is: b6:88:c2:19:86:5f

Example output from the container:

root@584e403aec5a:/# ifconfig eth1
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether b6:88:c2:19:86:5f  txqueuelen 1000  (Ethernet)
        RX packets 8  bytes 736 (736.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

networkplugin's People

Contributors

skazza94 avatar tcaiazzi avatar lorenzo93 avatar olljanat avatar whatever4711 avatar nsychev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.