Este conteúdo não está disponível no idioma selecionado.
Chapter 13. Getting started with IPVLAN
IPVLAN is a driver for a virtual network device that can be used in container environment to access the host network. IPVLAN exposes a single MAC address to the external network regardless the number of IPVLAN device created inside the host network. This means that a user can have multiple IPVLAN devices in multiple containers and the corresponding switch reads a single MAC address. IPVLAN driver is useful when the local switch imposes constraints on the total number of MAC addresses that it can manage.
13.1. IPVLAN modes Copiar o linkLink copiado para a área de transferência!
The following modes are available for IPVLAN:
L2 mode
In IPVLAN L2 mode, virtual devices receive and respond to address resolution protocol (ARP) requests. The
netfilter
framework runs only inside the container that owns the virtual device. Nonetfilter
chains are executed in the default namespace on the containerized traffic. Using L2 mode provides good performance, but less control on the network traffic.L3 mode
In L3 mode, virtual devices process only L3 traffic and above. Virtual devices do not respond to ARP request and users must configure the neighbour entries for the IPVLAN IP addresses on the relevant peers manually. The egress traffic of a relevant container is landed on the
netfilter
POSTROUTING and OUTPUT chains in the default namespace while the ingress traffic is threaded in the same way as L2 mode. Using L3 mode provides good control but decreases the network traffic performance.L3S mode
In L3S mode, virtual devices process the same way as in L3 mode, except that both egress and ingress traffics of a relevant container are landed on
netfilter
chain in the default namespace. L3S mode behaves in a similar way to L3 mode but provides greater control of the network.
The IPVLAN virtual device does not receive broadcast and multicast traffic in case of L3 and L3S modes.
13.2. Comparison of IPVLAN and MACVLAN Copiar o linkLink copiado para a área de transferência!
The following table shows the major differences between MACVLAN and IPVLAN:
MACVLAN | IPVLAN |
---|---|
Uses MAC address for each MACVLAN device. Note that, if a switch reaches the maximum number of MAC addresses it can store in its MAC table, connectivity can be lost. | Uses single MAC address which does not limit the number of IPVLAN devices. |
Netfilter rules for a global namespace cannot affect traffic to or from a MACVLAN device in a child namespace. | It is possible to control traffic to or from a IPVLAN device in L3 mode and L3S mode. |
Both IPVLAN and MACVLAN do not require any level of encapsulation.
13.3. Creating and configuring the IPVLAN device using iproute2 Copiar o linkLink copiado para a área de transferência!
This procedure shows how to set up the IPVLAN device using iproute2
.
Procedure
To create an IPVLAN device, enter the following command:
ip link add link <real_nic_device> name <ipvlan_device> type ipvlan mode l2
# ip link add link <real_nic_device> name <ipvlan_device> type ipvlan mode l2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that network interface controller (NIC) is a hardware component which connects a computer to a network.
To assign an
IPv4
orIPv6
address to the interface, enter the following command:ip addr add dev <ipvlan_device> <ip_address/subnet_mask_prefix>
# ip addr add dev <ipvlan_device> <ip_address/subnet_mask_prefix>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In case of configuring an IPVLAN device in L3 mode or L3S mode, make the following setups:
Configure the neighbor setup for the remote peer on the remote host:
ip neigh add dev <peer_device> <ipvlan_device_IP_address> lladdr <mac_address>
# ip neigh add dev <peer_device> <ipvlan_device_IP_address> lladdr <mac_address>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where MAC_address is the MAC address of the real NIC on which an IPVLAN device is based on.
Configure an IPVLAN device for L3 mode with the following command:
ip route add dev <real_nic_device> <peer_ip_address/32>
# ip route add dev <real_nic_device> <peer_ip_address/32>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For L3S mode:
ip route add dev <real_nic_device> <peer_ip_address>/32
# ip route add dev <real_nic_device> <peer_ip_address>/32
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where IP-address represents the address of the remote peer.
To set an IPVLAN device active, enter the following command:
ip link set dev <ipvlan_device> up
# ip link set dev <ipvlan_device> up
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To check if the IPVLAN device is active, execute the following command on the remote host:
ping <IP_address>
# ping <IP_address>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where the IP_address uses the IP address of the IPVLAN device.