This is the final part of the router migration with the redirection of external access to go directly to the reverse proxy rather than via the old Draytek.

Current State

Internal users and guests are accessing the internet and other resources via the Mikrotik router without any issues. External users are being forwarded to the Draytek router which is then applying the old forwarding to allow access to selected resources via NAT and a reverse proxy host.

Desired State

Desired stateConnect the Public VLAN to the Mikrotik router and make it the default gateway. Update the NAT forwarding rules to connect directly to the proxy and other accessible systems and not using the Draytek.

The Draytek should only be connected to the Hall VLAN for final admin and for the legacy VPN service until that can be rebuilt using the Mikrotik options. It should be possible switch off the Draytek when it's not in active use.

Move the Public VLAN

The Public VLAN is intended to be the only network which permits access from the internet and is effectively a "demilitarised zone" or DMZ which I can't help feel is an overly dramatic way of saying it's a subnet with only externally visible hosts with very restrictive access so any breach of a host there should not be able to spread to internal hosts.

Define a Bridge VLAN for Public Hosts

The Public VLAN will also use the VLAN trunk on ether5 that we defined in Extend Hall VLAN to Mikrotik Router for Outbound Access to connect to my GeekLab server. Go to Bridge > VLANs and click on New to add the new VLAN.

Define bridge VLAN for Public hosts
Parameter Value
Comment Public
VLAN IDs 180
Tagged
  • ether5

This will be the only connection out of the Mikrotik for the Public VLAN for now.

Define an Interface VLAN for Public Hosts

We want to use the Public VLAN for IP routing to the internet and selected internal hosts, DHCP and DNS so we need to define it as an interface VLAN too. Go to Interfaces > VLAN and click New

Define interface VLAN for Public hosts
Tab Parameter Value
General Name V180-Public
VLAN ID 180
Interface bridge

Add to BasicServices List

We don't want anything talking to the new public connection just yet, so add to the list before we configure anything more. Go to Interfaces > Interface List and click New

Add the VLAN to the BasicServices list.
Parameter Value
List BasicServices
Interface V180-Public

Define an IP Address

We also need to assign an IP address and subnet for the Public VLAN. This will be a straight cutover from the Draytek router, with the the Draytek disconnected from the core VLAN switch before the Mikrotik is connected so we can use the same IPs since they'll never be on the same network at the same time.

The Draytek isn't announcing the Public subnet via RIP from its side and I won't be doing the same on the Mikrotik either so in that respect we're not going to have routing issues.  Although outbound traffic from the Draytek is routed via the Mikrotik, it's been passed though a NAT so the Mikrotik won't know it originated from a Public device. 

Go to IP > Addresses and click New

Add IP address and subnet for the Public VLAN
Parameter Value
Comment Public
Address 192.168.nnn.1/24
Interface V180-Public

Define a DHCP Server

While I have assigned a static IP to the public interface of the proxy servers it will be useful to have DHCP available on the public subnet with a small pool of addresses for deployments for any future hosts I wish to deploy there. I'm going to define the DHCP server for now but leave it disabled until I need it. 

Go to IP > Pool > Pools to define the address pool

Define pool for the Public subnet
Parameter Value
Name public-dhcp
Addresses 192.168.nnn.200-192.168.nnn.254

Go to IP > DHCP Server > DHCP to define the DHCP server for the VoIP subnet.

Disabled DHCP Server config for the public subnet
Tab Parameter Value
General Enabled Unticked
Name public
Interface V180-Public
Lease Time 24:00:00
Address Pool public-dhcp

I don't expect things to change frequently on the Public subnet so setting DHCP leases to 24 hours is quite reasonable.

Go to IP > DHCP Server > Networks to set the basic DHCP options for any future hosts built on the public subnet

Define DHCP settings for the public subnet
Parameter Value
Comment Public
Address 192.168.nnn.0/24
Gateway 192.168.nnn.1
No DNS Untick
DNS Servers 192.168.nnn.1
NTP Servers 192.168.nnn.1

Firewall Rules

Since we have defined the public VLAN as being a member of the BasicServices group we need to add a rule to allow inbound NAT since that the chain ends with an explicit reject. The connection to ether6 for the Draytek got an automatic accept at the end of the forward chain.

Process packets destined for interfaces on the BasicServices list using the basicservices-int chain
Tab Parameter Value
General Comment NAT for RevProxy
Chain int-basicservices
Dst. Address [ IP of proxy host ]
Dst. Port 80,443,465,993

Cutover the Public VLAN to the Mikrotik Router

Although access to hosts on the public VLAN is from the internet and going through the Mikrotik router so in theory there's no worries about triangular routing, the Draytek is doing NAT and having an inbound connection going though two NAT process and the return going back through just one is probably asking for trouble, so this is going to be cutover of all services in one go to keep it simple.

On my core VLAN switch, which links both routers and the GeekLab host together in a star configuration its simply a case of two edits to the VLAN 180 configuration. The first disconnects the VLAN from the port connected to the Draytek. The second connects the VLAN to the port connecting the Mikrotik.

Application NATs

In Preparing the Mikrotik RB5009 router for phased cutover we configured the Mikrotik with six NAT rules to forward ports for HTTP/S, email and Syncthing towards the Draytek router. We can now set those to connect directly to the appropriate host.

For each in turn go to IP > Firewall > NAT and update the destination address.

Update NAT destination to point to reverse proxy server
Tab Parameter Old Value New Value
Action To Address 192.168.69.2 [IP of proxy interface on public VLAN]

Unsurprisingly Syncthing had already bypassed the Draytek when I updated default routes from my internal network to use the Mikrotik for internet access since it can do NAT traversal and find peers itself using the Relay WAN mode. The advantage of setting up a NAT is it allows faster TCP WAN direct connections. Reconfiguring the NAT for this is the same process as the others apart from using the IP address of the Syncthing server instead.

Testing

With the Public VLAN connected to the Mikrotik and the NAT repointed it's time to test. To do this properly I need a host that's on the internet for a complete end-to-end which these days is really easy using a mobile phone with Firefox to test access to the Nextcloud server and Thunderbird to test mail access. That took all of two minutes to prove both worked.

If you want to do it properly, or need to diagnose a fat-finger typo, then you can use the Statistics tab on the IP > Firewall > Filter Rules or NAT to see if traffic is passing through or not. If you want detail then enable logging too. Another useful quick check is IP > Firewall > Connections with a filter of "Src. Address not in 192.168.0.0/24" to show all external IPs and what they're connecting to.  The internal hosts will show up in the Reply Src. Address column, with Src. Address showing the address of the connecting device.

Summary

And with the public access now being handled directly by the Mikrotik router we are now substantially complete in our migration and I can now switch off the old Draytek router.

I still need to move the VPN service over but that's a complete redesign as I was using the Draytek proprietary SSL VPN and Mikrotik provide different VPN options. As an interim I can turn on the Draytek (before I leave home obviously!) if I need to have remote access. I generally only use that when on public WiFi hotspots since mail and Nextcloud are accessed via TLS encryption.

I was also thinking that I should capture the process for a RouterOS upgrade at some point, either on the next update to the 7.21 LTS version or switching to the standard track and start playing with the latest versions of everything. Then a few days ago while I was doing the writeup of the previous article news broke of a Security vulnerablitly in Mikrotik RouterOS so I'll be doing that for real tomorrow, which probably translates as a couple of days ago by the time this gets published.

Notes

This was article was written with reference to a Mikrotik RB5009 running RouterOS 7.21.5 using WinBox 4.3 and a Draytek Vigor 2862. I expect this to be broadly similar for equivalent products and later versions but that cannot be guaranteed.