sodcalculator

10 Tech How-To

Ubuntu Server PPPoE Router Setup Guide

Guide 10-44750 · Updated · Step by step

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

  1. Identify your network interfaces – Run ip link to list all network interfaces. Note the names of your WAN and LAN interfaces (e.g., eth0 for WAN, eth1 for LAN). In this guide, we’ll use eth0 for WAN and eth1 for LAN.
  2. Install the PPPoE client – Run sudo apt update and then sudo apt install pppoeconf. This package includes the configuration tool and the PPPoE daemon.
  3. 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 the pppoe configuration, 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.
  4. Verify the PPPoE connection – Run ip a show ppp0 to see if the ppp0 interface has an IP address. Also check ip route to confirm a default route via ppp0 exists.
  5. 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.

  6. Enable IP forwarding – Edit /etc/sysctl.conf and uncomment or add the line net.ipv4.ip_forward=1. Then run sudo sysctl -p to apply it immediately.
  7. 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.

  8. Make iptables rules persistent – Install iptables-persistent: sudo apt install iptables-persistent. During installation, answer Yes to save current rules. If you miss it, run sudo netfilter-persistent save later.
  9. Configure DHCP and DNS (optional but recommended) – Install a DHCP server: sudo apt install isc-dhcp-server. Edit /etc/dhcp/dhcpd.conf to 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-server and set INTERFACESv4="eth1". Restart the service: sudo systemctl restart isc-dhcp-server.
  10. 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.8 to verify connectivity.

Common Mistakes

  • Wrong interface selected – Using the LAN interface for PPPoE will break your setup. Double-check with ip link before 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 try to 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 plog to see logs, and use sudo pon dsl-provider to 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 ppp0 for an IP. If none, run sudo plog to 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 on eth1. 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 with sudo iptables -t nat -L -n and sudo 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 plog for 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 try to 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

The whole Tech How-To bed →