Home page Forums Technical Support, Bugs and Fixes External devices Reply To: External devices

#8713
Dmitriy SDmitriy S
Participant

    Issue: Syslog not working for devices behind NAT
    Situation Description:
    MikroWizard server is installed behind a NAT router:

    Server internal IP: 192.168.10.2
    Router external IP: 1.1.1.1
    Client MikroTik devices connect from the internet through the external IP

    Steps to Reproduce:

    Added a MikroTik device to MikroWizard
    Manually configured /system logging on MikroTik with prefix mikrowizard (without ID number)
    Logs were arriving at the server but were not being saved to the database
    Deleted the device and added it again (device ID changed)
    Enabled “Force Syslog” option for automatic configuration
    MikroWizard automatically configured syslog but used the internal address 192.168.10.2 instead of external 1.1.1.1
    Device could not send logs because address 192.168.10.2 is unreachable from the internet

    Issues Found:
    Issue 1: Regex requires device number in prefix

    Code in syslog.py uses regex: mikrowizard(\d+):
    When manually configured, used prefix mikrowizard without number
    Logs were arriving but not being processed (regex didn’t match)
    Solution: Use prefix mikrowizard{device_id}, for example mikrowizard5

    Issue 2: Force Syslog uses peer_ip instead of default_ip

    When “Force Syslog” is enabled, MikroWizard takes peer_ip from the device record
    The peer_ip list only contains IP addresses from the server’s network interfaces
    For a server behind NAT, only the internal IP 192.168.10.2 is available
    The router’s external IP 1.1.1.1 is not available in the list
    Current solution: Add the external IP as an alias on the loopback interface

    Issue 3: Device ID changes when deleted and re-added

    When a device is deleted and re-added, the database ID changes
    Old syslog settings with prefix mikrowizard{old_id} stop working
    Need to either automatically update the prefix or use a different identifier (e.g., by IP address)

    Working Temporary Solution:

    Add external IP as an alias on the server:

    bashsudo ip addr add 1.1.1.1/32 dev lo label lo:ext

    Restart the mikroman container:

    bashsudo docker restart mikroman

    In the MikroWizard web interface, when editing the device, select peer_ip = 1.1.1.1
    Enable “Force Syslog” – now it will use the correct external address

    Improvement Suggestions:

    For servers behind NAT: Add a separate “External IP for Syslog” setting in System Settings, which will be used instead of peer_ip when Force Syslog is enabled
    Simplify prefix: Allow regex to accept both mikrowizard{id}: and just mikrowizard:, identifying the device by sender’s IP address
    Stable identifiers: When deleting/re-adding a device, preserve the ID or use another permanent identifier (MAC address, serial number)
    Automatic availability check: When configuring Force Syslog, check if the specified peer_ip is reachable from the device and warn if not