This is an old revision of the document!
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. The hardware aspect of the network devices has been discussed in here.
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 /sys/class/net.
Here is a summary of the information you will need:
- Internal network: 10.0.0.0/24
- ISP1 network: 192.168.0.0/24 - ISP router on 192.168.0.1
- ISP2 network 192.168.1.0/24 - ISP router on 192.168.1.254
- 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/providers, but that is not mandatory.
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 this page for additional details. You will not need NetworkManager for the home server.
If you plan to use WiFi with WPA or more complex setups (PPP or such) please refer to the Gentoo Handbook.
You should double check the actual names of your network devices under /sys/class/net of course and identify them properly or the following will not work for you.
The first step is to populate your /etc/conf.d/net configuration file, follow this example and adapt to your needs:
- net
# LAN on enp0s31f6 config_enp0s31f6="10.0.0.1/24" # ISP1 on enp59s0u2u4c2 config_enp59s0u2u4c2="192.168.0.10/24" # ISP2 on enp0s20f0u4u4c2 config_enp0s20f0u5u3="192.168.1.10/24"
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="default via 192.168.0.254"
Now, create the needed symlinks and start the networks:
for i in enp0s31f6 enp59s0u2u4c2 enp0s20f0u4u4c2 do ln -s /etc/init.d/net.lo /etc/init.d/net.$i 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 /etc/rc.conf and change the following line to “NO”:
rc_depend_strict="NO"
Reboot your home server and ensure all networks are up and running by pinging the ISP gateways and some internal network host.