<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NAT (Network Address Translation) on Digi Hunch</title><link>https://www.digihunch.com/tags/nat-network-address-translation/</link><description>Recent content in NAT (Network Address Translation) on Digi Hunch</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Tue, 08 Apr 2025 14:48:02 -0400</lastBuildDate><atom:link href="https://www.digihunch.com/tags/nat-network-address-translation/index.xml" rel="self" type="application/rss+xml"/><item><title>Kubernetes Networking Solutions Overview</title><link>https://www.digihunch.com/2021/06/kubernetes-networking-solutions-overview/</link><pubDate>Tue, 22 Jun 2021 12:14:26 -0400</pubDate><guid>https://www.digihunch.com/2021/06/kubernetes-networking-solutions-overview/</guid><description>&lt;img src="https://www.digihunch.com/wp-content/uploads/2025/04/feature-k8s-networking.webp" alt="Featured image of post Kubernetes Networking Solutions Overview" /&gt;&lt;p class="wp-block-paragraph"&gt;Kubernetes networking involves a lot of details. We discuss some CNI plugins in this post. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The most basic mode is &lt;a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/#kubenet"&gt;kubenet&lt;/a&gt;. We use &amp;#8211;network-plugin=kubenet with kubelet process to use it. Kubenet is not a CNI plugin, but it works with bridge, lo and host-local (CNI-compliant implementations). We can directly specify MTU with &amp;#8211;network-plugin-mtu. Kubenet is a basic network plugin, based on bridge plugin, with the addition of port mapping and traffic shaping. It does not offer cross-node networking itself. Today it is typically used with managed clusters by cloud providers, where the cloud provider set up routing rules themselves for inter-node communication.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When a cluster goes multi-node, the main challenge is communication between Pods across different nodes. Pods come and go. The size of cluster could increase or decrease as well. The network solutions come in two network types: overlay network based on encapsulation, or non-overlay networks, most likely using routing techniques. Common backends for for multi-host container networking solutions include VXLAN encapsulation, IPIP encapsulation, host-gw, IPSec. In addition, there are some backends that only used by certain plugins.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-common-backends"&gt;Common Backends&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;VXLAN&lt;/strong&gt;: use in-kernel VXLAN to encapsulate the packets. VXLAN is a &lt;a href="https://developers.redhat.com/blog/2018/10/22/introduction-to-linux-interfaces-for-virtual-networking#"&gt;virtual networking capability&lt;/a&gt; in Linux which is also used in &lt;a href="https://www.digihunch.com/2020/08/virtualization-4-of-4-networking/"&gt;virtualization&lt;/a&gt; technology. VXLAN is an overlay technology requiring encapsulation of overlay network&amp;#8217;s layer-2 frame into UDP packet at layer 4 of underlay network. When configured, the VxLAN backend creates a Flannel interface on every host. When a container on one node wishes to send traffic to a different node, the packet goes from the container to the bridge interface in the host&amp;#8217;s network namespace. From there the bridge forwards it to the Flannel inteface because the kernel route table designates that this interface is the target for the non-local portion of the overlay network. The Flannel network drive wraps the packet in a UDP packet and sends it to the target host. Once it arrives at its destination, the process flows in reverse, with the Flannel driver on the destination host unwrapping the packet, sending it to the bridge interface, and from there the packet find its way into the overlay network and to the destination Pod.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;host-gw&lt;/strong&gt;: the host-gw is a non-overlay solution that maintains route tables on Linux Host to allow Pods to communicate across Nodes. It is only used in Flannel plugin. Suppose we have two hosts, each with two containers as connected below. Initially, container0 is not able to reach container2 because eth0 on node0 does not have an entry that matches container2&amp;#8217;s IP address. The packet is there sent to default route, which isn&amp;#8217;t destined to container2. &lt;/p&gt;&#10;&lt;figure class="wp-block-image is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://gblobscdn.gitbook.com/assets%2F-LOuzrzA9qdsjWfu2rC9%2F-LUPoGQ1ihiJFofTaO7A%2F-LUPoH4I_mQkNKdfkxU1%2Fhost-gw.png?alt=media" alt="" style="width:840px;height:366px" width="840" height="366"/&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;However, if we build rules to match container IP address, on the route table of each node. The issue would be solved. This is essentially how host-gw works. Specifically, on node 0, we add &amp;#8220;ip route add 192.168.1.0/24 via 10.20.0.2 dev eth0&amp;#8221;, on node 1, we add &amp;#8220;ip route add 192.168.0.0/24 via 10.20.0.1 dev eth0). The host-gw in Flannel will manage rule addition to us. Note that the two hosts must have direct layer 2 connectivity. In other words, there must not be a router between the two nodes. Otherwise, the routing table on the router is out of reach. In fact, all nodes in a Flannel network must have layer 2 connectivity with each other. In other words, all nodes must be in a single LAN. Host-gw provides better performance than VxLAN.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;IPSec&lt;/strong&gt; uses in-kernel IPSec to encapsulate and encrypt the packets. IPsec is a group of protocols to ensure authentication and encryption per packet between devices. Since it secures traffic at layer 3 and now it has become a major backend technology for VPN. IPsec adds several headers and trailers to datagram containing authentication and encryption information. The two major protocols working in IPSec are AH (Authentication Header) and ESP (Encapsulating Security Payload). AH serves up authentication services only; ESP provides both authentication and encryption abilities. It also uses IKE protocol for key exchange.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;IPSec works in two modes: transport and tunnelling mode. &lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Transport mode creates a secure tunnel between two devices end to end. The payload of each datagram is encrypted, but the original IP header is not. Intermediary routers are thus able to view the final destination of each datagram, unless a separate tunnelling protocol (e.g. GRE) is used.&lt;/li&gt;&#10;&lt;li&gt;Tunnel mode works between two endpoints, such as two routers, protecting all traffic that goes through the tunnel. The original IP header containing the final destination of the datagram is encrypted, in addition to the payload. To tell intermediary routers where to forward the datagrams, IPsec adds a new IP header. At each end of the tunnel, the routers decrypt the IP headers to deliver the datagram to their destinations. The intermediary routers does not know the final destination, or what transport protocol is used.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;IPIP&lt;/strong&gt; (IP over IP) tunnel is typically used to connect two internal IPv4 subnets through public IPv4 internete. It has the lowest overhead but can only transmit IPv4 unicast traffic.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-cni-plugins"&gt;CNI Plugins&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Originally, the network functions were developed in-tree. Then the CNI specification came up to allow plugin development out-of-tree to implement cluster networking functions. The Container Network Interface seeks to completely decoupled network management from container runtime. Kubernetes picked CNI over CNM in 2016, as discussed in my &lt;a href="https://www.digihunch.com/2020/08/virtualization-4-of-4-networking/"&gt;virtualization&lt;/a&gt; discussion. CNI clearly defines the specification for following activities:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;When a Pod comes up, give it a network interface&lt;/li&gt;&#10;&lt;li&gt;Assign IP to the network interface&lt;/li&gt;&#10;&lt;li&gt;When a Pod is deleted, delete the associated network interface&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When we configure a Kubernetes cluster, we must specify &amp;#8211;network-plugin switch, so that the cluster is operational. If we use CNI as network-plugin, we also need to install the plugin, optionally with the help of Rancher.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;On the worker node, we use &amp;#8211;network-plugin=cni with kubelet process to use CNI plugins. A plugin may consist one or more binaries. The binaries are located in /opt/cni/bin (or otherwise specified by &amp;#8211;cni-bin-dir). The configurations are located in /etc/cni/net.d (or otherwise specified in &amp;#8211;cni-conf-dir). Note that the configuration file may reference different plugin implementations for different network management purpose (e.g. interface creating, address allocation, etc). The &lt;a href="https://github.com/containernetworking/plugins"&gt;container networking repo&lt;/a&gt; provided some reference implementations and some of them are used by other plugins. These reference implementations include:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Main (interface creating): bridge, ipvlan, loopback, ptp, macvlan, etc&lt;/li&gt;&#10;&lt;li&gt;IPAM (IP address management): host-local, dhcp, static&lt;/li&gt;&#10;&lt;li&gt;Meta (other plugins): portmap, bandwidth&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;So, a CNI plugin consists of a networking solution for backend, and binaries to cover the aspects outlined above. I discussed some common backends above. Below I will introduce some common plugins and backends only available to each plugin&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-flannel"&gt;Flannel&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Flannel by CoreOS: supports a range of backends. The advantage of Flannel is it reduces the complexity of doing port mapping. &lt;a href="https://blog.laputa.io/kubernetes-flannel-networking-6a1cb1f8ec7c"&gt;This&lt;/a&gt; is a great post that covers the mechanism.&lt;/p&gt;&#10;&lt;figure class="wp-block-image is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://miro.medium.com/max/983/1*EFr8ohzABfStS7o9gGMYKw.png" alt="" style="width:737px;height:217px" width="737" height="217"/&gt;&lt;figcaption class="wp-element-caption"&gt;Flannel with overlay (e.g. VxLAN on UDP encapsulation)&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;It supports VXLAN, host-gw, IPSec, IPIP as well as the followings:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;strong&gt;Amazon VPC&lt;/strong&gt;: recommended with Amazon VPC. AWS VPC creates IP routes in an AWS route table. The number of records in this table is limited by 50 so you can&amp;#8217;t have more than 50 machines in a cluster.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;strong&gt;GCE&lt;/strong&gt;: recommended with Google Compute Engine Network. Instead of using encapsulation, GCE also manipulates IP route to achieve maximum performance. Because of this, a separate flannel interface is not created.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;UDP&lt;/strong&gt;: debugging only for old kernels that don&amp;#8217;t support VXLAN&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 class="wp-block-heading" id="h-calico"&gt;Calico&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://en.wikipedia.org/wiki/Border_Gateway_Protocol"&gt;Border Gateway Protocol &lt;/a&gt;(BGP) is a standardized exterior gateway protocol designed to exchange routing and reachability information among autonomous systems (AS) on the Internet.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Calico operates at layer 3. It prefers BGP without an overlay network for the highest speed and efficiency, but in scenarios where hosts cannot directly communicate with one another, it can utilize an overlay solution (e.g. VxLAN or IP-in-IP). Calico also supports network policies for protecting workloads and nodes from malicious activity or aberrant applications.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The Calico networking Pod contains a CNI container to keep track of Pod deployment, and register addresses and routes. It also contains a daemon that announces the IP and route information to the network via the Border Gateway Protocol (BGP). The BGP daemon build a map of the network that enables cross-host communication.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Calico requires a distributed and fault-tolerant key/value store, and deployments often choose etcd to deliver this component. Calico uses it to store metadata about routes, virtual interfaces, and entwork policy objects. Calico can either use a separate HA deployment of etcd, or the same etcd datastore with the Kubernetes cluster.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When we are unable to use BGP (e.g. with cloud provider, or in an environment where we have no permission to configure router peers. Calico&amp;#8217;s IP-in-IP mode encapsulates packets before sending them to other nodes.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Once IP-in-IP is configured, Calico wraps inter-Pod packets in a new packet with headers that indicate the source of the packet is the host with the originating Pod, and the target of the packet is the host with the destination Pod. The Linux kernel performs this encapsulation, and then forwards the packet to the destination host where it is unwrapped and delivered to the destination Pod.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-canal"&gt;Canal&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The followings is quoted from Rancher &lt;a href="https://rancher.com/blog/2019/2019-03-21-comparing-kubernetes-cni-providers-flannel-calico-canal-and-weave/"&gt;website&lt;/a&gt;:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Canal seeks to integrate the networking layer provided by Flannel with the networking policy capabilities of Calico. As the contributors worked through the details however, it became apparent that a full integration was not necessarily needed if work was done on both projects to ensure standardization and flexibility. As a result, the official project became somewhat defunct, but the intended ability to deploy the two technology together was achieved. For this reason, it&amp;#8217;s still sometimes easiest to refer to the combination as &amp;#8220;Canal&amp;#8221; even if the project no longer exists. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Because Canal is a combination of Flannel and Calico, its benefits are also at the intersection of these two technologies. The networking layer is the simple overlay provided by Flannel that works across many different deployment environments without much additional configuration. The network policy capabilities layered on top supplement the base network with Calico’s powerful networking rule evaluation to provide additional security and control.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-weave-net"&gt;Weave Net&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Weave Net by Weaveworks offers a different paradigm. Weave creates a mesh overlay network between each of the nodes in the cluster, allowing for flexible routing between participants. Applications use the network just as if the containers were all plugged into the same network switch, with no need to configure port mappings and links.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For more good references to determine networking options, check out these posts:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Calico &lt;a href="https://projectcalico.docs.tigera.io/networking/determine-best-networking"&gt;blog&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;Rancher &lt;a href="https://www.suse.com/c/rancher_blog/comparing-kubernetes-cni-providers-flannel-calico-canal-and-weave/"&gt;blog&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;Kubevious &lt;a href="https://kubevious.io/blog/post/comparing-kubernetes-container-network-interface-cni-providers"&gt;blog&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2021/06/kubernetes-storage-explained/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Kubernetes Storage Explained – from in-tree plugin to CSI&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2021/07/traffic-management-in-kubernetes-service-and-ingress/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Service and Ingress -Traffic Management in Kubernetes&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>Virtualization 4 of 4 – Networking</title><link>https://www.digihunch.com/2020/08/virtualization-4-of-4-networking/</link><pubDate>Fri, 21 Aug 2020 21:53:32 -0400</pubDate><guid>https://www.digihunch.com/2020/08/virtualization-4-of-4-networking/</guid><description>&lt;h3 class="wp-block-heading"&gt;Virtual LAN (VLAN)&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Although VLAN emerged before virtualization and is technically not part of virtualization topic. I&amp;#8217;d just like to start from here as a refresher. Suppose we have computers from finance department and computers from sales department all connected to a single layer-2 switch. There are at least three problems: 1) too many devices on the same broadcast domain causes traffic congestion; 2) security can be compromised and 3) each department might have several physical locations. We introduce multi-layer switch to address these with two main features: 1) the VLAN feature can map ports to logical networks, so that all hosts are physically connected to a single switch, but logically to their own network (VLAN) 2) the SVI (switch virtual interface) feature allows inter-VLAN routing at layer 3. Such multi-layer switch is sometimes referred to as layer-3 switch. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;VLAN is local to a switch and a tag is required in ethernet frame in order to pass VLAN info across switches. This link between switches is called a &lt;strong&gt;trunk&lt;/strong&gt;. &lt;a href="https://en.wikipedia.org/wiki/IEEE_802.1Q"&gt;IEEE 802.1q&lt;/a&gt; (aka dot1q) is the networking standard for VLAN, which standardizes the tagging traffic between switches to tell which traffic belongs to which VLAN. The dot1q trunk (aka dot1q link) provides VLAN IDs fro frames traversing between switches. A trunk can be configured between two switches, or between a switch and a router. &lt;strong&gt;Trunking&lt;/strong&gt; is the process of traversing different VLAN traffic over the trunk. The ports on each switch need to be configured to enable trunking. While Cisco calls such ports &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;trunk port&lt;/strong&gt;&lt;/span&gt;, others call them &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;tagged port&lt;/strong&gt;&lt;/span&gt;. Their function is to add the VLAN tag to ethernet frame. In contrast, regular ports that send and receive frames without VLAN tag are called &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;access port&lt;/strong&gt;&lt;/span&gt; or &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;untagged port&lt;/strong&gt;&lt;/span&gt;. Trunk port carries traffic for multiple VLANS whereas access port carries traffic for a single VLAN. A network device connected to access port has no idea about its VLAN belonging. VLAN creation and management are the responsibility of the switch. Common trunking protocols include &lt;span style="text-decoration: underline;"&gt;VTP (VLAN trunking protocol) &lt;/span&gt;and &lt;span style="text-decoration: underline;"&gt;DTP (dynamic trunking protocol)&lt;/span&gt;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;This &lt;a href="https://www.youtube.com/watch?v=NmkFzDrZsXM"&gt;video&lt;/a&gt; and &lt;a href="https://www.professormesser.com/network-plus/n10-008/n10-008-video/vlans-and-trunking-n10-008/"&gt;this&lt;/a&gt; video have good explanations on VLAN.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading"&gt;Virtual Extensible LAN (VXLAN)&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;VXLAN is an overlay protocol. Remember that in the standard TCP/IP stack, you normally encapsulate layer-3 IP datagram into a layer-2 ethernet frame. With the VXLAN encapsulation technique however, layer-2 frames can be encapsulated within layer-4 UDP packet.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;VXLAN allows you to stretch layer 2 connection over an intervening layer 3 network. VXLAN tunnel endpoints (VTEPs) are the endpoint device that terminate VXLAN tunnels and it can be either virtual or physical switch ports. It encapsulate VXLAN traffic and de-encapsulate the traffic when it leaves the VXLAN tunnel.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The VXLAN encapsulation includes the followings:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Outer Ethernet Header (source and dest MAC for underlay VTEPs)&lt;/li&gt;&#10;&lt;li&gt;Outer IP header (source and dest IP on underlay network)&lt;/li&gt;&#10;&lt;li&gt;Outer UDP header (including source and dest ports, 4789 default)&lt;/li&gt;&#10;&lt;li&gt;VXLAN Header (including VNI)&lt;/li&gt;&#10;&lt;li&gt;Inner Ethernet Frame (with source and dest MAC for overlay interfaces)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The VNI (VXLAN network identifier, aka VNID) included in the VXLAN header is 24-bit long. It is conceptually similiar to VLAN ID in VLAN but only with 12-bit length.&lt;/p&gt;&#10;&lt;figure class="wp-block-image"&gt;&lt;img decoding="async" src="http://chansblog.com/wp-content/uploads/2015/02/0.1-VXLAN-frame.jpg" alt=""/&gt;&lt;figcaption class="wp-element-caption"&gt;VXLAN Enapsulation&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The VXLAN protocol is documented in &lt;a href="https://tools.ietf.org/html/rfc7348"&gt;RFC7348&lt;/a&gt;. Its specification was originally created by VMware, Cisco and Arista. As it became more common in network virtualization (with data centre virtualization, and application containerization) several other players joined the list of contributors and they manufacture switches that support VXLAN. &lt;a href="https://support.huawei.com/enterprise/en/doc/EDOC1100086966#:~:text=VXLAN%20encapsulates%20a%20Layer%202,over%20a%20Layer%203%20network.&amp;amp;text=It%20establishes%20a%20logical%20tunnel,forward%20them%20through%20the%20tunnel."&gt;This&lt;/a&gt; is a section on VXLAN from the document of Huawei Cloud Engine 5800 switch.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://www.openvswitch.org/"&gt;Open vSwitch&lt;/a&gt; is an example of a software-based virtual network switch that supports VXLAN overlay networks.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In summary, the main benefits of VXLAN over VLAN are:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;VXLAN scales up to 16 million logical networks, thanks to the 24-bit length of VNI&lt;/li&gt;&#10;&lt;li&gt;VXLAN supports layer 2 adjacency across IP networks. A VM belonging to existing layer 2 domain can be created in different data centre (where more computing resources are available), without being constrained by layer 2 boundaries, or being forced to create geographically stretched layer 2 domains (stretched VLAN).&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 class="wp-block-heading"&gt;Virtual Machine Networking&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For VM to connect to each other, within or across hosts, we need not only vNIC on VM, but also vSwitch to connect vNICs. A vSwitch (aka bridge) is a logically defined layer-2 device that passes frames between vNICs. On the same host, vNICs are directly connected to vSwitch, which is then connected to the physical NIC. Each vSwtich connects a broadcast domain. When we setup vNIC there are three modes:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Bridged networking:&lt;/strong&gt; VM connect to outside network using host&amp;#8217;s physical NIC, which acts as a bridge between vNIC and outside network. The VM is a full participant in the network as if it were a physical computer on the network. i.e. it obtain IP addressing information from a DHCP server on the outside (physical) network. The VM&amp;#8217;s IP address is also visible and directly accessible by other computers on the network. bridge networking is common for servers as VMs.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;NAT networking:&lt;/strong&gt; The VM relies on the host to act as NAT device to make outgoing network connection. The IP address of VM is assigned by virtual DHCP server on host. The guest VMs form a private network and computers on the outside network are external. The host translates private IP address into the host&amp;#8217;s IP address on the way out, and listens for returning traffic. Outside network sees traffic from VM guest as if it were from the host. This network mode is common when the VMs are mainly used as a client workstation.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Host-only networking: &lt;/strong&gt;creates a network that is completely contained within the host computer. The vSwtich is the hub of the private network and the physical NIC on the host is not involved. The VM will not have access to the outside network. This mode is useful when the VMs needs to be isolated from outside network, and only need to communicate with peers on the same host.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The difference between NAT networking and host-only networking is the exposure of VM guest to external network. All of these networking modes are &lt;a href="https://knowledge.broadcom.com/external/article/303393/understanding-networking-types-in-vmware.html"&gt;available&lt;/a&gt; on VMWare fusion, for example. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Advanced virtualization platform such as vSphere usually support multi-hosting. Multiple host can also be configured to form a distributed vSwitch, such as &lt;a href="https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.networking.doc/GUID-6E51D76A-DC9F-44E2-B673-7D92384AFDE4.html"&gt;vSphere Distributed Switch&lt;/a&gt;, in addition to standard switches.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading"&gt;Docker Networking&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;I had a &lt;a href="https://www.digihunch.com/2020/07/dockersnetwork/"&gt;brief&lt;/a&gt; on Docker network covering three modes. Out of the three modes, single-host bridge network is the equivalent of host-only networking. MacVLAN driver is similar to bridged networking, in the sense that container may connect to external network, using host NIC as a bridge. However, the external network is still bound by physical location. This is when overlay network comes in handy.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading"&gt;CNM and CNI&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In the Docker networking, container needs to map its own port to host, of which the port resource is implemented by IP tables, which limits the scale and performance of the solution. Also, those networking modes do not address the problem of multi-host networking. As multi-host networking became a real need for containers, the industry started looking into different solutions. Container project favour a model where networking is decoupled from the container runtime. This also greatly improves application mobility. In this model, networking is handled by a &amp;#8216;plugin&amp;#8217; or &amp;#8216;driver&amp;#8217; that manages the network interface, and how the containers are connected to the network. The plugin also assigns the IP address to the container&amp;#8217;s network interfaces. In order for this model to succeed, there needs to be a well-defined interface or API between the container runtime and the network plugins.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Docker, the company behind the Docker container runtime, came up with the Container Network Model (CNM). Around the same time, CoreOS, the company responsible for creating the rkt container runtime, came up with the Container Network Interface (CNI). Kubernetes originally seeks to use CNM for its plugins, but they eventually decided to go with CNI. The primary reason was that CNM was still seen as something designed with Docker container runtime in mind and was hard to decouple from it. After this decision, several other open source project also turned to CNI for their container runtimes.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;This &lt;a href="https://thenewstack.io/container-networking-landscape-cni-coreos-cnm-docker/"&gt;article&lt;/a&gt; expands further into the difference between CNM and CNI.&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2020/08/virtualization-3-of-3-containers/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Virtualization 3 of 4 – Containers&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2020/08/zookeeper/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Zookeeper Summary&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item></channel></rss>