PUQ Mautic

Mikrotik VPN WHMCS module

WHMCS server module for Mikrotik VPN that automates provisioning and management of VPN accounts through the Mikrotik API. The module supports automatic account creation, suspend/unsuspend/terminate, change package, change password, bandwidth speed and traffic limits, traffic usage statistics with history, post-paid traffic billing via WHMCS metrics, and multilingual admin and client interfaces.

Description

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Mikrotik VPN WHMCS module

The Mikrotik VPN WHMCS module is a provisioning module that integrates WHMCS with Mikrotik routers, enabling Internet and VPN service providers to offer VPN accounts to their customers. The module automates the full lifecycle of VPN account management using the Mikrotik API only.


Main features


System requirements

Requirement Minimum
WHMCS 9.x or higher
PHP 8.2 or higher
Mikrotik RouterOS 7.x or higher
ionCube Loader v13 or newer (v14, v15)

Important: The module registers opposite values for upload and download speeds in the Mikrotik router compared to WHMCS settings, because Mikrotik measures incoming traffic while VPN clients experience outgoing traffic. Proper Mikrotik router configuration is essential (NAT, firewall, routing, and all required VPN server settings).



Screenshots

Client area — Home screen

Client area home screen 01-description-client-area.png

Client area — Traffic statistics

Traffic statistics 02-description-traffic-stats.png

Admin area — Product information

Admin area product information 03-description-admin-area.png

Changelog

Mikrotik VPN module WHMCS

Order now | Download | FAQ

v3.1.1 (02-06-2026)


v3.1 (20-04-2026)


v3.0 (01-02-2026)

Note: Product reconfiguration is required after update.


v2.2 (23-01-2025)

Important: After the update, all products using this module must be completely reconfigured.


v2.0 (23-09-2024)


v1.3.5 (11-10-2023)


v1.3 (04-02-2023)


v1.2 (04-01-2023)


v1.1 (28-10-2022)


v1.0 (01-08-2022)

Installation and Configuration Guide

Step-by-step instructions for installing, configuring, and setting up the Mikrotik VPN WHMCS module, including Mikrotik router preparation (RouterOS certificates, HTTPS and API-SSL, VPN server), WHMCS integration, email templates, server registration, and product configuration.

Installation and Configuration Guide

WHMCS setup (install/update)

Mikrotik VPN module WHMCS

Order now | Download | FAQ

System requirements

Requirement Minimum version
PHP 8.2 or higher
WHMCS 9.x or higher
Mikrotik RouterOS 7.x or higher
ionCube Loader v13 or newer (v14, v15)

Note: The module uses ionCube encoding. Make sure ionCube Loader is installed and active on your server.


Download

The module can be ordered and downloaded from PUQ Cloud:

wget https://download.puqcloud.com/WHMCS/servers/PUQ_WHMCS-Mikrotik-VPN/php82/PUQ_WHMCS-Mikrotik-VPN-latest.zip

Older module versions for WHMCS 8 are available in PHP-specific directories:

After downloading, extract the archive:

unzip PUQ_WHMCS-Mikrotik-VPN-latest.zip

Installation

Step 1: Upload files

Extract the module archive and copy the puqMikrotikVPN directory to the WHMCS servers module directory:

WHMCS_WEB_DIR/modules/servers/puqMikrotikVPN

Step 2: Add server

Navigate to System SettingsServersAdd New Server:

  1. Enter the correct Name and Hostname
  2. In Assigned IP Addresses, enter the list of IPs to distribute to users
  3. In Server Details, select the PUQ Mikrotik VPN module
  4. Enter valid Mikrotik router credentials (username and password)
  5. Click Test connection to verify

Step 3: Create product

Navigate to System SettingsProducts/ServicesCreate a New Product:

  1. Select the PUQ Mikrotik VPN module in the Module settings section
  2. Configure the product parameters

Update

Step 1: Backup

Before updating, it is recommended to back up:

Step 2: Upload new files

Download and extract the new version, then overwrite all files in:

WHMCS_WEB_DIR/modules/servers/puqMikrotikVPN/

Step 3: Verification

  1. Log in to the WHMCS admin panel
  2. Check the module is functioning correctly
  3. Verify product settings

Important (v3.0): Product reconfiguration is required after updating to version 3.0. The traffic package model has been replaced with post-paid billing via WHMCS metrics.

Installation and Configuration Guide

Setup guide: Mikrotik preparation and configuration

Mikrotik VPN module WHMCS

Order now | Download | FAQ

This guide covers the preparation of a Mikrotik router for use with the PUQ Mikrotik VPN WHMCS module: root CA certificate, Webfig certificate, HTTPS, API-SSL and VPN server activation.

Note: Enter the following commands one by one and wait for each command to complete before running the next.


1. Check RouterOS version

Ensure RouterOS version is 7.x or higher:

system/package/print

2. Create a root CA on the router

Enable HTTPS by creating your own local root Certificate Authority:

/certificate
add name=LocalCA common-name=LocalCA key-usage=key-cert-sign,crl-sign

3. Sign the root CA certificate

/certificate
sign LocalCA

4. Create a non-root certificate for Webfig

Replace XXX.XXX.XXX.XXX with your router's public IP address (or the hostname you use to reach it).

/certificate
add name=Webfig common-name=XXX.XXX.XXX.XXX

5. Sign the Webfig certificate with the local CA

/certificate
sign Webfig ca=LocalCA

6. Enable HTTPS (www-ssl) with the Webfig certificate

/ip service
set www-ssl certificate=Webfig disabled=no

7. Enable API-SSL with the Webfig certificate

The PUQ Mikrotik VPN module communicates with the router through the API-SSL service:

/ip service
set api-ssl certificate=Webfig disabled=no

Important: The module uses the Mikrotik API only. Make sure the API-SSL port is reachable from the WHMCS server.


8. Enable VPN server

Enable the VPN protocol(s) you plan to offer to clients (PPTP, L2TP, etc.) and configure the corresponding PPP profile, service and IP pool. The PPP profile name configured here will later be selected in the product settings on the WHMCS side.

Mikrotik VPN server setup 16-mikrotik-setup.png


9. Firewall, NAT and routing

Configure NAT, firewall and routing on the Mikrotik router so that VPN clients can reach the Internet and any internal resources you want to expose. The module itself only provisions the user account (PPP secret) — the surrounding network configuration is the responsibility of the router administrator.

Important: The module registers opposite values for upload and download speeds in the Mikrotik router compared to the WHMCS product settings, because Mikrotik measures incoming traffic while VPN clients experience outgoing traffic.

Installation and Configuration Guide

Setup guide: WHMCS setup

Mikrotik VPN module WHMCS

Order now | Download | FAQ

System requirements

Requirement Minimum version
PHP 8.2 or higher
WHMCS 9.x or higher
Mikrotik RouterOS 7.x or higher
ionCube Loader v13 or newer (v14, v15)

Note: The module uses ionCube encoding. Make sure ionCube Loader is installed and active on your server.

Older module versions for WHMCS 8 are available in PHP-specific directories:


Step 1: Download the module

wget https://download.puqcloud.com/WHMCS/servers/PUQ_WHMCS-Mikrotik-VPN/php82/PUQ_WHMCS-Mikrotik-VPN-latest.zip

Step 2: Extract the archive

unzip PUQ_WHMCS-Mikrotik-VPN-latest.zip

Step 3: Copy module files

Copy the puqMikrotikVPN directory to:

WHMCS_WEB_DIR/modules/servers/

Step 4: Add server in WHMCS

Navigate to System SettingsServersAdd New Server

  1. Enter the correct Name and Hostname
  2. In Assigned IP Addresses, enter the list of IPs that will be distributed to users
  3. In the Server Details section, select the PUQ Mikrotik VPN module
  4. Enter valid Mikrotik router credentials (username and password)
  5. Click Test connection to verify the connection

Add server - general settings 04-add-server-1.png

Add server - module settings 05-add-server-2.png


Step 5: Create product in WHMCS

Navigate to System SettingsProducts/ServicesCreate a New Product

Select the PUQ Mikrotik VPN module in the Module settings section.

WHMCS product module settings 06-whmcs-setup.png

Installation and Configuration Guide

Email Template (puqMikrotikVPN notification traffic limit)

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Creating the email template

Navigate to System SettingsEmail TemplatesCreate New Email Template

This template is used to notify the customer when the remaining traffic falls below the threshold configured in the product settings ("Notification traffic remainder less than X GB").


Template configuration

Parameter Value
Email Type Product/service
Unique Name puqMikrotikVPN notification traffic limit

Email subject

Traffic less than {$notification_traffic_remainder} GB - {$username}

Email body

Dear {$client_name},

This letter informs you that the traffic limit of the service is coming to an end.

Product/Service: {$service_product_name}
Due Date: {$service_next_due_date}

Username: {$username}
Left traffic: {$traffic_balance_gb} GB
After renewing the service, {$traffic_billingcycle_gb} GB will be automatically added.

{$signature}

Available template variables

The following custom variables are passed to the email template by the module:

Variable Description Example
{$username} VPN account username mikrotik-user-42
{$notification_traffic_remainder} Traffic threshold configured in product settings (GB) 5
{$traffic_balance_gb} Remaining traffic balance for the customer (GB) 4.2
{$traffic_billingcycle_gb} Traffic that will be added on the next billing cycle (GB) 100

In addition, all standard WHMCS product/service merge fields are available (e.g. {$client_name}, {$service_product_name}, {$service_next_due_date}, {$signature}).

Note: Notifications are sent automatically during the WHMCS cron execution when remaining traffic falls below the threshold configured in the product settings.


Screenshots

Email template creation 07-email-template-1.png

Email template configuration 08-email-template-2.png

Installation and Configuration Guide

Email Template (puqMikrotikVPN Suspension Notification traffic limit)

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Creating the email template

Navigate to System SettingsEmail TemplatesCreate New Email Template

This template is used to notify the customer that the VPN account has been suspended on the Mikrotik router because the traffic balance reached zero or below. The traffic limit will be restored on the next billing cycle.


Template configuration

Parameter Value
Email Type Product/service
Unique Name puqMikrotikVPN Suspension Notification traffic limit

Email subject

Suspension Information - {$username}

Email body

Dear {$client_name},

This letter informs you that the VPN account has been suspended due to traffic exhaustion.
The traffic limit will be restored from the next service cycle.
It is also possible to switch to a package with a large amount of traffic.

Product/Service: {$service_product_name}
Due Date: {$service_next_due_date}


Username: {$username}
Left traffic: {$traffic_balance_gb} GB
After renewing the service, {$traffic_billingcycle_gb} GB will be automatically added.


{$signature}

Available template variables

The same custom variables as in the traffic-limit notification template are available:

Variable Description
{$username} VPN account username
{$traffic_balance_gb} Remaining traffic balance (GB) — normally zero or below when this template is sent
{$traffic_billingcycle_gb} Traffic that will be added on the next billing cycle (GB)

Plus all standard WHMCS product/service merge fields ({$client_name}, {$service_product_name}, {$service_next_due_date}, {$signature}).

Note: This email is sent automatically by the module when the VPN account is auto-suspended on the Mikrotik router because the customer's traffic balance has been exhausted.

Installation and Configuration Guide

Add server (Mikrotik router)

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Adding a Mikrotik router to WHMCS

Configure a Mikrotik router as a server within WHMCS using the PUQ Mikrotik VPN module.

Navigate to System SettingsServersAdd New Server


Step 1: General settings

Enter the correct Name and Hostname for your Mikrotik router.

If your Mikrotik API-SSL service listens on a non-standard port, enter it in the Port field. Check the Secure checkbox (the module talks to the router through API-SSL).

Add server - general settings 04-add-server-1.png


Step 2: Assigned IP addresses

In the Assigned IP Addresses field, enter the list of IP addresses that will be distributed to users. These IPs are consumed sequentially as new VPN accounts are provisioned. Both private and public IP addresses are supported.


Step 3: Module settings

  1. In the Server Details section, select the PUQ Mikrotik VPN module from the dropdown
  2. Enter valid Mikrotik router credentials:
    • Username — Mikrotik user with API access (typically with the full group or custom group that includes api, write, read, policy)
    • Password — the corresponding password
  3. Click Test connection to verify the connection is working correctly

The test connection verifies that the module can reach the Mikrotik API-SSL service and authenticate with the provided credentials.

Add server - module settings 05-add-server-2.png

Important: The Mikrotik user must have sufficient privileges to create and manage PPP secrets, read traffic counters and reset them. The module uses the Mikrotik API only — SSH access is not used.

Installation and Configuration Guide

Product Configuration

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Add new product to WHMCS

Navigate to System SettingsProducts/ServicesCreate a New Product

Select the PUQ Mikrotik VPN module in the Module settings section.


Configuration parameters

Parameter Description
License key A pre-purchased license key for the PUQ Mikrotik VPN module. The license must be active for correct operation. After saving, the verification status is displayed below the field.
Comment PREFIX Prefix applied to the VPN user comments on the Mikrotik router. Helps identify which PPP secrets belong to WHMCS-managed accounts.
Profile PPP secret profile on the Mikrotik router. The dropdown is populated with the profiles configured on the selected server.
Service Available VPN service on the Mikrotik router (e.g. any, pptp, l2tp, pppoe, etc.).
Bandwidth Download Download speed limit in M/s applied to the VPN account.
Bandwidth Upload Upload speed limit in M/s applied to the VPN account.
Traffic (One Time / Monthly / Quarterly / Semi-Annual / Annual / Biennial / Triennial) Packet of traffic added per billing cycle (in GB). Values match the WHMCS billing cycle of the product.
Save traffic history (days) Number of days to retain daily traffic usage statistics. Older records are deleted automatically during cron execution.
User notification traffic limit email template Email template sent when remaining traffic falls below the threshold configured in the next field. Select a Product/service email template (created manually in WHMCS).
Notification traffic remainder less than X GB Traffic threshold (in GB) that triggers the notification email.
Suspend exceeding traffic limit email template Email template sent when the traffic balance reaches zero or below and the VPN account is automatically suspended on the router.
Link to instruction Optional URL to a client-facing setup manual. Displayed as a button in the client area. Leave empty to hide the button.
Support PPtP Toggles the display of PPtP connection details (server address, credentials) in the client area.
Support L2TP Toggles the display of L2TP connection details in the client area.
L2TP IPSec PSK key The IPSec pre-shared key for L2TP; displayed in the client area when L2TP support is enabled.
Statistics collection frequency The frequency at which traffic usage statistics are collected by the WHMCS cron. Also checks the traffic balance and disables the VPN account on the Mikrotik router when the balance is exhausted.

Important notes

Warning: This module works only as a server module (Products/Services). It cannot be used as an add-on product. Attempting to use it with add-on products will result in an error message.

Post-paid traffic billing (v3.0+): The module no longer exposes its own traffic package selector. Traffic consumption is reported back to WHMCS using standard metrics, so you can build any post-paid traffic pricing model directly in the WHMCS product configuration.

Opposite upload/download values on Mikrotik: the module intentionally registers opposite values on the router compared to the WHMCS settings, because Mikrotik measures incoming traffic while VPN clients experience outgoing traffic.


Screenshots

Product configuration settings 09-product-configuration.png

Product configuration — module settings area 17-product-configuration-2.png

Client Area

Overview of the client-facing features available in the Mikrotik VPN WHMCS module, including the home screen (VPN server address, protocols, credentials, connection status, bandwidth limit), email notifications (traffic limit, suspension) and traffic usage statistics.

Client Area

Home screen

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Client area home screen

After authenticating to the client panel, the end customer sees the VPN service management page with the following sections:

Service information

Traffic information

Sidebar navigation

The client area sidebar contains two menu items:

Note: If the service status is not Active or if the VPN account cannot be found on the Mikrotik router, an error page is displayed instead.


Screenshot

Client area home screen 10-home-screen.png

Client Area

Email notification

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Email notification examples

The module sends two types of automatic email notifications based on the customer's traffic balance and the templates configured in the product settings.


1. Traffic limit about to be exhausted

Sent automatically when the remaining traffic balance falls below the threshold configured in the product settings ("Notification traffic remainder less than X GB"). Uses the template selected in "User notification traffic limit email template".

Email notification — traffic limit 11-email-notification-1.png


2. Suspension notification (traffic exhausted)

Sent automatically when the traffic balance reaches zero or below and the module suspends the VPN account on the Mikrotik router. Uses the template selected in "Suspend exceeding traffic limit email template".

Email notification — suspension 12-email-notification-2.png

Note: Both templates must be created manually in WHMCS before they can be selected in the product settings. See the Email Template pages in the Installation and Configuration chapter.

Client Area

Traffic statistics

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Traffic usage statistics

The client can view traffic usage statistics in the sidebar menu item "Traffic statistics".

The statistics page shows the customer's traffic on a daily basis, broken down into incoming and outgoing traffic. Both charts are powered by Google Charts and automatically resize to fit the browser window. The raw data is collected by the WHMCS cron job and stored in the database for the number of days configured in the product settings ("Save traffic history (days)" parameter).

Note: Statistics data is only available after the WHMCS cron has run at least once with the UsageUpdate function. After each collection, traffic counters on the Mikrotik router are reset to zero to guarantee accurate accounting for the next interval.


Screenshots

Traffic statistics — chart view 13-traffic-statistics-1.png

Traffic statistics — table view 14-traffic-statistics-2.png

Admin Area

Administrative features and tools available in the WHMCS admin panel for managing Mikrotik VPN services.

Admin Area

Product Information

Mikrotik VPN module WHMCS

Order now | Download | FAQ

Admin area product information

The administrator can view detailed service information in the WHMCS admin panel on the product/service page. The module adds a custom panel in the Module Data section with the following information:

License verification status

Displays the current license status with a colored indicator:

API connection status

Shows the result of a real-time connection test to the Mikrotik router API-SSL, confirming that the credentials entered for the server are working correctly.

VPN account information

Field Description
Username The VPN account username (PPP secret name) on the Mikrotik router
Enabled Whether the VPN account is currently enabled or disabled on the router
Profile The PPP profile assigned to the account
Service The VPN service / protocol (e.g. any, pptp, l2tp, pppoe)
IP address The IP address assigned to the account from the server's IP pool
Comment Includes the configured Comment PREFIX and WHMCS service identifier

Traffic information

Available management actions

The standard WHMCS module command buttons are available:


Screenshot

Admin area product information 15-product-information.png