VLANS on Home Networks

vlans-home-network-iconIn the early days of networking splitting a network into segments required a router.

VLANS or Virtual LANS is a technology that allows you to split a home network into segments using low cost switches.

Generally a switch will send broadcast traffic to all connected ports, and will allow devices connected on any port to communicate with any other device.



VLANS were created in order to reduce the amount of broadcast traffic on a network.

However on home networks they are used mainly to improve network security.

If we consider a switch with 8 ports as shown in the schematic below.

A broadcast sent from a device attached to any port will be sent to all ports.

standard-switch-broadcasts

In addition any device attached to any port can communicate with any other device attached to any port.

This becomes problematic when you have untrusted devices with access to your network or as in the case of home automation you have IOT devices that are possibly vulnerable to attack.

However with a VLAN capable switch it is possible to restrict broadcasts and to control which devices can communicate with each other.

This makes it possible to design a more secure home network.

If we now take out 8 port switch and split it into two VLANs which we call VLAN1 and VLAN2 as shown below.

VLAN-switch

In this configuration we effectively have created two independent networks. Devices connected to VLAN1 cannot communicate with devices that are connected to VLAN2 and vice versa.

VLAN Uses on A Home Network

The main use is for security where you want to isolate certain machines from the main network.

You will need to choose which devices to use to implement your VLAN and the VLAN mode to use.

VLANs are supported on routers (not all) and on network switches.

On routers the VLANS have different IP subnets.

VLAN Modes

Most devices will support multiple VLAN modes.

The TP link smart switch(TL-SG105E) supports three modes:

  1. MTU VLAN (Multi-Tenant Unit VLAN)
  2. Port Based VLAN
  3. 802.1Q VLAN

which mode you need to use will depend on your network requirements.

MTU VLAN (Multi-Tenant Unit VLAN)

This uses a shared uplink port that is normally connected to the Internet.

The other ports can send and receive data on the uplink port but not between each other as shown in the schematic below:

VLAN-MTU-Schematic

This is very easy to configure as all you really need to do is choose the uplink port (shared port) and enable it.

For example it can be used to:

  • Create an isolated guest network.
  • create an Isolated smart home network.

The schematic below shows the basic layout:

Guest network Vlans

 

Port Based VLANS

In this mode a VLAN can consist of several ports but a port can only exist on one VLAN.

It is used when you want to create an isolated network.

A possible configuration is shown in the schematic below:

VLANs-Using-Port-Mode

In this configuration devices on VLAN 1 can access device connected to ports 1,2 and 3 but not devices connected to ports 4,5 (VLAN 2).

Devices connected to ports 4,5 (VLAN 2 ) can connect to each other and have no internet connection, and cannot connect to devices on VLAN 1

802.1Q VLAN

This is the most flexible mode but also the most difficult one to configure.

The IEEE 802.1Q protocol defines a new format for the Ethernet data frame by inserting a VLAN tag in the data frame data frame as shown in the schematic below:

VLAN-frame

Tagging is used when you have multiple VLAN switches and a distributed VLAN.

As an example imagine you had devices in the living room connected to a smart switch and devices in a home office connected to a second smart switch.

Now you want some devices in the living room to be on the same VLAN.

Because they are physically connected to two different switches you will need to used tagging.

Because this is more complex I will cover it in its own tutorial at a later date but TP-Link include it as an example here.

For this tutorial we will take an example of a single switch with no tagging and configure two VLANs (main and guest ) with both VLANs able to connect to the Internet.

The following schematic is a modified schematic taken from the tplink site here.

vlan-802.1Q

Although we have only two networks (guest and main) we require 3 VLANs.

As port 1 connects the switch to the router all ports need access to this port and so we configure VLAN1 as the default to include all ports.

VLAN2 is the main network and we will use ports 1,2 and 3. VLAN3 is the guest network with ports 1,4 and 5.

tplink-vlan-ports

Now the not very obvious configuration is the PVID settings which must be done for this to work the PVID must match the VLAN ID.

tplink-PVID-settings

TP-Link Router Configuration for Guest Network

This is the configuration I use for a guest network on my home network.

My TPlink Router also supports VLANS, and so I connect my guest network which is in the basement to LAN1 (port1) and assign it to its own VLAN.

There is no option to assign a Wan Interface as it is automatically allowed.

tp-link-archer-router-vlan

This is a schematic of my home network using the TP-link router..

Home-Network-Schematic

Notes:

  • The Wi-Fi router is on the main network VLAN.
  • The Router assigns a different subnet to the second VLAN. The main network uses 192.168.1.0 and the basement VLAN uses 192.168.2.0
  • The basement VLAN has its own WAP

The DHCP server on the router is automatically configured to assign addresses on the new subnet as shown below:

tplink-vlan-router-dhcp

Home Network VLAN Testing

The easiest way of testing is using the ping command.

You should not be able to ping machines on different VLANs.

ping-fail-vlan

DHCP server Notes

The DHCP server must be located on a VLAN that is accessible by all other VLANs which usually means it is on the Internet router.

If you want a VLAN to use a separate DHCP server than the one on the router then you can install one on the VLAN without causing a problem to machines on the other VLANs.

However because a VLAN has a DHCP server it doesn’t prevent it from using the central DHCP server, and you cannot guarantee that a client on the VLAN will get the address from the local DHCP server.

Simple Home network Design Example

Example 1

You have lodgers or a guest house and want to isolate guest machines from your main network but give them access to the Internet.

Your router doesn’t support VLANs and guest Wi-Fi doesn’t have the range. You cannot change the router and both the guest and main network need Wi-Fi access

Solution

You will need a VLAN capable switch to split the network. You will also need to Wireless access points and shouldn’t use the WI-Fi provided by the main router.

A schematic is show below:

example-1-solution

The above solution can be achieved using 802.1Q VLAN or MTU VLAN modes on the switch.

Quick Questions

Referring to the schematic for solution 1 above.

Q1- If you connect a device to the main Wi-Fi router using Wi-Fi will you be able to ping a devices on the guest and main network? Yes or No.

Q2. Will a device on the main network be able to ping a device on the main network? Yes or No.

Q3: The main router also has 3 spare Ethernet ports. Can you use them?

Q4 On what device do you think the DHCP server is located?

Answers

A1 Yes

A2 Yes

A3 If you do it will not be secure.

A4 The main router

Switches With VLAN Support

Usually if the switch is labelled as a smart switch or managed switch it will have VLAN support but you should read the description to be sure.

Below is screen shot from Amazon of a TP-link switch (£30) that supports VLANs.

tp-link-switch-vlan

Summary

VLANs provide an excellent and low cost method of greatly improving you home network security and should be considered if you share your network with guests, and or have IOT devices connected to your Network.

Terms Used in this Tutorial

broadcast traffic– traffic that is end to all hosts(devices) on an network. Many network services rely on this type of traffic e.g ARP and DHCP.

ARP– protocol used to resolve obtain the MAC address of a device using and iP address.

DHCP– Protocol for obtaining an IP address. See Understanding DHCP on Home Networks

Related Tutorials and Resources

Please Let me Know if you found it Useful
[Total: 19 Average: 4.4]

47 comments

  1. Thank you for the article, it is very informative and well written !

    I have a question about the examplary configuration at the end – with router which does not support vlans and a managed switch:

    What would happen if a host in guest network vlan (Attacker Host) tries to reach a host in the main network vlan (Vicitim host), and knows the IP.
    My thinking is – Attacker Host will send ARP for the Victim Host IP and no response will be received (obviuosly since the hosts are not in the same broadcast domain) so the Attacker Host will send the packet to the default gateway. The Router will receive the packet, recognize the Victim Host IP (all the IPs were assigned by the DHCP server on the router) and send the packet back on the same port with the ethernet frame modified to reach the Victim Host.
    The packet enters port 1 on switch and is forwarded by the switch to the Victim Host.

    I think I must be missing something here because I’ve seen the same solution (vlan capable switch + non-vlan router) described on other websites and no security risks like that have been mentioned.

    Any help will be appreciated.
    Thank you.

    1. I assume you are referring to the very last diagram.Generally VLANs on switches use MAC addresses and not IP addresses so filtering is done on the Mac address and not the IP address.The router routes on network address and in this case they are the same and so the router just drops the packet.
      Even if address resolution was successful then the mac address filtering still applies so you wouldn’t expect it to work.
      Rgds
      steve

      1. Yes, I am referring to that last diagram.
        The problem I see with that explanation is:

        1. Regarding the IP address resolution on the router:

        The IP addresses of the host machines in VLAN2 and VLAN3 would not be the same. They would be in the same subnet, assigned by the DHCP server on the router. My understanding is that if HostB sends a packet to the default gateway (the router) with destination IP of HostA then the router would have the IP in its routing table and would route the packet down the same port it received it. I don’t think there’s any reason the packet would be dropped (the scenario assumes a “dumb” router so no extra routing rules).

        2. MAC filtering on the switch:

        In the discussed scenario the MAC address on the frame sent to switch from the router would be the Router MAC address so no filtering rules would apply as traffic between Port 1 and Port 2 is allowed.

        Unfortunately I don’t have the HW to confirm this behavior in real use-case, but due to the aforementioned reasons I think such setup would not work as advertised and is insecure.

        If my assumptions are not correct I’d be happy to find out the exact reasons.
        I was going to go ahead with such setup for my home network but now I think I’ll just by a L3 smart switch which would handle DHCP / subnets / routing between the Vlans.

        Regards,
        Peter

        1. Sorry but I should have been more explicit. I think the diagram is the same as worked example 1 using the switch and no vlans on the router.
          In this case there is only one subnet. at it should work as described and I’m pretty sure I tried it when I wrote the tutorial but it was a little while ago.
          Rgds
          Steve

  2. Great article Steve. Thanks!

    2 things, though:

    1. In your 802.1Q example, its not clear to me why we need vlan1 to encompass all the ports. Wouldn’t only port 1 be sufficient? (This makes it now seem that Host B is on both VLAN3 and VLAN1 at the same time. It looks like we “clear that up” by assigning PVIDs, but I’m just wondering why vlan1 needs port 1-5 when you end up assigning only pvid1 to port1, anyway.)

    2. What’s the advantage of using a vlan-capable router with vlan switches? (I think I know: the ability to route vlan-tagged frames) but I guess what I’m asking is: what type of traffic “routing” (even if it’s just within the same switch) can you accomplish with devices under these 3 scenarios:
    – nothing but managed switches (no routers)
    – managed switches and a dumb router
    – managed switches and a vlan-aware router

    Thanks again!

    1. I agree with you regarding port 1 and I set it up without port 1 only to find it didn’t work and then I read the manual.
      As to point 2 I will need to have a think and I will put it into the tutorial
      rgds
      steve

Leave a Reply

Your email address will not be published.