Hopp til innhold

Vlan's an' network segmentin'

Relevante sider
Andre relevante sider
Skip to content

This here’s a machine-translated text that might contain errors!

VLAN an’ Network Segmentation

Here ya’ll split a network into segments an’ figure out which traffic gets to ride through. Ya need da address, prefix, gateway, an’ port from IP, subnets, an’ default gateway an’ network protocols.

Start off with da VLAN example, Task 1, an’ da firewall drill. Da trail is access plan listin’ what traffic’s allowed in an’ what stays out. Makkin’ any real changes needs its own blessed test setup an’ a way back ta how it was before. If ya don’t got that kind o’ access, use da example fer plannin’; ya ain’t touchin’ da school’s net. Subnet math an’ DHCP setup are optional rides.

Why Segment?

Segmentation splits the network into smaller chunks. VLANs separate traffic at layer 2. A router or layer-3 switch can still pass traffic between ‘em, but firewalls or access rules decide what’s actually allowed through.

Benefit Explanation
Security Access rules can limit which services an IoT camera gets to reach
Performance Less broadcast traffic per segment
Control Different rules for different user groups
Troubleshooting Easier to pin down problems in a specific segment

A practical example

This is a hypothetical breakdown, not the school’s actual setup or finished firewall rules:

  • VLAN 10: Administration - Payroll, HR, management. Strictly limited access.
  • VLAN 20: Staff - Teachers and other employees. Access to shared folders and printers.
  • VLAN 30: Students - Internet access and learning platforms only.
  • VLAN 40: IoT - Printers, smart screens, cameras. No internet access (or very limited).
  • VLAN 50: Servers - Internal servers. Access from other VLANs only for agreed-upon services.

What’s a VLAN?

A virtual local area network (Virtual Local Area Network, VLAN) splits up one physical switch into logical networks. The VLAN ID marks which VLAN the traffic belongs to. You got to steer access between VLANs on top of that too.

Video: How a VLAN Splits Up a Physical Network

The video explains how a VLAN divides one physical network into multiple logical networks and separates the traffic between them.

In this example, each VLAN uses its own IPv4 subnet:

VLAN Name Subnet Gateway
10 Administration 10.0.10.0/24 10.0.10.1
20 Employees 10.0.20.0/24 10.0.20.1
30 Students 10.0.30.0/24 10.0.30.1
40 IoT 10.0.40.0/24 10.0.40.1
50 Servers 10.0.50.0/24 10.0.50.1

Subnettin’ real quick

The example’s /24 subnets got 254 regular host addresses (from .1 to .254), includin’ the one the gateway uses. [[Protocols Layer 3 - IP, subnets and default gateways|IPs an’ subnets]] explains how they’re figured out; you don’t needta do that math again fer the firewall practice.

  • 10.0.10.0/24 gives ya addresses from 10.0.10.1 up t’ 10.0.10.254
  • The gateway is usually the first address in line (.1)

Tagged vs. Untagged Traffic

So that VLANs work across multiple switches (or between a switch and router), taggin’ gets used:

Type Description Usage
Untagged (access) The port belongs to one VLAN. The device don’t know nothin’ about VLANs. PCs, printers, phones
Tagged (trunk) The port carries traffic from several VLANs, marked with the VLAN ID. Between switches, toward routers

A regular ol’ PC usually hooks up to an access port without markin’ its own traffic with a VLAN ID. A trunk can carry several allowed VLANs, not necessarily ‘em all. A trunk might also have an untagged, so-called native VLAN. Check out the actual setup on the port profile before you try to figure out where the traffic is headed.

Easy Task 1 - See VLANs in Practice

Got permission to read the network setup in UniFi or another tool? Go check it out without touchin’ a thing:

  • Look at which VLANs are configured
  • Which ports is set as access, and which ones be trunk?
  • Compare the PC’s IP setup with the subnet and port profile. The IP address alone don’t confirm the VLAN membership.

Without admin access: Use the example table. A client has the address 10.0.30.10/24 and gateway 10.0.30.1. Which of the examples subnets does that fit into, and what kind of port would you pick for a regular ol’ PC? Expected answer is the student subnet and an access port on VLAN 30. This here is just interpretin’ the example, not measurin’ your own net.

Firewall Rules Between VLANs

First, describe who is supposed to start a connection, what the destination is, and which protocol/port it uses. A generic label like “employees to servers” is too broad to configure directly. The table is an example policy that must be made specific:

From (source) To (destination) Allowed? Justification
Students Internet ✅ Yes Necessary for teaching
Students Server administration No Student access to an app does not grant rights to server administration
Employees Agreed-upon server services Limited yes Open only the services needed for work
IoT Internet ❌ No (or limited) IoT devices rarely need internet
IoT Students/Employees ❌ No IoT should be isolated
Servers Client that started allowed connection Return traffic A stateful firewall can allow responses on an established connection

Return traffic doesn’t mean the server gets to start new connections to everyone. Rules for established/related and the order of rules must fit the firewall. Traffic between devices in the same VLAN usually doesn’t go through the firewall controlling routing between VLANs.

Standard: block everything, allow what ya need

A good firewall policy starts with blockin’ all traffic between VLANs, and then only openin’ what’s necessary. That’s a whole lot safer than startin’ with everything open and tryin’ to block what ya don’t want.

This here’s the final policy we want, ain’t no call for throwin’ a wide block on first in a network that’s already up an’ runnin’. Keep them needed admin bits, DNS, an’ DHCP while we tweak that limited test setup over there.

Exercise: Client via proxy, not directly to the app

Use these example roles or similar known values from a test environment:

Unit VLAN Address and service
Client 30 10.0.30.10
Proxy 50 10.0.50.10, HTTP on TCP 80
App 50 10.0.50.20, HTTP on TCP 5000

The client should get access to open the app through the proxy, but not directly on the app port. Docker Level 3 shows how the proxy and app are set up and controlled. Write down the plan in its own document:

Source Destination Protocol/port Action Expected control
Client-VLAN 30 Proxy’s address TCP 80 Allow The app’s expected /status response through the app name
Client-VLAN 30 App’s address TCP 5000 Block new connection No direct HTTP connection from the client

In this example, the proxy and app reside in the same VLAN. The connection between them is tested directly, but it isn’t governed by these rules across VLANs. A successful test through the proxy proves the app was reachable via that route; a failed direct test alone doesn’t prove the firewall blocked correctly.

Practical Test in an Approved Testing Environment

Use a already workin’ proxy/app setup. Jot down the usual state and current rules, and keep the console or other admin trail handy so ya can roll back any changes. Check the source, destination, port, direction, and rule order before messin’ with just one limited rule.

From the client side, you test the app name through the proxy. For direct access to the app, you can use:

curl --fail --show-error --connect-timeout 5 --max-time 10 http://10.0.50.20:5000/status

That address is straight from the example; swap it out for your test setup’s app address. Once that block goes in, this client shouldn’t be able to establish an HTTP connection. A timeout could have other causes on top of that; compare the results with the firewall log or rule counter when the tool spits one out, and make sure the app still answers through the proxy while you’re at it. If you get a HTTP 404 or 500 off the app port, that means the HTTP connection made it across, even if curl --fail throws a fit.

Checkpoint: Planned vs. Actual Access

Show both tests with source, target, expected result, and actual outcome. Explain the rule and what the tests confirm. When there’s a discrepancy, check one rule or one traffic path at a time and repeat the verification. Roll back if the change breaks required access.

If you’ve only used the example, mark the results as expected and explain which trials are still outstanding. The plan is set in stone then, but implementation and actual effect ain’t been demonstrated yet. Subnet calculation and DHCP below are optional add-ons after this checkpoint.

Subnettin’

New to prefixes and subnets?

[[Protocols Level 3 - IP, Subnetting & Default Gateway|🌐 IP, Subnetting & Default Gateway]] explains what that prefix actually means before you use it to plan out those VLAN subnets here.

Re-election: Use [[Level 3 Protocols - IP, Subnet, and Default Gateway|IP and Subnets]] when you need to pick a different address range. The numbers below apply to regular IPv4 subnets and show the count of host addresses after the network and broadcast addresses:

Prefix Network Mask Host Addresses Typical Usage
/24 255.255.255.0 254 Most VLANs
/25 255.255.255.128 126 Smaller segments
/16 255.255.0.0 65 534 Large networks

Easy Task 2 - Calculate a Subnet

Optional calculation exercise: Use the method from the IP lookup or a subnet calculator, such as subnet-calculator.com:

  • Enter 10.0.60.0 with mask /24. How many addresses do you get?
  • What happens if you change it to /25? Or /23?
  • Which one would ya pick fer a classroom with 30 students?

Check: /24 gives 254 host addresses, /25 gives 126 and /23 gives 510. Justify yer choice based on all devices that need an address, including the gateway and other gear; the number of students ain’t the whole address requirement.

DHCP per VLAN

Optional lookup: Clients that need to get their IP setup automatic-like require a DHCP that hands out the right settings for the subnet. Static addresses don’t need no DHCP. Network services and server roles explains what DHCP is all about along with reservations.

Here’s an example fer the Student VLAN:

Setting Value
Subnet 10.0.30.0/24
Gateway 10.0.30.1
DHCP-range 10.0.30.100 - 10.0.30.250
DNS The name service that knows the internal app names in the test environment

Summary

  • Segmentation splits the network into parts where traffic can be controlled.
  • A VLAN is a virtual network on the same physical switch.
  • Access ports connect devices to one VLAN; trunk ports carry multiple VLANs.
  • Firewall rules determine what’s allowed between VLANs.
  • In this example, each VLAN has its own subnet; DHCP applies when addresses are assigned automatically.
  • Final policy: block unnecessary traffic and allow agreed-upon services.

Sources: UniFi: access rules and return traffic and access/trunk ports.