- PPPoE Connection Status RouterOS Script
This script connects to the PPPoE client on a RouterOS device, collects connection status data, and formats it into a structured plaintext output. The data is written into a .txt file, which can be easily reviewed or transferred for further analysis.
This tool is useful for network administrators who need to monitor and log PPPoE connection status information on RouterOS devices.
Before running the script, ensure that you have the following:
- A MikroTik RouterOS device running version 6.45 or later (or a compatible version that supports the required scripting features).
Before running the script, ensure that you have the following:
- A MikroTik RouterOS device.
- Administrative access to the RouterOS device via Winbox, SSH, or WebFig.
- Basic understanding of MikroTik RouterOS scripting.
The script uses the RouterOS scripting environment, which is native to MikroTik devices and does not require any additional software installation on your local machine.
To install the script on your RouterOS device, follow these steps:
Note: Ensure that the user account used to run the script has sufficient permissions to access PPPoE client details and manage files on the RouterOS device. Administrative privileges are recommended. To install the script on your RouterOS device, follow these steps:
-
Login to RouterOS
Use Winbox, SSH, or WebFig to access the RouterOS device. -
Create the Script
- Navigate to
System > Scriptsin RouterOS. - Click the "+" button to add a new script.
- Name the script (e.g.,
pppoe-status). - Comment cound be
Generates PPPoE status report and capped reconnect log to CLI and files - Copy and paste the script (provided below) into the
Sourcefield. - Assign required
permissions:
- Navigate to
| Policy | Required | Reason (English) |
|---|---|---|
| Don't Require Permissions | ✘ | |
| ftp | ✘ | |
| read | ✔ | Required to read PPPoE interface status, system clock, and files |
| write | ✔ | Required to create, remove, and update files |
| policy | ✔ | Required to allow execution of scripts with policy permissions |
| password | ✘ | |
| sensitive | ✘ | |
| reboot | ✘ | |
| test | ✔ | Required to execute scripts and system commands |
| sniff | ✘ | |
| romon | ✘ |
- Save the Script
- Click OK to save the script.
This RouterOS script exports/append detailed PPPoE connection information to a plaintext file pppoe-reconnect-log.txt on the RouterOS device. It retrieves the status of the PPPoE client, including parameters like MTU, MRU, uptime, and more, and stores this information in a structured, human-readable format.
The script retrieves the following PPPoE client parameters:
- Timestamp: Time of the event
- PPP-Interface: Name of the PPPoE interface
- ETH-Interface: Associated Ethernet interface
- Link Status: Current link status (e.g., link-ok / N/A)
- Status: Connection status (e.g., connected / disconnected)
- AC Name: Name of the Access Concentrator
- AC MAC Address: MAC address of the Access Concentrator
- Local IPv4: Local IPv4 address
- Remote IPv4: Remote IPv4 address
- Local IPv6: Local IPv6 address
- Remote IPv6: Remote IPv6 address
- Prefix: Assigned IPv6 prefix
- Prefix Expires After: Time until the prefix expires
- MTU: Maximum Transmission Unit
- MRU: Maximum Receive Unit
- Current Uptime: Duration the connection has been active
After saving the script in RouterOS, you can run it manually through the RouterOS console or schedule it to run periodically.
- Navigate to
System > Scriptsin RouterOS. - Select the script you created (e.g.,
pppoe-status). - Click Run.
- Open a terminal session on your MikroTik device.
- Execute the script using the following command:
/system script run pppoe-status
- The script will execute immediately and output the results in the terminal.
The console output and file pppoe-reconnect-log.txt will contain the following information:
[PPPoE Reconnect Event]
Timestamp : 2025-09-04 19:49:14
PPP-Interface : pppoe-out1
ETH-Interface : ether7-pppoe
Link Status : link-ok
Status : connected
AC Name : AC_01
AC MAC Address : 12:34:56:78:9A:BC
Local IPv4 : 203.0.113.25
Remote IPv4 : 198.51.100.45
Local IPv6 : fe80::abcd:1234:5678:9abc
Remote IPv6 : fe80::dcba:4321:8765:cba9
Prefix : 2003:fb:e700:5600::/56
Prefix Expires After: 17h48m14s
MTU : 1492
MRU : 1492
Current Uptime : 7w2d06:11:52
To access the file:
- Go to Files in RouterOS.
- Locate the
pppoe-reconnect-log.txtfile. - Download or open it to view the PPPoE connection details.
Netwatch is a RouterOS tool that monitors the reachability of a host by pinging it periodically. You can trigger scripts when the host goes up or down, making it ideal for monitoring PPPoE connectivity.
Via GUI:
- Go to
Tools > Netwatch. - Click Add New.
- Configure the entry:
- Host:
8.8.8.8 - Type:
simple - Interval:
30s - Ignore Initial Up:
Yes(prevents the Up script from running immediately if the host is already reachable) - Up Script:
/system script run pppoe-status - Down Script: optional, e.g.,
/system script run pppoe-statusto log disconnections - Comment:
PPPoE Watchdog(for clarity)
- Host:
- Click OK to save.
Via CLI:
/tool netwatch add host=8.8.8.8 type=simple interval=30s ignore-initial-up=yes \
up-script="/system script run pppoe-status" \
down-script="/system script run pppoe-status" \
comment="PPPoE Watchdog"
Via GUI:
- Go to
Tools > Netwatch. - Look at the Status column for each entry:
up→ host is reachabledown→ host is unreachable
Via CLI:
/tool netwatch print detail
This command will display all configured Netwatch entries, including:
- Host being monitored
- Interval between pings
- Up Script and Down Script
- Current status (up or down)
- Any comments for clarity
By checking the status, you can verify that your PPPoE watchdog is working as expected.
We welcome contributions! Feel free to fork the repository, make improvements, and submit a pull request. Your help is appreciated!
This script is provided as-is and is free to use and modify under the terms of the BSD 3-Clause License.
