Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
router:networking [2024/02/21 13:05] – [Gentoo Network Configuration] willy | router:networking [2025/02/06 09:17] (current) – removed willy | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Network Configuration for the Home Router ====== | ||
- | |||
- | {{ : | ||
- | |||
- | The network architecture i will referring to it's divided into different zones: | ||
- | * The **external** zone, which is internet or in general anywhere **outside** your home. This will be on the other side of your ISP gateway. It's considered dangerous and //hic sunt leones//. | ||
- | * The **internal** zone, which is your home network, it's considered safe and comfy. Do not let unknown strangers have the WiFi password! | ||
- | |||
- | There are also your ISP's gateways networks, which i will assume are // | ||
- | |||
- | 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. | ||
- | |||
- | ===== Internal network ===== | ||
- | |||
- | The **internal** network is considered somehow a safe zone, where all your home devices (or devices while at home) will connect. This network will be able to access to all your home services and also the internet, in a safe way. | ||
- | |||
- | The key point for mobile devices (laptops, tables, phones etc) that can move between inside and outside home is to be able to access the services both when inside and outside home in the same way. This will **not** include how to provide safe internet access to mobile devices while outside home, since this might require root access in some cases or the mandatory use of a VPN. | ||
- | |||
- | (note: a quick way for Android devices is to set // | ||
- | |||
- | I will show you how do all this **without** the need for a VPN, not because i dislike using a VPN but because it's a complexity layer that applies to end-users, and this might not be acceptable for someone (elderly parents, spuses, kids...). Moreover, i do not want mobile devices to be using the home network connection when outside for general browsing and navigation, because this will add delay and use up twice the home bandwidth and data caps, which is not desirable. | ||
- | |||
- | For the **internal** network it is important that you choose a good subnet range. The IANA defines | ||
- | |||
- | I will assume your home server is 10.0.0.1. | ||
- | |||
- | Note that your internal network must be connected **only** to your home server and **never** directly to your ISPs gateways! | ||
- | |||
- | ===== External network ===== | ||
- | |||
- | 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...) | ||
- | |||
- | I will assume that you have two ISPs (for resilience). **ISP1** is high-speed but has a monthly data-cap, and it's gateway is on the 192.168.0.0 subnet. **ISP2** is lower-speed but has no data-cap. It's gateway is on the 192.168.1.0 subnet. | ||
- | |||
- | I also assume you have an **external server**, or better that you have **two** external servers for resilience and redundancy: | ||
- | * external server 1: 99.99.99.99 | ||
- | * external server 2: 77.77.77.77 (only needed if you have two ISPs) | ||
- | |||
- | (IPs are totally random, but you need static IPs accessible on the internet). | ||
- | |||
- | You can get very cheap VPS by shopping around. You will not be running much on them, so you don't need CPU or RAM nor storage, make sure you have a decent network bandwidth as that will determine the quality of accessing your home services while outside. | ||
- | |||
- | ===== 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. | ||