VLANs and other ways to divide a network in software

9 min 5 sections 5 practice questions 10 sources citedISC2 objective 4.1

One building's network can be divided into several separate networks without moving a cable. The division is made by settings in switches, routers and firewalls, and it is called logical segmentation. No background is assumed. A security professional needs it because a division that exists only as a setting can be undone by one wrong setting, and attackers know which settings to look for.

By the end of this unit you will be able to:

  • Explain what a VLAN is and why traffic between VLANs has to pass a router or firewall
  • Tell apart a VLAN, a VPN, virtual routing and forwarding and a virtual domain
  • Explain how switch spoofing and double tagging carry a frame into another VLAN, and how each is stopped
  • Match MAC flooding, a rogue DHCP server and ARP poisoning to the switch feature that stops each

The pupil who found the payroll server

An illustrative example

A secondary school runs everything on one network: pupils' laptops, classroom screens, the finance office and the payroll server. A pupil in the library opens the list of shared printers and sends a rude page to the printer beside the bursar's desk. The same list shows the payroll server.

The school cannot afford a second set of switches and cables for the office.

How could the school keep pupils' devices and office systems apart with the switches it already owns?

One switch, several separate networks

A virtual local area network (VLAN) is a group of switch ports that behave as if they were on a switch of their own. Devices in one exchange frames and broadcasts with each other and with nobody else, although every device is plugged into the same physical equipment. Each VLAN is a separate broadcast domain.

Each VLAN has a number, the VLAN ID. The ID is 12 bits long, which allows up to 4,094 VLANs on one network.

A block of flats with one front door

People in one flat talk freely among themselves. To visit another flat a person has to pass the concierge in the hall, who can ask their business and refuse. The flats are VLANs. The concierge is the router or between them.

A frame cannot cross from one VLAN to another at . It has to go up to a router or firewall, which works at , and that device decides whether to pass it. The VLAN makes the division. The rules on the device between VLANs enforce it.

Common misconception

“Systems placed on separate VLANs cannot reach each other.”

A VLAN separates traffic at layer 2 only. If the router between two VLANs forwards everything, the systems reach each other as before. The control is the filtering where the VLANs meet.

Four ways to divide a network in software

Logical segmentation means dividing a network by configuration, without separate hardware for each part. A VLAN is one of four common methods.

Logical segmentation: four methods
MethodWhat it dividesWhere it is set
VLANOne switched network into several layer 2 networksIn the switches
Virtual private network (VPN)A private path out of a shared network such as the internetAt the two ends of a tunnel
Virtual routing and forwarding (VRF)One router into several routers, each with its own routing tableIn the router
Virtual domainOne firewall into several firewalls, each with its own rules and administratorsIn the firewall

A virtual private network (VPN) carries one network's traffic across another inside a tunnel. Each is wrapped in a new packet for the journey and unwrapped at the far end. Most VPNs also what they carry. A tunnel on its own does not.

A router normally keeps one routing table, the list it uses to choose where each packet goes next. With virtual routing and forwarding (VRF) one router keeps several independent tables. Traffic in one table cannot reach addresses in another. Two customers of a carrier can even use the same address ranges without clashing.

A virtual domain splits one physical firewall into several virtual firewalls. Each has its own interfaces, its own rules and its own administrators. A service provider can serve many customers from one device, and a company can give each division a firewall it manages itself.

Logical segmentation is cheaper and quicker to change than separate hardware. Its weakness is that every division depends on the configuration and software of a shared device. One mistake or one flaw in that device can remove all the divisions at once.

Trunks, tags and the native VLAN

A switch port is set up in one of two ways.

Access port
Belongs to one VLAN and connects an end device such as a computer or printer. The device does not know that VLANs exist.
Trunk port
Carries the traffic of many VLANs over one link, between two switches or between a switch and a router.
Tag
A label the switch adds to a frame before sending it over a trunk, holding the frame's VLAN ID. The format is set by the standard IEEE 802.1Q. The receiving switch reads the tag, removes it and delivers the frame to that VLAN only.
Native VLAN
The one VLAN on a trunk whose frames travel with no tag. A frame that arrives on a trunk untagged is assumed to belong to it. On most switches it is VLAN 1 unless changed.

Many switches leave ports able to negotiate: if the device at the other end asks to form a trunk, the port agrees. That convenience and the untagged native VLAN are the two openings used in the attacks that follow.

VLAN hopping: two ways across, and how each is stopped

VLAN hopping is sending frames into a VLAN that the attacker's port does not belong to, without passing the router or firewall.

In switch spoofing the attacker's computer pretends to be a switch and asks its port to become a trunk. If the port negotiates, the attacker can send and receive on every VLAN the trunk carries. The defence is to fix every user-facing port in access mode and switch trunk negotiation off.

Double tagging uses the native VLAN. It works in one direction only.

  1. The attacker's port is in the native VLAN of a trunk, say VLAN 1. The target is in VLAN 20.
  2. The attacker sends a frame carrying two tags: an outer tag for VLAN 1 and an inner tag for VLAN 20.
  3. The first switch sees the outer tag. Native VLAN frames cross the trunk untagged, so it removes that tag and forwards the frame.
  4. The second switch receives a frame whose remaining tag says VLAN 20, and delivers it there.

A double-tagged frame hops into another VLAN

A double-tagged frame hops into another VLANAttacker in VLAN 1, first switch, second switch and target in VLAN 20, in a row. The frame leaves with two tags and crosses the trunk with only tag 20. Below the first switch, the defence: an unused native VLAN.Attackerin nativeVLAN 1Firstswitchstripstag 1Secondswitchreadstag 20Targetin VLAN 20,no replyDefencean unused nativeVLAN on each trunk;no user ports inVLAN 1two tagstag 20A double-tagged frame hops into another VLANAttacker in VLAN 1, first switch, second switch and target in VLAN 20, in a row. The frame leaves with two tags and crosses the trunk with only tag 20. Below the first switch, the defence: an unused native VLAN.Attackerin nativeVLAN 1Firstswitchstripstag 1Secondswitchreadstag 20Targetin VLAN 20,no replyDefencean unused nativeVLAN on each trunk;no user ports inVLAN 1two tagstag 20
Read this figure as text

Double tagging is a way of hopping into a VLAN the attacker's port does not belong to, without passing a router or firewall. It uses the native VLAN, whose frames cross a trunk untagged, and it works in one direction only.

  1. The attacker's port is in the native VLAN of a trunk, VLAN 1. The attacker sends a frame carrying two tags: an outer tag for VLAN 1 and an inner tag for VLAN 20.
  2. The first switch sees the outer tag. Native VLAN frames cross the trunk untagged, so it removes that tag and forwards the frame, which now carries only the tag for VLAN 20.
  3. The second switch receives a frame whose remaining tag says VLAN 20, and delivers it to the target there. Replies cannot return by the same trick, but one frame can be enough to deliver a harmful command.
  4. The defence is to set the native VLAN of every trunk to an ID that nothing else uses, and to keep user ports out of VLAN 1.

Replies cannot return by the same trick, but one frame can be enough to deliver a harmful command. The defence is to set the native VLAN of every trunk to an ID that nothing else uses, and to keep user ports out of VLAN 1.

Other attacks on a switch and their defences

Three more attacks need two terms. The Dynamic Host Configuration Protocol (DHCP) is the service that hands a joining device its IP address and its gateway. The is how a device asks which hardware address holds a given IP address.

Attacks from a switch port and the feature that stops each
AttackWhat the attacker doesDefence
MAC floodingInvents thousands of hardware addresses until the switch's address table is full. The switch then sends every frame to every port, as a hub wouldPort security: a limit on the number of addresses a port may use
Rogue DHCP serverAnswers address requests before the real server and names the attacker's machine as the gatewayDHCP snooping: only ports marked as trusted may send DHCP server replies
ARP poisoningSends false ARP replies so that neighbours send their traffic to the attackerDynamic ARP inspection: drops ARP messages that do not match the addresses DHCP snooping recorded
Switch spoofingAsks a to become a trunkAccess mode fixed, trunk negotiation off
Double taggingHides a second tag behind the native VLAN's tagUnused native VLAN, no user ports in VLAN 1
Rogue root bridgeAnnounces itself as the spanning tree root to draw trafficBPDU guard and root guard on user ports

A private VLAN adds one more division. Ports in the same VLAN are barred from talking to each other and can reach only the gateway. It suits hotel rooms, guest and servers that belong to different customers.

Switches joined by more than one path can pass a frame round a loop for ever. Broadcast frames multiply until the network stops, a broadcast storm. The Spanning Tree Protocol (STP), defined in IEEE 802.1D, prevents this: the switches elect one root switch and block the extra links. They talk in messages called bridge protocol data units (BPDUs).

An attacker who sends BPDUs announcing a better root can draw traffic through their own machine. BPDU guard shuts a user port that receives BPDUs. Root guard stops a port becoming the path to the root.

Ports with nothing plugged in are disabled and placed in a VLAN that leads nowhere, so that a stranger who finds a spare wall socket gains nothing.

A question, worked through

A hospital has placed its medical devices in VLAN 30 and its visitors' Wi-Fi in VLAN 80 on the same switches. An audit finds that a visitor's laptop can open the management page of an infusion pump and receive its replies. The network team confirms that every port is in the correct VLAN and that the trunks are set up as designed.

Which action BEST corrects this?

  1. Add rules on the firewall that routes between the two VLANs
  2. Move the medical devices to a VLAN with a different number
  3. Set the native VLAN on every trunk to an unused number
  4. Enable port security on the ports serving the access points
Decide on your answer, then open the reasoning
  1. The question asks how to stop traffic that crosses between two VLANs although both are set up correctly. Find how the traffic is crossing.
  2. The laptop receives replies. Traffic flowing both ways between VLANs is being routed at layer 3, which means the device between the VLANs is passing it.
  3. Rule out b: a new VLAN number changes the label and nothing else. The router would forward to the new VLAN as it does now.
  4. Rule out d: port security limits hardware addresses on a port and stops MAC flooding. Nothing in the scenario points to flooding.
  5. Between a and c: an unused native VLAN stops double tagging, which works one way only and could not return the pump's replies. Filtering on the firewall between the VLANs closes the path being used, so a is the best answer.

Answer: A. Add rules on the firewall that routes between the two VLANs

Choosing between good answers

An answer relies on VLANs alone to keep two groups of systems apart
look for the option that filters traffic on the router or firewall between them. The VLAN divides and the filter enforces.
A scenario mentions a frame with two tags, or the native VLAN
it is double tagging. Choose an unused native VLAN and no user ports in VLAN 1.
A switch begins sending traffic out of every port after a burst of unknown addresses
it is MAC flooding. Choose port security.
Two customers or divisions must share one router or one firewall and stay apart
choose virtual routing and forwarding for the router and virtual domains for the firewall.
Devices receive a wrong gateway from a server nobody installed
it is a rogue DHCP server. Choose DHCP snooping.

Check your understanding

5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.

These questions are drafts that no named reviewer has approved yet.

Question 1 of 5

Desktops on one floor of an office begin receiving a gateway address nobody recognises. It belongs to a laptop plugged into a meeting-room socket, which answers address requests before the real server does.

Which switch feature would stop this?

What to remember

  • A VLAN makes one switch behave as several separate layer 2 networks. Traffic between VLANs must pass a router or firewall.
  • Logical segmentation has four named methods: VLAN, VPN, virtual routing and forwarding, and virtual domain.
  • A trunk carries many VLANs and tags each frame with its VLAN ID under IEEE 802.1Q. The native VLAN travels untagged.
  • VLAN hopping is done by switch spoofing or by double tagging. Fixed access ports and an unused native VLAN stop them.
  • Port security stops MAC flooding, DHCP snooping stops rogue DHCP servers, and dynamic ARP inspection stops ARP poisoning.
  • A VLAN is not a security control until something filters the traffic that crosses between VLANs.

Say it from memory

  1. Name four methods of logical segmentation and say what each divides.

    A VLAN divides one switched network into separate layer 2 networks. A VPN makes a private tunnel across a shared network. Virtual routing and forwarding gives one router several independent routing tables. A virtual domain divides one firewall into independent virtual firewalls. Traffic between segments is controlled only by the filtering where they meet.

    Read this part again

  2. How long is a VLAN ID, how many VLANs does it allow, and what must a frame pass to cross from one VLAN to another?

    The VLAN ID is 12 bits long, which allows up to 4,094 VLANs on one network. A frame cannot cross between VLANs at layer 2. It has to go up to a router or firewall at layer 3, and the rules on that device enforce the division.

    Read this part again

  3. How does an access port differ from a trunk port, and what is the native VLAN?

    An access port belongs to one VLAN and connects an end device that does not know VLANs exist. A trunk port carries many VLANs over one link, with each frame tagged with its VLAN ID in the IEEE 802.1Q format. The native VLAN is the one VLAN whose frames cross a trunk untagged, VLAN 1 on most switches unless changed.

    Read this part again

  4. What are the two forms of VLAN hopping, and what stops each?

    In switch spoofing the attacker's computer asks its port to become a trunk; the defence is fixing every user-facing port in access mode with trunk negotiation off. Double tagging hides a second tag behind the native VLAN's tag and works one way only; the defence is an unused native VLAN on every trunk and no user ports in VLAN 1.

    Read this part again

  5. Which switch features stop MAC flooding, a rogue DHCP server, ARP poisoning and a rogue root bridge?

    Port security limits the addresses a port may use, which stops MAC flooding. DHCP snooping lets only trusted ports send DHCP server replies. Dynamic ARP inspection drops ARP messages that do not match what DHCP snooping recorded. BPDU guard and root guard on user ports stop a rogue root bridge.

    Read this part again

Sources