|
1 | | -# vxlan |
| 1 | +# VXLAN |
| 2 | + |
| 3 | +This is a toy used to learn VXLAN. |
| 4 | + |
| 5 | +Virtual Extensible LAN (VXLAN) is a network virtualization technology that attempts to address the scalability problems associated with large cloud computing deployments. It uses a VLAN-like encapsulation technique to encapsulate OSI layer 2 Ethernet frames within layer 4 UDP datagrams. |
| 6 | + |
| 7 | +## The objective of VXLan |
| 8 | + |
| 9 | +### 1, Create virtual L2 network over physical L3 network |
| 10 | + |
| 11 | + |
| 12 | +### 2, VXLan encpasulates L2 packet inside L3 packet |
| 13 | + |
| 14 | + |
| 15 | +### 3, `VTEP` implementaion |
| 16 | + |
| 17 | +packet encpasulates is not enought for L2 over L3. VXLan device need to implement the following features. |
| 18 | +- ARP resolution: Need to reply to ARP request from local servers without broadcasting the ARP packet. |
| 19 | +- Destination search: Need to find the destination location corresponding to the destination MAC. |
| 20 | + |
| 21 | +those features refered as `VTEP`(VXLAN endpoints, which terminate VXLAN tunnels and may be either virtual or physical switch ports, are known as VXLAN tunnel endpoints (VTEPs)). |
| 22 | + |
| 23 | +there are some variations of `VETP` implementation, we use local agent and virtual VXLan switch run on Linux servers. |
| 24 | + |
| 25 | +## Implementation `VTEP` in this project. |
| 26 | + |
| 27 | +Create the vxlan device, Then as each remote host is discovered (either on startup or when they are added), do the following |
| 28 | + |
| 29 | +- Create routing table entry for the remote subnet. It goes via the vxlan device but also specifies a next hop (of the remote host). |
| 30 | +- Create a static ARP entry for the remote host IP address (and the VTEP MAC) |
| 31 | +- Create an FDB entry with the VTEP MAC and the public IP of the remote daemon. |
| 32 | + |
| 33 | +In this scheme the scaling of table entries is linear to the number of remote hosts - 1 route, 1 arp entry and 1 FDB entry per host. |
| 34 | + |
| 35 | +use `etcd` as the key-value store to exchange information when remote host status changed(add, delete, update, etc...). |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +get the lastest [release](https://github.com/cssivision/vxlan/releases). |
| 40 | + |
| 41 | +Run |
| 42 | +```sh |
| 43 | +sudo ./vxlan -etcdEndpoint http://etcd:2379 |
| 44 | +``` |
| 45 | + |
| 46 | +you will get log similar to the following. |
| 47 | +``` |
| 48 | +INFO[0000] Determining IP address of default interface |
| 49 | +INFO[0000] Using interface with name eth0 and address 10.146.0.3 |
| 50 | +INFO[0000] Defaulting external address to interface address (10.146.0.3) |
| 51 | +INFO[0000] VXLAN device already exists |
| 52 | +INFO[0000] Returning existing device |
| 53 | +INFO[0000] subnet key expired in: 2018-02-25 09:23:53.467058164 +0000 UTC |
| 54 | +INFO[0000] create subnet: 10.10.238.0, net mask: 24 |
| 55 | +INFO[0000] MTU: 1410 |
| 56 | +INFO[0000] VXLan HardwareAddr: 1a:0f:87:98:5e:c7 |
| 57 | +INFO[0000] Running backend. |
| 58 | +INFO[0000] adding subnet: 10.5.10.0/24 PublicIP: 10.140.0.3 VtepMAC: f6:ad:73:33:de:0b |
| 59 | +INFO[0000] calling AddARP: 10.5.10.0, f6:ad:73:33:de:0b |
| 60 | +INFO[0000] calling AddFDB: 10.140.0.3, f6:ad:73:33:de:0b |
| 61 | +``` |
| 62 | + |
| 63 | +## Reference |
| 64 | +- Flannel https://github.com/coreos/flannel |
| 65 | +- VXLan attributes, Please consult the man page for `ip link` and see the vxlan section for more details. |
| 66 | +- How VXLan work? https://www.slideshare.net/enakai/how-vxlan-works-on-linux |
| 67 | +- IP route fundamental |
| 68 | + - https://www.thegeekstuff.com/2012/04/ip-routing-intro/ |
| 69 | + - https://www.thegeekstuff.com/2012/04/route-examples/ |
| 70 | + - https://www.thegeekstuff.com/2012/05/route-flags/ |
0 commit comments