Switching 101 - DHCP, VLAN/tagging, NAT

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.

Switching 101 - DHCP, VLAN/tagging, NAT

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
Switching 101 - DHCP, VLAN/tagging, NAT
Switching 101 - DHCP, VLAN/tagging, NAT
2019-10-19 02:58:11
Hardware Version: V3
Firmware Version: 3.0.3

Yay, I got my first switch ever! (And I'm not talking about the Nintendo one, that one was easy to figure out!)

 

So Cable Modem > ISP Cheap Router > Switch

 

For the sake of being clear, here's how I filled my ports:

1/0/1: ISP router (I need to change that, it's slow as hell)

1/0/2: (RESERVED) LAG w/ port 1 with future router

1/0/3: NAS

1/0/4: (RESERVED) NAS LAG

1/0/5: EAP245

1/0/6: (RESERVED) Future AP

1/0/7: Home-Assistant

1/0/8: (RESERVED) Testing OpenWRT on Pi

----

1/0/9: VoIP Box

1/0/11: PC 1

1/0/12: PC 2

 

I change the VLAN 1 interface IP to 192.168.0.2 to avoid conflict with the router and access the switch without a static IP.

 

At first I thought I could use the built-in DHCP server to assign IPs to my devices and just use the router for NATing, but someone on Reddit told me that it doesn't work like that.

Note that I spent 6 hours and 15 resets, trying stuff out, the manual on one screen and my cellphone in my hand. I played a lot with tagging and DHCP, but didn't get anything good (read: working)

 

I created VLAN 49 with 1/0/1,1/0/9 for my VoIP. (both untagged). I'm not sure I understand the tagging thing even after some research.

 

The mian things I'd like to accomplish is:

- I'd like to create a VLAN with a public access point from the EAP245, isolated from the rest of the network;

- Another that can only access my Home-Assistant server for IoT devices (No internet for IoT but the HA server needs internet).

- Make things secure: I'd like the VoIP to be isolated, everything IoT to have no internet, guest wifi to only have WAN access, etc

- Eventually I'll get a "cheap" ~450 CAD Qotom router, but right now the router I have range between 20% and 100% CPU usage. Is there any way I can lighten it's workload?

 

Sidenote, my "older" router, a Netgear, died two weeks ago. After nearly 2 weeks of research, I love the TP-Link interface (thanks because openwrt is not compatible with the AP). the range of the EAP245 is awesome (I compared a lot of AP)

 

Best wishes

  0      
  0      
#1
Options
5 Reply
Re:Switching 101 - DHCP, VLAN/tagging, NAT
2019-10-19 15:12:44 - last edited 2019-10-19 15:19:41

Extarys wrote

At first I thought I could use the built-in DHCP server to assign IPs to my devices and just use the router for NATing, but someone on Reddit told me that it doesn't work like that.

 

Why should it not work?

 

- I'd like to create a VLAN with a public access point from the EAP245, isolated from the rest of the network;

- Another that can only access my Home-Assistant server for IoT devices (No internet for IoT but the HA server needs internet).

- Make things secure: I'd like the VoIP to be isolated, everything IoT to have no internet, guest wifi to only have WAN access, etc

- Eventually I'll get a "cheap" ~450 CAD Qotom router, but right now the router I have range between 20% and 100% CPU usage. Is there any way I can lighten it's workload?

 

1. To create a true isolated guest network you should use two separate networks on your router assigned to two firewall zones. If the router is VLAN-aware, you need only one cable connection to the switch. If it's not VLAN-aware, but lets you assign the built-in port to different networks (local / guest), you can use two cable connections to the switch. Note that EAPs have a built-in function for creating guest networks which just enable wireless client isolation and ACLs denying access to private IPs. This does not require two subnets, but can share the same broadcast domain (I call this »poor man's guest net«). True isolation requires two separate broadcast domains with two SSIDs assigned to separate VLANs.

 

2. Same as 1. For true isolation of an IoT network, create a third network on the router. I use a separate IoT net to isolate Kasa smart devices to a purely local network w/o Internet access. You need to trick the Kasa devices so that they connect to your router's NTP time server when they try to reach the NTP server defined in the Kasa firmware (IIRC, it's 0.cn.pool.ntp.org) in order to still use scheduled actions in an isolated network. Also, some »smart« functions requiring cloud access won't work.

 

3. T1600G-28TS has a Voice VLAN setting (see QoS menu). I don't use VoIP phones, so I have no experience with a Voice VLAN, but you might find details in the User's Guide.

 

4. I recommend OpenWRT routers and/or EdgeRouter-X. The latter runs EdgeOS (based on Debian Linux) and has a very good NAT throughput of ~900 Mbps if hardware off-loading is enabled (it's disabled in factory defaults). What's more, it's possible to install OpenWRT on ER-X. Both, OpenWRT and EdgeOS let you easily create different networks as well as different DHCP server pools and are VLAN-aware, so they can be connected to the T1600G using one cable over a trunk (that's tagged) port.

 

In general, VLANs are just a way to carry traffic for different networks (the VLANs) over one physical router/cable/switch/AP. Isolation between networks is just a logical consequence of using same physical transport for different networks.

 

Just imagine you would have two (or more) networks with two routers, two switches and two sets of APs and then create two network topologies for those two networks. Next, assign both networks two VLAN IDs and reduce the devices to only one router, one switch and one set of APs which all need to be VLAN-aware. This is - in my opinion - the most easy way to set up VLANs.

 

 

༺ 0100 1101 0010 10ཏ1 0010 0110 1010 1110 ༻
  0  
  0  
#2
Options
Re:Switching 101 - DHCP, VLAN/tagging, NAT
2019-10-20 17:01:59 - last edited 2019-10-20 17:03:11

@R1D2 Thanks for taking the time to write this.

 

I've been trying hard to use the built-in DHCP server while having the router do NAT. That is when someone on reddit told me I couldn't. But I'm sure there is a way to use the DHCP server in the switch and still use NAT. Here are the steps I took.

 

For testing, I created a VLAN 114 with SSID Guess on the EAP245.

I created VLAN 113 on the T1600G with port 1 untagged (port 1 goes to the router) and port 5 tagged (EAP)

I created a new interface for VLAN 114, Static IP 10.1.114.1.

I also enabled the DHCP server and created a pool with the network address 10.1.114.0 (Gateway 10.1.114.1)

In DHCP L2 Relay, I checked 'Enabled' and enabled the VLAN 114.

 

My phone receive an IP address (10.1.114.2) but the device does not have internet access. It seems to be isolated from the rest of the LAN too, which is good.

 

How can I use the router for NATing while using the switch as DHCP server in this case then?

 

I did manage the QoS for the VoIP, there is no reliable way to test it but the settings are set, so.

  0  
  0  
#3
Options
Re:Switching 101 - DHCP, VLAN/tagging, NAT
2019-10-20 20:16:18 - last edited 2019-10-20 20:34:42

 

Extarys wrote

My phone receive an IP address (10.1.114.2) but the device does not have internet access. It seems to be isolated from the rest of the LAN too, which is good.

 

You need to set the DNS server(s), too, in order to be able to use DNS names. Just try to ping the router, if this works, then test next steps until you come to test Internet access, not the other way around.

 

Next is DHCP relay, why do you enable this? Just bind the DHCP to your guest VLAN, that's all what's needed IMO.

 

My T1600G-28TS is hardware V1 whose firmware (unfortunately) does not have a DHCP server, so I can't test it.

 

How can I use the router for NATing while using the switch as DHCP server in this case then?

 

 

NAT has nothing to do with DHCP, both are completely different services.

 

Your router should be able to do NAT (for address translation of LAN IPs to a public IP) without having to assign those LAN IPs via DHCP first if there is already another DHCP server in the subnet which does this, else staticcally assgined IPs wouldn't work at all.

 

I know that there seems to be some confusion on part of other people re NAT and DHCP (see here for example), so probably this confusion comes from home routers which mix both terms somehow.

༺ 0100 1101 0010 10ཏ1 0010 0110 1010 1110 ༻
  0  
  0  
#4
Options
Re:Switching 101 - DHCP, VLAN/tagging, NAT
2019-10-21 01:41:19

@R1D2 Yes, sorry I set the DNS server in the pool for 1.1.1.1

 

I can ping 10.1.114.1 but not the router 192.168.0.1.

 

Here is the VLAN configuration:

 

Port 5 is the EAP is I use it for main wifi, guest wifi (VLAN 114) and IoT devices (VLAN 113).

 

I'm very glad mine is V3 then. Also, thanks for clarifying NAT, there is a lot of contradicting information out there.

 

  0  
  0  
#5
Options
Re:Switching 101 - DHCP, VLAN/tagging, NAT
2019-10-21 07:24:33 - last edited 2019-10-21 08:02:45

Why is your router connected to an untagged port? How should it handle the 10.1.114.0 subnet then?

 

 

»Normal« setup of a Guest Network

 

That's how I set up a guest network usually (switch omitted b/c of clarity):

 

 

Here the EAPs assign Ethernet frames coming in from two different SSIDs to 2 isolated VLANs 1 and 2. The router then needs to separate traffic in both VLANs into two LANs 1 and 2 again. The switch (not shown) just forwards traffic from both VLANs from EAP to the router and back again from the router to the EAP.

 

As I wrote: your router needs to handle the 10.1.114.0 subnet (VLAN 114) too if you want two isolated separate subnets.

 

 

Alternative setup of a Guest Network

 

Now, if you have only one network defined on your router (192.168.0.0) and want to use VLANs only to isolate local, guest and IoT devices sharing the same subnet, you would have to:

  • only use on subnet (192.168.0.0), but four VLANs (say 1, 2, 113, 114),
  • assign the router's untagged port a primary VLAN ID of 1 (PVID) and membership of VLANs 1, 2, 113 and 114,
  • assign the port(s) of VLAN 2 (LAN) a primary VLAN ID of 2 (PVID) and membership of VLANs 1 and 2,
  • assign the port(s) of VLAN 113 (IoT) a primary VLAN ID of 113 (PVID) and membership of VLANs 1 and 113,
  • assign the port(s) of VLAN 114 (guests) a primary VLAN ID of 114 (PVID) and membership of VLANs 1 and 114,
  • create firewall rules on the router that deny traffic from the IoT VLAN to the Internet (WAN).

 

Thus, in this solution VLANs are terminated in the switch, not in the router (VLANs only exist internally and they always need to lead into a network at the end):

 

 

  • This way, Ethernet frames in the LAN VLAN reach the router through VLAN 2, but traffic from the router travels back through VLAN 1.
  • Frames from the IoT VLAN reach the router through VLAN 113, but traffic from the router travels back through VLAN 1.
  • Frames from the guest VLAN reach the router through VLAN 114, but traffic from the router travels back through VLAN 1.

 

In addition, if you use wireless client isolation in the EAP (setting »Guest Network« option), this setting also enables ACLs to deny traffic to private IPs. You have to add an ACL to exclude certain IPs from being blocked if you want to reach IoT devices from the LAN network. In addition, you need to ensure that the router doesn't route IoT traffic to the Internet (WAN), while traffic from the local and guest networks needs to be able to reach the Internet.

 

That's what I called the »poor man's guest network« solution in my first reply to your post – it uses the same broadcast domain for all devices, since there is only one network.

 

In my opinion this makes setup much more complicated than using three cleanly isolated networks on the router assigned to three VLANs (avoids the default VLAN then completely).

 

And BTW, this is the reason why in my opinion the newly introduced »Guest Network« setting in Omada controller for a simple thing as wireless client isolation complicates things further instead of making life more easy.

 

 

Do yourself a favour and set up different networks on a Linux router such as OpenWRT. It's very easy to do so and it provides a clean isolation between the different subnets. Also, access control using the zone-based firewall in OpenWRT is very easy.

 

 

 

 

༺ 0100 1101 0010 10ཏ1 0010 0110 1010 1110 ༻
  0  
  0  
#6
Options

Information

Helpful: 0

Views: 2356

Replies: 5

Related Articles