PPPoE Server

Step 1 Install the PPPoE Server on Ubuntu Server

You will need to install these components to get the PPPoE Server working. ppp and pppoe

sudo apt update
sudo apt install ppp
sudo apt install pppoe

Step 2

 Setup PPPoE Settings

Several files need to be created before we can start PPPoE Server. First, modify the /etc/ppp/pppoe-server-options and change it to the following:
sudo nano /etc/ppp/pppoe-server-options

# PPP options for the PPPoE Server
# LOC: GPL
#require-pap
require-chap
#login
lcp-echo-interval 10
lcp-echo-failure 2
ms-dns 8.8.8.8
#ms-dns 10.0.0.1
netmask 255.255.255.0
# Assumes that your IP address is allocated dynamically by the ISP.
#noipdefault
# Try to get the name server addresses from the ISP.
#usepeerdns
# Use this connection as the default route.
#defaultroute
# Makes pppd "dial again" when the connection is lost.
#persist
# Do not ask the remote to authenticate.
#noauth
ktune
proxyarp
nobsdcomp
noccp
novj
noipx

Step 3

Next, add a users. Nead add it into /etc/ppp/chap-secrets.
sudo nano /etc/ppp/chap-secrets:

# Secrets for authentication using CHAP
# client                      server             secret                              IP addresses
username1                   *                     1234567890                   10.0.0.50
username2                   *                     1234567890                   *
username3                   *                     1234567890                   10.0.0.200

Make sure that the file has the correct permissions.

sudo chmod 600 /etc/ppp/chap-secrets

Step 4

Setup the IP addresses to lease for the PPPoE Server. Create file.
sudo nano /etc/ppp/ipaddress_pool

10.0.0.30-253

Step 5 Test PPPoE Server

(You should set it up first UFW Forward Masquerade)

If you want to test start PPPoE Server, you can run the command. in the situation that you use Network Manager for interfaces.

pppoe-server -C addname -S isp -L 10.0.0.1 -p /etc/ppp/ipaddress_pool -I enp1s0 -m 1412

 if everything works ok you can create a startup script.

Step 6 Set PPPoE Scripts for Network Manager

Create own file in 

sudo nano /etc/network/if-up.d/my_route

Add script

#!/bin/sh

if [ "$IFACE" = "enp1s0" ]; then
    pppoe-server -C addname -S isp -L 10.0.0.1 -p /etc/ppp/ipaddress_pool -I enp1s0 -m 1412
fi

Start PPPoE Scripts for ifupdown

There is another method in the situation you are using ifupdown.

sudo nano /etc/ppp/pppoe_start

#!/bin/bash
##############################
# Simple script that starts PPPoE Server
##############################

# Enable IP Forwarding or You should set it up first UFW Forward Masquerade
#echo 1 > /proc/sys/net/ipv4/ip_forward

# Start PPPoE Server
 pppoe-server -C addname -S isp -L 10.0.0.1 -p /etc/ppp/ipaddress_pool -I enp1s0 -m 1412

# Set Firewall rules or You should set it up first UFW Forward Masquerade
#iptables -A POSTROUTING -t nat -s 10.0.0.0/24 -j MASQUERADE
#iptables -A FORWARD -p tcp --syn -s 10.0.0.0/24 -j TCPMSS --set-mss 1256

Stop PPPoE Scripts

sudo nano /etc/ppp/pppoe_stop
#!/bin/bash
##############################
# Simple script that stops PPPoE Server
##############################

# Disable IP Forwarding or You should set it up first UFW Forward Masquerade
#echo 0 > /proc/sys/net/ipv4/ip_forward

# Kill PPPoE Server
killall pppoe-server
killall pppd

# Flush the IPtable rules. or You should set it up first UFW Forward Masquerade
#iptables -t nat -F POSTROUTING

Installation interfaces for ifupdown.

sudo nano /etc/network/interfaces

auto enp1s0
iface enp1s0 inet manual
up ifconfig $IFACE 0.0.0.0 up
post-up /etc/ppp/pppoe_start
post-down /etc/ppp/pppoe_stop
down ifconfig $IFACE down

Automatically add routes when PPPOE or PPTP client connects

In a situation where you need ...

sudo nano /etc/ppp/ip-up.d/ppp

#!/usr/bin/env bash

interface=$1
event=$2

# ppp1
if [[ $interface != "ppp1" ]] || [[ $event != "up" ]]
then
  return 0
fi
ip route add 10.0.0.0/24 dev ppp1 table pppoe-route