├── LICENSE ├── README.md ├── assets ├── CF-ZeroTrust-Access-portal.png ├── Portal-Advanced-settings.png ├── Settings-Advanced-mDNS.png ├── Settings-Networks-home.png ├── Settings-Networks.png ├── Settings-Security-Groups.png ├── Settings-Security-Rules.png ├── Settings-Wifi-home.png ├── UDM-P_logical_network.png ├── UDM-P_logical_network.svg └── UDP-Pro-topo.png └── configuration ├── 1-UDM-Pro-Setup.md ├── 2-Backhaul-switches-APs.md ├── 3-Networks.md ├── 4-Wifi.md ├── 5-Firewall-rules.md └── 6-Cloudflare-tunnel.md /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Prosumer network configuration using Unifi/Ubiquiti gear 2 | 3 | [Ubiquiti](https://www.ui.com/) is a creative and proliferate producer of really cool networking gear 4 | at reasonably attractive prices. 5 | But what they are ahead in hardware and software, they lack on documentation. 6 | The basics are documented in their help pages, but many of the more involved 7 | networking configurations have gaps. 8 | 9 | This repo was initially intended to capture and document my own home network's configuration. Hope is, this 10 | will also help others in their quest for a more solid networking experience. 11 | 12 | ## Goals 13 | 14 | - run a reliable, secure and well performing home network with little complaints from my customer base (aka spouse & family) 15 | - design with Principle of Least Privilege (PoLP). 16 | One definition by [NIST, see page 91](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-12r1.pdf) 17 | - keep my customer base reasonably sheltered from online privacy mining and spying. 18 | - allow me to tinker and learn, hence this network setup is indeed over-engineered. 19 | A simple modern ISP's router & gateway could get the basic job done (but would be less fun to interact with). 20 | 21 | ## Design choices 22 | 23 | Disclaimer: I have no relationship with, no sponsoring from nor financial interests in Ubiquiti, 24 | I'm just a mostly happy customer of their products. 25 | 26 | About ~10 years ago, I discovered Ubiquiti's prosumer networking hardware that is indeed disruptive, 27 | for the price they are able to offer their hardware. My journey with UI started with just an AP or 2, 28 | combined with an EdgeRouterLite 3, adding a couple PoE capable switches to it over time. 29 | This summer I finally took the plunge to replace my ERL3 (which started to exhibit some 30 | thermal stability issues) with the UDM Pro [Unifi Dream Machine Pro](https://www.ui.com/consoles/) 31 | 32 | ### Basic topology 33 | 34 | This is the current physical wired topology, with the UDM-Pro as the gateway, 35 | and one PoE-enabled UI switch on each floor. House ethernet wiring is good for up to 1 Gbit/s, 36 | with all runs made in CAT5e; same for patch cables. 37 | 38 | ![backhaul topo](/assets/UDP-Pro-topo.png) 39 | 40 | ### Network segmentation 41 | 42 | Following the Least Privilege principle, the LAN is separated into multiple logical segments, using 43 | VLANs: 44 | | VLAN | CIDR | Medium | SSID | Purpose | 45 | | ---: | ---: | ------ | ---- | ------- | 46 | | 1 | 10.0.90.0/24 | Wired 1GbE | n/a | backhaul, management | 47 | | 10 | 10.0.10.0/24 | Wired/Wireless | jenni.ap | trusted home net | 48 | | 20 | 10.0.20.0/24 | Wireless | jenni.guest | guests, internet only | 49 | | 30 | 10.0.30.0/24 | Wireless | jenni.iot | IoT devices, internet only | 50 | | 40 | 10.0.40.0/24 | Wireless | jenni.media | media devices, internet only | 51 | | 50 | 10.0.50.0/24 | Wired | n/a | PoE camera devices, no internet | 52 | 53 | For my network, I chose ranges from the 10/8 private address space, feel free to pick different ranges 54 | from [RFC1918](https://datatracker.ietf.org/doc/html/rfc1918), e.g. from the 172.16/12 or 192.168/16 ranges. 55 | I find it useful to reflect the sub range, e.g. ```.10.*```, to also be the VLAN id, but there is no 56 | technical need to do so. 57 | 58 | Note the 5 switches shown below are purely logical; the physical HW has the UDM and the 2 switches above. 59 | By default, the UDM Pro allows full inter-VLAN access, but this site's configuration will by default block 60 | any inter-VLAN connectivity, and only allow the trusted ```home (10)``` VLAN to initiate connections to the 61 | ```IoT (30)``` and ```media (40)``` VLANs. Access from/to the ```management (1)``` LAN and trunk is 62 | not allowed from any VLAN; sole exception is allowing access to the UDM-P itself from the ```home (10)``` (10.0.10.1). 63 | 64 | Details see [Firewall](#Firewall) 65 | 66 | ![logical network](assets/UDM-P_logical_network.svg) 67 | diagram created with: 68 | 69 | ## Configuration 70 | 71 | - [Initial Setup of UDM-Pro](/configuration/1-UDM-Pro-Setup.md) 72 | - [Backhaul: Switches, AccessPoints](/configuration/2-Backhaul-switches-APs.md) 73 | - [Define networks](/configuration/3-Networks.md) 74 | - [Define WiFi](/configuration/4-Wifi.md) 75 | - [Firewall groups and rules](/configuration/5-Firewall-rules.md) 76 | - [Cloudflare tunnel to LAN](configuration/6-Cloudflare-tunnel.md) 77 | -------------------------------------------------------------------------------- /assets/CF-ZeroTrust-Access-portal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/CF-ZeroTrust-Access-portal.png -------------------------------------------------------------------------------- /assets/Portal-Advanced-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/Portal-Advanced-settings.png -------------------------------------------------------------------------------- /assets/Settings-Advanced-mDNS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/Settings-Advanced-mDNS.png -------------------------------------------------------------------------------- /assets/Settings-Networks-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/Settings-Networks-home.png -------------------------------------------------------------------------------- /assets/Settings-Networks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/Settings-Networks.png -------------------------------------------------------------------------------- /assets/Settings-Security-Groups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/Settings-Security-Groups.png -------------------------------------------------------------------------------- /assets/Settings-Security-Rules.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/Settings-Security-Rules.png -------------------------------------------------------------------------------- /assets/Settings-Wifi-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/Settings-Wifi-home.png -------------------------------------------------------------------------------- /assets/UDM-P_logical_network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/UDM-P_logical_network.png -------------------------------------------------------------------------------- /assets/UDM-P_logical_network.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/UDP-Pro-topo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidjenni/udm-pro-network/023c85fc0b84bf93078ade726d155b253c9879f2/assets/UDP-Pro-topo.png -------------------------------------------------------------------------------- /configuration/1-UDM-Pro-Setup.md: -------------------------------------------------------------------------------- 1 | # Setting up the UDM-Pro 2 | 3 | ## Setup wizard and assign IP address 4 | 5 | Not going into too many details, there's good documentation on how to run through the UDM-Pro setup wizard: 6 | 7 | - [Unifi Network - Getting Started](https://help.ui.com/hc/en-us/articles/360012192813) 8 | - [Setup Network Application](https://help.ui.com/hc/en-us/articles/1500012237441-UniFi-Network-Use-the-UniFi-Network-Application) 9 | - [CrossTalk Solutions - Initial Wizard Setup](https://youtu.be/beniNcXaAKQ?t=248) 10 | 11 | To make the initial configurations, plug in your PC or laptop directly into one of the ports on the UDM-Pro; 12 | configure your PC/laptop/MBP to acquire DHCP addresses. Open a browser at 13 | 14 | Even though in my network, I plan on using a 10/8 private network, I started running the initial setup of 15 | UDP-Pro and adopting the Unifi devices from the UDM-P's default ```192.168.1.1``` address. Run through the 16 | wizard to connect to your ISP, update the UDM-P and adopt any switches and APs you have. 17 | 18 | Note that you need to initially login to UDM-Pro with a SSO login from UI.com: 19 | 20 | The setup here assumes a local DNS server, I am using a [Pi-hole DNS server](https://pi-hole.net/) on ```10.0.90.42``` 21 | 22 | Once you've logged in to your UDM-Pro using the SSO login, best practice is to add a local admin and set the following under: 23 | ```Portal | Advanced```: 24 | 25 | ![Portal-Advanced-Settings](/assets/Portal-Advanced-settings.png) 26 | 27 | Enable SSH and set your strong SSH password (you do keep all your passwords in a password manager like 1Password, right?) 28 | While here, also ensure that ```Remove Access`` is now disabled (unless you want to enable remote configuration of your site via UI's cloud). 29 | 30 | Once the Unifi devices have been adopted, switch the UDM-Pro to your desired IP address, in my case: 31 | ```10.0.90.1``` by navigating to [Network App | Settings | Networks](https://10.0.90.1/network/default/settings/networks) 32 | Change the **LAN** network to: 33 | 34 | | Label | Value | 35 | | ----- | ----- | 36 | | Enable Network | on | 37 | | Name | ```mgmt-90``` | 38 | | Advanced | | 39 | | VLAN ID | leave empty | 40 | | Device Isolation | off | 41 | | IGMP Snooping | off | 42 | | Auto Scale Network | off | 43 | | DHCP Mode | DHCP Server | 44 | | Gateway IP/Subnet | ```10.0.90.0/24``` | 45 | | DHCP Range | 10.0.90.100 - 10.0.90.254 | 46 | | DHCP Name Server | Manual 47 | | | 10.9.0.42 | 48 | | DHCP Lease Time | 7200 | 49 | | DHCP Gateway IP | Auto | 50 | 51 | Leave all the other settings on their default/OFF settings. 52 | 53 | Apply/save those settings and reconnect to the UPM-Pro on the new IP address: 54 | 55 | # Enable mDNS 56 | 57 | To better support e.g. Chromecast or Apple cast, enable multicast DNS to better connect to media devices: 58 | 59 | Go to [Network App | Settings | Advanced Features | Advanced Gateway Settings | Multicast DNS](https://10.0.10.1/network/default/settings/advanced/gateway/mdns/form) 60 | 61 | ![enable mDNS](/assets/Settings-Advanced-mDNS.png) 62 | -------------------------------------------------------------------------------- /configuration/2-Backhaul-switches-APs.md: -------------------------------------------------------------------------------- 1 | # Backhaul physical network 2 | 3 | CAT5e cabling between the UDM to the managed switches and Unifi access points creates the 4 | physical backbone of the network: 5 | 6 | ![backhaul topo](/assets/UDP-Pro-topo.png) 7 | 8 | The cabling between UDM, switches and the APs are all part of the untagged, native LAN. 9 | Since that portion of the network carries multiple VLANs, it's also referred to as *trunked connections*. 10 | 11 | All managed Unifi switches and Unifi Access Points acquire their IP address via DHCP. 12 | 13 | ## Port Profiles 14 | 15 | | Profile Name | Native Network | Tagged Networks | 16 | | ------------ | -------------- | --------------- | 17 | | OFF | none | none | 18 | | mgmt-90 | mgmt-90 | none | 19 | | mgmt | mgmt-90 | mgmt (90) | 20 | | Wired-VLANs | mgmt-90 | home (10), guest (20), IoT (30), media (40), camera (50) | 21 | | Wireless-AP-VLANs | mgmt-90 | home (10), guest (20), IoT (30), media (40) | 22 | 23 | ## Managed switches 24 | 25 | ### UDM-Pro 26 | 27 | | Port | Link name | Profile Name | 28 | | ---: | --------- | ------------ | 29 | | 1 | to US-8-150W-garage | Wired-VLANs | 30 | | 3 | to US-8-60W-office | Wired-VLANs | 31 | | 8 | direct mgmt access (laptop) | mgmt | 32 | | 9 | uplink to T-Mobile ISP | All | 33 | 34 | All unused ports are configured with profile *OFF* 35 | 36 | ### US-8-150W-garage 37 | 38 | | Port | Link name | Profile Name | PoE | 39 | | ---: | --------- | ------------ | --- | 40 | | 1 | AP-LivingRoom | Wireless-AP-VLANs | PoE/PoE+ | 41 | | 2 | AP-Studio | Wireless-AP-VLANs | PoE/PoE+ | 42 | | 3 | AP-garage | Wireless-AP-VLANs | 24V Passive | 43 | | 9 | Uplink to UDM | Wired-VLANs | (SFP 1GbE) | 44 | | 10| downlink to Netgear GS108 | All | (SFP 1GbE) | 45 | 46 | All unused ports are configured with profile *OFF* 47 | 48 | ### US-8-60W-office 49 | 50 | | Port | Link name | Profile Name | PoE | 51 | | ---: | --------- | ------------ | --- | 52 | | 1 | uplink to UDM | Wired-VLANs | none | 53 | | 2 | mgmt-office | mgmt-90 | none | 54 | | 3 | home-office | home (10) | none | 55 | 56 | All unused ports are configured with profile *OFF* 57 | 58 | ## Access Points 59 | 60 | ### WiFi Networks 61 | 62 | All APs connect via trunk (mgmt-90) as management LAN 63 | 64 | | SSID | Network | WiFi bands | Sec Protocol | Extras | 65 | | ---- | ------- | ---------- | ------------ | ------ | 66 | | jenni.ap | home (10) | Both | WPA-2/WPA-3 | Hi Perf Devices | 67 | | jenni.guest | guest (20) | Both | WPA-2/WPA-3 | L2 Isolation | 68 | | jenni.IoT | IoT (30) | 2.4 GHz | WPA-2 | Multicast Enhancement | 69 | | jenni.media | media (40) | Both | WPA-2/WPA-3 | Multicast Enhancement | 70 | -------------------------------------------------------------------------------- /configuration/3-Networks.md: -------------------------------------------------------------------------------- 1 | # Networks 2 | 3 | Time to create the networks and VLANs under [Networks](https://10.0.10.1/network/default/settings/networks): 4 | 5 | | network name | CIDR range | VLAN id | 6 | | ------------ | ---------- | ------- | 7 | | home | 10.0.10.0/24 | 10 | 8 | | guest | 10.0.20.0/24 | 20 | 9 | | iot | 10.0.30.0/24 | 30 | 10 | | media | 10.0.40.0/24 | 40 | 11 | | camera | 10.0.50.0/24 | 50 | 12 | 13 | Personal preference on the IP range starting IP address: For most VLANs, I prefer to reserve the 14 | first ~30-50 IP addresses for any static assignments. 15 | 16 | ![home network settings](/assets/Settings-Networks-home.png) 17 | 18 | Here's the resulting list of networks: 19 | 20 | ![all network settings](/assets/Settings-Networks.png) 21 | -------------------------------------------------------------------------------- /configuration/4-Wifi.md: -------------------------------------------------------------------------------- 1 | # Wifi networks 2 | 3 | To create/configure Wifi networks, goto [Wifi](https://10.0.10.1/network/default/settings/wifi) 4 | 5 | The most relevant setting is to set the name, e.g. ```jenni.ap``` and select the corresponding 6 | network, here: ```home``` 7 | 8 | ![Settings Wifi home / jenni.ap](/assets/Settings-Wifi-home.png) 9 | 10 | Under the *Advanced* tab, accept most of the defaults, except for these: 11 | 12 | | Wifi name | Setting | Value | 13 | | --------- | ------- | ----- | 14 | | *.ap | High Performance Devices | ON | 15 | | *.guest | L2 Isolation | ON | 16 | | *.IoT | Wifi Band | 2.4 GHz only (since most IoT have no 5 GHz support) | 17 | | *.media | Multicast Enhancement | ON | 18 | -------------------------------------------------------------------------------- /configuration/5-Firewall-rules.md: -------------------------------------------------------------------------------- 1 | # Firewall 2 | 3 | ## Groups 4 | 5 | To make the firewall rules easier to read and manage, set up the following groups in 6 | [Settings | Security | Internet Threat Management | Firewall ](https://10.0.10.1/network/default/settings/security/threat-management) 7 | 8 | under *Groups*, enter the following: 9 | 10 | | Name | Type | Values | 11 | | ---- | ---- | ------ | 12 | | All local LANS | IPv4 Address/Subnet | 10.0.10.0/24, 10.0.20.0/24 10.0.30.0/24, 10.0.30.0/24, 10.0.50.0/24 | 13 | | Home Devices (low trust) | IPv4 Address/Subnet | 10.0.30.0/24, 10.0.530.0/24 | 14 | | Local DNS | IPv4 Address/Subnet | 10.0.90.42 | 15 | | Low Trust LANs | IPv4 Address/Subnet | 10.0.20.0/24, 10.0.30.0/24, 10.0.40.0/24, 10.0.50.0/24 | 16 | | RFC1918 | IPv4 Address/Subnet | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | 17 | | Trusted LANs | IPv4 Address/Subnet | 10.0.10.0/24 | 18 | | UDM in local LANs | IPv4 Address/Subnet | 10.0.10.1/24, 10.0.20.1/24, 10.0.30.1/24, 10.0.40.1/24, 10.0.50.1/24, 10.0.90.1/24 | 19 | 20 | And some port groups: 21 | 22 | | Name | Type | Values | 23 | | ---- | ---- | ------ | 24 | | DHCP | Port Group | 67 | 25 | | DNS | Port Group | 53 | 26 | | NTP | Port Group | 123 | 27 | | UDM mgmt ports | Port Group | 22, 80, 443 | 28 | 29 | The resulting groups look like: 30 | 31 | ![Firewall groups](/assets/Settings-Security-Groups.png) 32 | 33 | # Rules 34 | 35 | **NOTE**: Before adding rules, make sure you do have a UDM-Pro backup! Any mistakes or misconfiguration can 36 | lead to a lock out, where your PC/laptop can no longer reach the UDM-Pro! 37 | 38 | By default, the UDM-Pro has full inter-VLAN communications enabled. Firewall rules are evaluated in order, 39 | i.e. once an earlier allow or block rule is matched, the remaining rules are skipped. Best practice is to 40 | list allow rules with concise match criteria first, followed by block rules that block whatever wasn't matched 41 | before. 42 | 43 | Most rules are for *LANin* (i.e. traffic from the LAN segment into the router/gateway), 44 | with a few for *LANlocal*, i.e. traffic within the LAN segment) 45 | 46 | ![Firewall rules](/assets/Settings-Security-Rules.png) 47 | 48 | Rules for *LAN IN*: 49 | 50 | | Index | Type | Description | Action | IPv4 Protocol | Source | Destination | Advanced | 51 | | ----- | ---- | ----------- | ------ | ------------- | ------ | ----------- | -------- | 52 | | 2000 | LANin | allow established /related | Accept | All | Any | Any | Match Established, Related | 53 | | 2001 | LANin | allow all local to NTP | Accept | UDP | All local LANs | Any | .. | 54 | | 2002 | LANin | allow Local DNS for all LANs | Accept | TCP, UDP | All local LANs | Group: Local DNS; Port: DNS | .. | 55 | | 2003 | LANin | allow ping to Local DNS | Accept | ICMP | All local LANs | Local DNS | .. | 56 | | 2004 | LANin | allow trusted to devices | Accept | All | Trusted LANs | Home Devices (low trust) | Enable logging | 57 | | 2005 | LANin | Allow DNS admin from Trusted LANs | Accept | All | Trusted LANs | Group: Local DNS; Port: UDM mgmt ports | 58 | | 2006 | LANin | block inter-LAN | Drop | All | RFC 1918 | RFC1918 | Enable logging | 59 | 60 | Rules for *LAN LOCAL*: 61 | 62 | | Index | Type | Description | Action | IPv4 Protocol | Source | Destination | Advanced | 63 | | ----- | ---- | ----------- | ------ | ------------- | ------ | ----------- | -------- | 64 | | 2000 | LANlocal | drop invalid state | Drop | All | Any | Any | Match Invalid | 65 | | 2001 | LANlocal | Block UDM from low trust LANs | Drop | All | Low Trust LANs | Group: UDM in local LANs; Port: UDM mgmt ports | Enable logging | 66 | -------------------------------------------------------------------------------- /configuration/6-Cloudflare-tunnel.md: -------------------------------------------------------------------------------- 1 | # Cloudflare tunnel to LAN 2 | 3 | A safe way to make LAN/home internal http nodes reachable from the internet, 4 | using cloudflare's [Zero Trust Network Access](https://www.cloudflare.com/plans/zero-trust-services/). 5 | The 'Free Plan' is sufficient for personal, non-business use. 6 | 7 | The Cloudflare tunnel is a variation of a VPN. Since the tunnel connection is initiated from within the local network, 8 | no DDNS setup nor opening of VPN ports is required at the local UDM gateway. 9 | 10 | This setup assume you already own one or more registered internet domains. 11 | 12 | ## Create tunnel in cloudflare 13 | 14 | - [Create/login to cloudflare dashboard](https://dash.cloudflare.com/login) 15 | - add your existing domain name as "Website" to the CF dashboard (select the free plan for private usage). This imports the DNS settings from the registrar's DNS (but does leave the actual registration at the existing registrar). It's ok to have no A/CNAME etc records at CF. 16 | - from your registrar's DNS management page, replace the nameserver entries with what CF's dashboard asks for, e.g. `alec.ns.cloudflare.com` 17 | - wait until CF dashboard for the domain shows NS change has been validated (should also trigger an email from CF) 18 | 19 | - from CF ZeroTrust dashboard, select "Access" | "Tunnels"; create a new tunnel 20 | - from the next step, the "Install connector" step, select "Docker" and copy the docker run incantation. 21 | 22 | ## Docker host, e.g. using Synology NAS' docker host 23 | 24 | - from Synology's "Package Manager", add "Docker" package, and launch/open that 25 | - under "Registry", search the `cloudflared` docker image and download it 26 | - under "Image", select & launch the `cloudfared` image; in the "Network" step, select "Use the same network as Docker Host" option 27 | - under "General Settings": 28 | - set a container name, e.g. `-cloudflared` 29 | - check "Enable auto-restart" 30 | - select/click "Advanced Settings", then: 31 | - select "Execution Command" tab, and paste a cleaned-up version from CF's docker incantation into the "Command" field: 32 | only the `token run --token ` parts are needed; remove `docker run cloudflare/cloudflared:latest` and the `--no-autoupdate` parts 33 | - hit "Next" from Advanced Settings and General Settings, and from "Volume Settings" as well (no volumes/files needed) 34 | 35 | ## Configure tunnels 36 | 37 | With the cloudflared running in local docker, back to the CF ZeroTrust configuration. It should now show under "Connectors" the cloudflared as running, and with an IP address. 38 | 39 | Time to add routes/tunnels to NAS, pi-hole, UDM etc.: 40 | - under "Public hostnames" tab, click "Add a public hostname" 41 | - specify subdomain name 42 | - specify local service scheme and local url w/ port, e.g. `10.0.90.42` 43 | 44 | For local `https:`, expand "Additional application settings" and update e.g. TLS settings to enable "No TLS Verify" etc. 45 | 46 | ## Securing remote access 47 | 48 | - from CF ZeroTrust dashboard, select "Settings" | "Authentication" 49 | - by default, there is Cloudflare's "One-time PIN". Add any additional authenticators, e.g. Github, AzureAD etc. 50 | 51 | ### Add AAD authentication 52 | 53 | - select "Add New" and click "Add Azure AD". Follow its help screen and open a second window for and in AAD, create & configure the app registration. 54 | - once tenantid, appId, clientSecret are configured, return to the CF ZT dashboard, click "Test" in the list of "Login methods" under the "Authentication" setting 55 | - ensure MFA is setup for the user accounts in AAD 56 | 57 | ### Configure App policy and authentication 58 | 59 | - from CF ZeroTrust dashboard, select "Access" | "Applications", then "Add an application" 60 | - select the "Self-hosted" type 61 | - Application Configuration: 62 | - name: e.g. "tunnel-access-frontdoor", with e.g. session duration of "24h" 63 | - subdomain: `*` to have it apply to all tunnels 64 | - add a default policy: 65 | - name e.g. "default-allow", Action = "Allow" 66 | - rules: 67 | - Include rule: Selector = "Emails" or "Emails ending" and enumerate allowed/accepted email addresses and email domains 68 | - under tab "Authentication", add/select the AzureAD (the default OneTime PIN can be deselected) 69 | 70 | Login screen example: ![Cloudflare ZeroTrust Access portal](/assets/CF-ZeroTrust-Access-portal.png) 71 | 72 | ## References 73 | - [Cloudflare tunnel docs](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/) 74 | - [CrosstalkSolutions blog](https://www.crosstalksolutions.com/cloudflare-tunnel-easy-setup/) --------------------------------------------------------------------------------