This guide walks you through turning an Ubuntu Server into a full-featured router using a PPPoE internet connection, commonly used by DSL and fiber ISPs. You’ll configure the network interfaces, install and set up the PPPoE client, enable IP forwarding, and set up NAT (masquerading) so all devices on your LAN can share the single internet connection. Before starting, ensure you have a second network interface (NIC) for your LAN, root or sudo access to the server, and your PPPoE username and password from your ISP.
What You’ll Need
- Ubuntu Server (20.04 LTS or newer) installed on a machine with at least two network interfaces: one for the WAN (connected to your modem or ONT) and one for the LAN (connected to your switch or access point).
- PPPoE credentials (username and password) from your internet service provider.
- A basic understanding of the command line and network concepts (IP addresses, subnets).
Step-by-Step
- Identify your network interfaces – Run
ip linkto list all network interfaces. Note the names of your WAN and LAN interfaces (e.g.,eth0for WAN,eth1for LAN). In this guide, we’ll useeth0for WAN andeth1for LAN. - Install the PPPoE client – Run
sudo apt updateand thensudo apt install pppoeconf. This package includes the configuration tool and the PPPoE daemon. - Configure the WAN interface for PPPoE – Run
sudo pppoeconf. The interactive wizard will scan for your modem. When prompted, select your WAN interface (e.g.,eth0). Answer Yes to modify thepppoeconfiguration, and when asked about adding a route, choose Yes. Enter your PPPoE username and password when prompted. For the remaining questions, accept the defaults (usually Yes for using peer DNS, and No for limiting access). At the end, choose Yes to start the connection now. - Verify the PPPoE connection – Run
ip a show ppp0to see if theppp0interface has an IP address. Also checkip routeto confirm a default route viappp0exists. - Configure the LAN interface – Edit the netplan configuration file:
sudo nano /etc/netplan/01-netcfg.yaml. Replace its contents with:network: version: 2 renderer: networkd ethernets: eth1: dhcp4: no addresses: [192.168.1.1/24]Adjust the IP range if desired. Then run
sudo netplan apply. - Enable IP forwarding – Edit
/etc/sysctl.confand uncomment or add the linenet.ipv4.ip_forward=1. Then runsudo sysctl -pto apply it immediately. - Set up NAT (masquerading) – Install iptables if not already present:
sudo apt install iptables. Then run:sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE sudo iptables -A FORWARD -i eth1 -o ppp0 -j ACCEPT sudo iptables -A FORWARD -i ppp0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
These rules allow LAN traffic to be translated and forwarded to the internet.
- Make iptables rules persistent – Install
iptables-persistent:sudo apt install iptables-persistent. During installation, answer Yes to save current rules. If you miss it, runsudo netfilter-persistent savelater. - Configure DHCP and DNS (optional but recommended) – Install a DHCP server:
sudo apt install isc-dhcp-server. Edit/etc/dhcp/dhcpd.confto define a subnet, e.g.,subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.100 192.168.1.200; option routers 192.168.1.1; option domain-name-servers 8.8.8.8, 8.8.4.4; }. Then edit/etc/default/isc-dhcp-serverand setINTERFACESv4="eth1". Restart the service:sudo systemctl restart isc-dhcp-server. - Test the router – Connect a client device to your LAN switch, ensure it gets an IP via DHCP (or set a static IP in the 192.168.1.0/24 range), and try to browse the internet. From the server, you can also run
ping 8.8.8.8to verify connectivity.
Common Mistakes
- Wrong interface selected – Using the LAN interface for PPPoE will break your setup. Double-check with
ip linkbefore running pppoeconf. - Forgetting to enable IP forwarding – Without
net.ipv4.ip_forward=1, packets will not be routed between interfaces. - Incorrect iptables rules – Missing the FORWARD rules or the MASQUERADE rule will result in no internet access for clients.
- Netplan misconfiguration – A syntax error in the YAML file will prevent the LAN interface from coming up. Always run
sudo netplan tryto validate before applying. - DHCP server not running – If clients don’t get an IP, check that the DHCP service is active and listening on the correct interface.
Tips
- Use a static IP for the LAN interface that is unlikely to conflict with your ISP’s network (e.g., 192.168.1.1 is common).
- Consider setting up a firewall (e.g., UFW) to restrict incoming connections from the internet. If you use UFW, allow forwarding and masquerading explicitly.
- Monitor the PPPoE connection with
sudo plogto see logs, and usesudo pon dsl-providerto reconnect manually if it drops. - If you have a dynamic public IP, consider using a dynamic DNS service to access your network from outside.
- Document your configuration in a text file so you can restore it if needed.
Troubleshooting
- No internet on the server itself – Check
ip a show ppp0for an IP. If none, runsudo plogto see PPPoE errors. Common causes: wrong credentials, modem not in bridge mode, or a faulty cable. - Clients can’t get an IP address – Verify the DHCP server is running (
sudo systemctl status isc-dhcp-server) and that it’s listening oneth1. Check the configuration file for syntax errors. - Clients have IP but no internet – Check if IP forwarding is enabled (
sysctl net.ipv4.ip_forward). Then verify iptables rules withsudo iptables -t nat -L -nandsudo iptables -L -n. Ensure the FORWARD rules are present and correct. - DNS resolution fails – If clients can ping IPs but not domain names, check the DNS settings in the DHCP configuration. You can also test from the server with
nslookup google.com. - PPPoE connection drops frequently – Check the physical connection, and look at
sudo plogfor errors. Some ISPs require a specific MTU (e.g., 1492) – you can set it in the pppoe configuration file. - Netplan fails to apply – If you get an error, run
sudo netplan tryto test the configuration before applying. Common issues are indentation errors or using the wrong interface name.
Frequently Asked Questions
Do I need a separate modem for PPPoE?
Yes, typically you need a modem or ONT that can be set to bridge mode, so the PPPoE session is established by your Ubuntu server. If your modem already handles PPPoE, you don’t need this setup.
Can I use a wireless interface for the LAN?
Yes, but you’ll need to configure the wireless interface with a static IP and ensure it’s in AP mode. The steps are the same, but the interface name will be like wlan0.
How do I change my PPPoE password?
Edit the file /etc/ppp/chap-secrets (or /etc/ppp/pap-secrets) and update the password. Then restart the connection with sudo poff and sudo pon dsl-provider.
Is it safe to use this router on a public network?
With proper firewall rules (like UFW) and NAT, it’s as safe as any consumer router. Make sure to disable unnecessary services and keep the system updated.
Can I run a VPN server on the same machine?
Yes, you can. Just ensure the VPN service binds to the LAN interface and that iptables rules allow the VPN traffic. This is a common setup for secure remote access.
What if my ISP uses PPPoE with a different authentication method?
PPPoE typically uses PAP or CHAP. The pppoeconf tool handles both automatically. If you have a more exotic setup, you may need to edit /etc/ppp/peers/dsl-provider manually.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Hard Drive Very Slow Suddenly? Fixes That Work
- Windows Insider: Check New Windows 10 Features
- Restore Pitted Chrome Sink Drain Surrounds
- Error Performing Query Error Facebook: Fixes
- WiFi Not Working on HTC 10? Solved
- Fix Windows 100% CPU Usage: 7 Real Fixes