Join the Conversation

To sign in, use your existing MySonicWall account. To create a free MySonicWall account click "Register".


How can I get internet connection status from TZ470?

HKIHKI Newbie ✭

I want to know if the physical ethernet link connected to the router is up or not within a few seconds using python.

Category: Developer Hub

Best Answer

  • Options
    JaimeJaime SonicWall Employee
    Answer ✓

    I think there are probably better methods of determining WAN connectivity or link status that may be more reliable or polished as a product. Some examples are:

    • Using the built-in logs and email alerting (if you have an internal email server that can alert you to a down interface).
    • Using SNMP or NetFlow/IPFIX collectors. These utilities usually have some level of reporting and alerting. These often include other forms of monitoring such as ICMP, TCP, etc.
    • Using the built-in Network Monitor Probes feature can also report connectivity issues (again, alerts would require an accessible email server or watching logs).
    • Syslog servers may be able to provide some kind of alerting/reporting for certain events.

    That's just what I can think of right off the top of my head. But to answer your question specifically, you can use SonicOS API to get the link status.

    The general steps:

    1. Authenticate to SonicOS API (POST to /api/sonicos/auth).
    2. Get the IPv4 interface status of all interfaces (GET to /api/sonicos/reporting/interfaces/ipv4/status). This will return JSON data with the interface information, including link status.
    3. Alternatively, you can get the status of a specific interface by name (GET to /api/sonicos/reporting/interfaces/ipv4/status/name/X1)
    4. If getting the status of all interfaces, you can loop through the entries in the returned JSON data to return just the name and link status if that's all you're looking for.

    The response JSON will look like this (note there are differences in the response between the two endpoints provided above):

        "name": "X1",
        "zone": "WAN",
        "type": "Wire",
        "ip_mode": "DHCP",
        "ip_address": "",
        "subnet_mask": "",
        "connected": null,
        "status": "1 Gbps Full Duplex",
        "link_settings": "Auto Negotiate",
        "link_isgigabit": 1000,
        "link_ability_bmp_low": 3590324271,
        "link_ability_bmp_high": 0,
        "group": " Default LB Group",
        "enabled": true,
        "configurable": true,
        "deletable": false,
        "comment": "Default WAN"

    Hope this helps!


Sign In or Register to comment.