Home → Articles → How to Set Up a PPPoE Billing Software with RouterOS on Ubuntu 26.04

How to Set Up a PPPoE Billing Software with RouterOS on Ubuntu 26.04

04 May, 2026

Introduction

Point-to-Point Protocol over Ethernet (PPPoE) is a network protocol that Internet Service Providers (ISPs) use to establish and manage customer connections. RouterOS, the operating system running on MikroTik network devices, includes a built‑in PPPoE server that authenticates users through local secrets stored on the router. When your Ubuntu VPS cannot access the MikroTik router directly over a local network, WireGuard creates a secure encrypted tunnel between the VPS and the router. A Python FastAPI application then communicates through this tunnel using the RouterOS API library to create, enable, or disable PPPoE secrets programmatically.

This guide teaches you how to build a PPPoE billing API on an Ubuntu VPS that connects to a remote MikroTik router through WireGuard and manages PPPoE secrets using the RouterOS API library.

Prerequisites

Before you start:

Install System Dependencies

Your Ubuntu VPS needs Python 3, PostgreSQL, and WireGuard tools to run the FastAPI billing application.

Configure WireGuard Tunnel Between VPS and MikroTik Router

WireGuard creates a secure virtual network interface that allows your Ubuntu VPS to communicate with the MikroTik router as if they were on the same local network.

Configure PostgreSQL Database

The billing system stores customer information in a PostgreSQL database on the Ubuntu VPS.

Create Project Directory and Virtual Environment

Isolating your billing project dependencies prevents conflicts with other Python applications on the VPS.

Install Required Python Packages

The billing system requires FastAPI for the web framework, the RouterOS API library for MikroTik communication, psycopg2 for PostgreSQL connectivity, and Uvicorn as the ASGI server.

Configure MikroTik Router API Access

The MikroTik router must have the API service enabled and a user with appropriate permissions.

Create the FastAPI Application

The FastAPI application provides REST endpoints to create customers and enable or disable PPPoE secrets on the remote MikroTik router through the WireGuard tunnel.

Run the FastAPI Application

Start the Uvicorn server to expose the PPPoE billing API endpoints.

Press Ctrl + C to stop the server when needed.

Configure Firewall for API Access

Allow external access to the FastAPI application on port 8000.

Test the PPPoE Billing API Endpoints

Test the API endpoints using curl commands from another terminal or your local machine.

Verify PPPoE Secret on MikroTik Router

Log in to your MikroTik router to confirm the PPPoE secret exists and reflects the changes made through the API.

The X flag confirms the secret is disabled.

Understand the API Workflow for Billing Integration

Your billing system can now integrate these endpoints into a complete customer management workflow.

Later, you can extend this system by merging customer records with payment history, usage tracking, and invoice generation.

Conclusion

In this guide, you have set up a PPPoE billing API on an Ubuntu VPS that connects to a remote MikroTik router through a WireGuard tunnel. You installed PostgreSQL to store customer records, built a FastAPI application using the RouterOS API library, and created endpoints to add, enable, and disable PPPoE secrets. You tested the API by creating a customer, toggling the secret status, and verifying changes on the router. Now that your billing API runs correctly, consider extending it with payment tracking, usage monitoring through RADIUS accounting, or building a customer self‑service portal that calls these same endpoints for plan upgrades and account management.