In 2016 I wrote a series of posts about a special section of Linux-based virtual networking, namely network namespaces and virtual VLANs. In parallel I published another series about IPtables rules on virtual Linux bridges. See
Fun with veth-devices, Linux bridges and VLANs in unnamed Linux network namespaces – I
and
Linux bridges – can iptables be used against MiM attacks based on ARP spoofing ? – I
plus related posts.
The motivation behind those post series was to find ways to define and separate packet paths in complex virtual LANs, which we may create on virtualization hosts. VLAN tagging is one of the methods to define certain allowed and disallowed paths of ICMP and TCP/IP packets between virtual hosts, virtual LAN segments or virtual network namespaces on Linux hosts. On virtual bridges/switches additional iptables/ebtables or nftables rules may help to control the traffic between certain bridge-ports and the segments behind them.
This new post series extends my old series. Among other things I will have a closer look on scenarios in which two separate LAN- and VLAN-segments with NICs in one and the same IP-(sub)-net (class C network) get connected by a namespace with routing rules. In addition the behavior of ARP and ICMP packets on bridges with IPtables rules will be analyzed.
I want to mention that some really clever and serious questions of a reader, Joshua Greenberg, motivated me to do this work. His questions regarding some of my old statements gave me some headache – in particular with respect to ARP. We agreed upon that some question marks behind my line of thought of 2016 could only be answered by further experiments. So, many thanks to Jushua for giving me a push to turn my head towards virtual networking again.
Open points and questions regarding the old post series
Both named post series on virtual networking got a long way, but were not finalized. The connection of (virtual) VLANs to external real (physical) networks via namespaces that contain one or more real NICs were not discussed. It is not at all clear whether we can separate the traffic between the VLANs and the outer world without the help of firewalls. In this context we may also have to look closer at the relation of VLANs to IP-subnets.
I briefly outline some of further open questions.
Multiple VLAN termination points and related sub-devices of one veth-endpoint in a network namespace
I admit that I should have analyzed virtual veth connections which support multiple VLANs more thoroughly for some of my scenarios in the 2016 posts. In particular a closer look at scenarios where a veth-endpoint puts multiple VLAN-related sub-devices into one and the same target namespace would have been helpful to avoid confusion. I.e., I should study scenarios with different virtual VLANs terminating in a common namespace more carefully. Before you think this gets boring, note that the veth end-point device itself gets just one IP. See e.g. post.
Such a situation introduces multiple open tagging virtual NIC devices in one namespace. Somehow we need to control which VLAN device and path a packet should “choose” to get the right VLAN tag (VID) and to enable its further transport through the right VLAN to a target NIC. And we should better understand what ARP packets do in the Linux network namespace in such a situation.
Such a scenario is e.g. also of interest when traffic of different virtual VLANs must be directed to or through a common namespace which comprises VLAN end-points and a real NIC; the latter to enable communication to the outside world of a Linux virtualization host. Such a namespace would be a routing one.
In this context the coupling of network layer 2 (Link layer) to layer 3 (IP or network layer) is of special interest. Layer coupling via deliverance of information about IP/MAC-relations is done by the ARP protocol. We all know that ARP is often used in hacker attacks. So it might be a good idea to know what happens with ARP in namespaces which contain multiple VLAN end-points.
In my old posts I speculated that ICMP and ARP answers in such unclear situations may depend on defined routes in the namespace. We shall find out in how far this is true by two corresponding experiments.
Connecting different L2-segments without and with VLANs by routing network namespaces
The scenario named above is just a special case of connecting or separating “L2-segments” in a common namespace. I define a L2-segment as a LAN-segment, in which packets on the Link Layer travel freely. A L2-segment forms an Ethernet broadcast domain; Ethernet broadcast packets reach all NICs attached to a L2-segment. A good introduction to L1- and L2-segments and related Ethernet broadcasts is given here. Note that a complexly and hierarchically structured L2-segment may be created by connecting real or virtual linear Ethernet bus-lines by Linux bridges.
An exciting area of unusual scenarios opens up when so called L2-segments do not coincide with logical IP sub-nets.
Two separated L2-segments may have NICs with IPs belonging to one and the same IP network class. The attentive reader of my 2016 series has of course noted that this was the case in all scenarios discussed at that time. Actually, this was a clue: I used VLANs to isolate packet paths within one and the same IP sub-net ( a class C net) and within originally coherent L2-segments against each other.
Now, multiple different and originally separated virtual L2-segments with IPs of the same IP net may be coupled by routing devices, routing namespaces or (VLAN-aware) bridges/switches. What happens with ARP requests and answers in such situations?
On the other hand side NICs attached to one and the same L2-segment may belong to different IP sub-nets. Which on first sight appears to be a stupid mis-configuration; but it may occur. What about ARP then?
What about VLANs across segments belonging to different logical IP sub-nets? Do such configurations make sense at all?
Bridges, iptables, VLANs and ARP
Readers have also sent me questions regarding VLAN-aware bridges and the propagation of ARP requests and ARP answer packets when IPtables rules control the packet traffic between bridge ports via “physdev“-related commands. What about tagged packets on a bridge with IPtables?
Summary
Linux network namespaces, virtual Linux bridges and veth network devices make it possible to realize complex virtual network scenarios on a virtualization host – including virtual VLANs. As such virtual networks must be well protected against hacker attacks as real networks we should first understand packet transport through virtual networks, their devices and in particular across Linux bridges sufficiently well.
Linux network namespaces and veths allow us to study packet transfer on different OSI layers in elementary network scenarios for L2-segments with and without virtualized VLANs in detail.
The questions which remained open in my old post series and some new questions of readers invite us to study a bunch of further scenarios in a new post series.
In the next post
More fun with veth and Linux network namespace – II – two L2-segments attached to a common network namespace
I will pose and study a scenario without VLANs and respective tags. I will just attach veth end-points of two otherwise separated L2-segments to a common network namespace. Nevertheless, this very simple experiment will shed some light on open questions regarding routes, ARP and ICMP requests and answers. It will also lead us to aspects of PROXY ARP in (routing and forwarding) network namespaces.