# Internal routing
## Pre-requisites
- Internet IPv4 addresses are limited, so the global list of IPv4 addresses are restricted. - Groups of IPv4 addresses can be marked in the format `A.B.C.D/E`, where each of `A`, `B`, `C` and `D` are 8-bits long, and `E` represents the number of leading bits that are the same for the whole subnet, e.g. `10.50.202.3/21` indicate the range of addresses
- from `10.50.200.0` (00001010.00110010.11001000.00000000)
- to `10.50.207.255` (00001010.00110010.11001111.11111111)
- Can be expressed in the form of a network mask too, i.e. `/21` means a mask of `255.255.248.0` (11111111.11111111.11111000.00000000) - To circumvent limited number of IPv4 addresses, IP address allocation is handled by telcos, which is turn was allocated a group of addresses (called a subnet) by higher and higher authorities, up until the Internet Assigned Numbers Authority (IANA).
- Some subnets are marked as private, so that others cannot assign to them in the Internet addresses. These are used in local area networks (LAN) like home or office networks - usually also outfitted with Wi-Fi capabilities. These LANs are exposed to the Internet typically by a single public IP address (known as the LAN gateway).
- Since two computers communicating typically reside in private LANs, a technique known as network address translation (NAT) needs to be performed, to convert from a private IP address to public IP address.
- Ports are necessary to distinguish the type of service available. For example, websites are served over HTTP (port 80) or HTTPS (port 443). Email is served over SMTP (port 25).
## Router
The first key piece of a home network is the router, which typically acts as the LAN gateway as well. The router serves several functions:
1. It performs network address translation (NAT).
A switch is different from a router.
{.is-warning}
## Working with multiple subnets
OpenVPN change subnet...
---
# Guides
In this section, we'll use the ASUS router RT-AC85U as an example.
Screwed up the local subnet somehow.
A possible fix is to temporarily route connections to 192.168.1.1/32 towards 10.99.101.1 as the gateway. Then set the router IP address as 10.99.101.1, with DHCP enabled (make sure the IP assignment subnet is also 10.99.101.2 - 10.99.101.254).
Replugging the Ethernet cable typically will invoke the change in address, but if it fails rebooting will work. If still fail, the settings went haywire. Earlier I set the gateway to 10.99.101.0 and all hell broke loose.