A PHP script that forwards FRITZ!Box system logs to a syslog server.
- PHP 8.2 or higher
- CURL extension
- Access to a FRITZ!Box device
- Tested with FRITZ!Box 7530, 7590
- Tested with FRITZ!OS v.8.02, v.8.03
- A syslog server (like rsyslog, syslog-ng)
Note: This is a command-line script - no web server is required.
- Real-time log forwarding from FRITZ!Box to syslog server
- Supports RFC 3164 syslog format
- Configurable refresh interval and retry mechanism
- Secure authentication with FRITZ!Box web interface
- Support for both legacy MD5 and modern PBKDF2 authentication
- Graceful connection handling and error recovery
- Clone this repository or download the script
- Ensure PHP is installed and available in your PATH
- Make the script executable:
chmod +x syslog-forwarder.php
Copy the .env.example
file to .env
and edit the variables according to your needs.
If configuration values are not set, the script will prompt for them at runtime.
Run the script from command line:
php syslog-forwarder.php
The script will:
- Connect to your FRITZ!Box
- Authenticate using the provided credentials
- Poll for new log entries at the configured interval
- Forward logs to your syslog server
To stop the script, press Ctrl+C.
docker compose up -d
To run the script as a systemd service on Linux:
- Create a service file
/etc/systemd/system/syslog-forwarder.service
:
[Unit]
Description=Syslog Forwarder for FRITZ!Box
After=network.target
[Service]
Type=simple
User=YOUR_USERNAME
EnvironmentFile=/path/to/your/.env
ExecStart=/usr/bin/php /path/to/syslog-forwarder.php
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
- Enable and start the service:
sudo systemctl enable syslog-forwarder
sudo systemctl start syslog-forwarder
- Check status with:
sudo systemctl status syslog-forwarder
Messages are sent in RFC 3164 format:
- Facility: User-level messages (1)
- Severity: Notice (5)
- Message format:
FRITZ!Box - (id:{ID}; group:{GROUP}) {MESSAGE}
- Network errors will be retried with exponential backoff
- Invalid sessions are automatically renewed
- All errors are logged with timestamps
This project was created to address the lack of native syslog forwarding capabilities in FRITZ!Box routers. It allows centralizing router event logs to a syslog server for better log management and monitoring.
This tool started as a personal utility and was developed in just a few hours. It's being shared for others who might need a simple solution to the same problem.
PHP was chosen simply because it's a language I'm comfortable with. While there might be better technical choices for this task, PHP is simple enough to get the job done. The performance impact of using PHP with polling is negligible - even with 1-second refresh intervals, the resource usage remains minimal.
Feel free to:
- Request new features
- Open issues if you need help
- Submit pull requests to improve the project
Note: Please base your pull request on the
dev
branch. Pull requests tomaster
may be closed or asked to rebase.
Tip: Before starting to work on a new feature or fix, check the list of opened issues. They are a good starting point for contributing and may help you avoid duplicated work.
All contributions are welcome! This project aims to be a simple solution, but that doesn't mean it can't be improved.
FRITZ!Box™ and FRITZ!OS™ are registered trademarks of AVM Computersysteme Vertriebs GmbH. This project is not affiliated with, endorsed by, or connected to AVM in any way.
This project is open source and available under the MIT License.