A Linux system can act as a gateway for devices on a private LAN. Older documentation often called this IP masquerading; today the same idea is usually described as NAT or source NAT.
What you need
- One interface connected to the upstream network or Internet.
- One interface connected to the private LAN.
- IP forwarding enabled.
- A firewall/NAT rule allowing LAN traffic to leave through the upstream interface.
Enable IPv4 forwarding
sudo sysctl -w net.ipv4.ip_forward=1
For a permanent setting, configure the relevant sysctl file rather than relying on the one-time command above.
NAT
Modern distributions may use nftables, firewalld, or a NetworkManager connection-sharing mode. Prefer the firewall framework already used by the system rather than mixing several tools.
Clients on the LAN should use the Linux gateway’s private address as their default gateway and should also have working DNS configuration.