Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
router:networking [2024/10/22 19:01] – willy | router:networking [2025/02/06 09:17] (current) – removed willy | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Network Layout ====== | ||
- | |||
- | For a general IP networking understandings [[https:// | ||
- | |||
- | Let's start with the high level organization, | ||
- | * Internal network, or the home network, is the network (or networks) that sits on top of your [[: | ||
- | * External network, or the internet, which is what's outside the home network and should be considered //unsafe//, but it's also the only way into your home network services when you are not at home. | ||
- | |||
- | In the middle of the two, you need a firewall / router device and some magic glue to let things speak together safely and effectively. On the // | ||
- | |||
- | |||
- | ===== Internal Network addressing ===== | ||
- | You need to choose a proper subnet for your home network, and it must be a **private** subnet. The IANA defines | ||
- | |||
- | Of the various available ranges, my suggestion is to use the **10.X.Y.Z** and try to avoid the most obvious combinations like 10.0.0.0/ | ||
- | |||
- | For the following, i will assume your home network uses **10.20.30.0/ | ||
- | |||
- | You should not use a subnet in the 192.168.x.y range as many of these ranges are already used by ISP routers and devices and in case of a clash you might end up having to replace addresses on all your internal hosts, and this can be a mess. | ||
- | |||
- | You also need to choose some IP addresses range assignments. I suggest at the least: | ||
- | * A range for DHCP (10.20.30.100 - 10.20.30.200) since most of your phones/ | ||
- | * A range for network devices, like WiFi APs (10.20.30..2 - 10.20.30.19) | ||
- | * A range for home servers/ | ||
- | * A range for webcams / IoT devices (10.20.30.30 - 10.20.30.69) | ||
- | * A range for fixed IPs (10.20.30.70 - 10.20.30.99) | ||
- | * A fixed IP for your home server (10.20.30.1) | ||
- | * A fixed IP for your router/ | ||
- | |||
- | Of course, you might want to add VLANs so separate IoT stuff and/or create more segments as you prefer. | ||
- | |||
- | |||
- | |||
- | ===== External Network ===== | ||
- | Upstream fro your home, lies your ISP, or ISPs. They will place in your home one (or more) // | ||
- | |||
- | Your ISP gateways will typically have addresses like 192.168.0.1 or 192.168.1.254. | ||
- | |||
- | You **do not need** to have two ISPs. It's a resilience point tough, if you plan to host critical services you might want to have two. If you have only one, just ignore anything related to the second one in the followings. | ||
- | |||
- | I will assume that your access to the **external network** is hidden behind | ||
- | |||
- | (For you lucky from the USA, where sometimes you can, maybe paying or even for free, get a static IP, this might not apply, but since the world is big and 99% of people cannot access a static IP anymore...) | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ===== Home Domain name ===== | ||
- | |||
- | You **need** a domain name. This is not optional, because SSL certificates can be released only to domain names and not directly to IP addresses, and also because when you are outside home, you need a //name// to reach home. | ||
- | |||
- | I will assume you own **mydomain.com**. There are plenty of cheapo domains and also some are for free, remember you don't need a second-level domain (something third level under //.eu.org// for example would work fine). You will need somebody to manage your DNS records (you **cannot** use your home server for this) and you will also be able to create sub-domains (like service.mydomain.com). | ||
- | |||
- | So, i assume you have the following sub-domains: | ||
- | * mydomain.com: | ||
- | * home.mydomain.com: | ||
- | * external1.mydomain.com: | ||
- | * external2.mydomain.com: | ||
- | |||
- | The key point is that you will be configuring this sub-domains differently **inside** and **outside** home, so that your mobile devices will be able to reach your home server with the same sub-domains both when inside and outside home. | ||
- | |||
- | So, from **inside** home (i will show you how to set this up in [[router: | ||
- | * mydomain.com: | ||
- | * home.mydomain.com: | ||
- | * external1.mydomain.com: | ||
- | * external2.mydomain.com: | ||
- | |||
- | And from **outside** home: | ||
- | * mydomain.com: | ||
- | * home.mydomain.com: | ||
- | * external1.mydomain.com: | ||
- | * external2.mydomain.com: | ||
- | |||
- | (if you have only one ISP, you don't need external2.mydomain.com) | ||
- | |||
- | ====== Home Server Networking setup ====== | ||
- | |||
- | You will need at least two network connections on your home server. I mean at least two physical network Ethernet card. You could use one WiFi link, but i prefer to have the backbone on wired. | ||
- | |||
- | You need one Ethernet connection that will be plugging your internal network, i will call this **enp0s31f6** or LAN. | ||
- | |||
- | You need one Ethernet connection for each ISP gateway, while you might do with only one for both, provided you properly assign multiple IP addresses to the same interface. I will call ISP1 **enp0s20f0u4u4c2** and ISP2 **enp59s0u2u4c2**. | ||
- | |||
- | Sorry guys, these are default Linux naming scheme, i know it looks messed up, but there are good reasons for this. You can list all your network devices under **/ | ||
- | |||
- | Here is a summary of the information you will need: | ||
- | |||
- | * Internal network: 10.0.0.0/ | ||
- | * ISP1 network: 192.168.0.0/ | ||
- | * ISP2 network 192.168.1.0/ | ||
- | * Home server, on ISP1 network: 192.168.0.10 (static IP) on enp0s31f6 | ||
- | * Home server, on ISP2 network: 192.168.1.10 (static IP) on enp0s20f0u4u4c2 | ||
- | * Home server, on internal network: 10.0.0.1 (static IP) on enp59s0u2u4c2 | ||
- | * Main external host: static IP 99.99.99.99 | ||
- | * Secondary external host: static IP 77.77.77.77 | ||
- | |||
- | The two external servers should ideally be on different networks/ | ||
- | |||
- | I choose to use static IPs for the home server on the ISPs networks because this allows for the use of SNAT instead of MASQUERADING later on , and it's faster. | ||
- | |||
- | |||
- | ===== Gentoo Network Configuration ===== | ||
- | |||
- | Since i am going all static on the home server, network setup is simple and traightforward. I will be using the basic Netifrc scripts from Gentoo, you should check [[https:// | ||
- | |||
- | If you plan to use WiFi with WPA or more complex setups (PPP or such) please refer to the [[https:// | ||
- | |||
- | You should double check the actual names of your network devices under **/ | ||
- | |||
- | The first step is to populate your **/ | ||
- | <file - net> | ||
- | # LAN on enp0s31f6 | ||
- | config_enp0s31f6=" | ||
- | |||
- | # ISP1 on enp59s0u2u4c2 | ||
- | config_enp59s0u2u4c2=" | ||
- | |||
- | # ISP2 on enp0s20f0u4u4c2 | ||
- | config_enp0s20f0u5u3=" | ||
- | </ | ||
- | |||
- | Please note that i omitted any default route. This file will not let you navigate internet from the home server. This is on purpose because in the next sections i will show you how to do advanced routing techniques and that will cause issues with a default route set at this level. If you need proper internet access meanwhile, add a line like the following: | ||
- | < | ||
- | route_enp59s0u2u4c2=" | ||
- | </ | ||
- | |||
- | Now, create the needed symlinks and start the networks: | ||
- | <code bash> | ||
- | for i in enp0s31f6 enp59s0u2u4c2 enp0s20f0u4u4c2 | ||
- | do | ||
- | ln -s / | ||
- | rc-upate add net.$i default | ||
- | done | ||
- | </ | ||
- | |||
- | Now you need to tell Gentoo that only **one** of these needs to be up for networking to be ready. If you don't do this, then all your services will fail as soon as one goes down. Edit the file **/ | ||
- | < | ||
- | rc_depend_strict=" | ||
- | </ | ||
- | |||
- | Reboot your home server and ensure all networks are up and running by pinging the ISP gateways and some internal network host. | ||