Skip to content

ubus commands

Schnup89 edited this page Apr 20, 2020 · 36 revisions

I think not everyone is familiar how to retrieve and analyse the ubus data, therefore we can provide a list of successfull tested calls an the result of them here:

ubus call network.interface.wan status

Get information for routed interfaces (e.g. wan, lan, tun)

ubus call network.interface dump will get the information of all available interfaces!

{
        "up": true,
        "pending": false,
        "available": true,
        "autostart": true,
        "dynamic": false,
        "uptime": 1046801,
        "l3_device": "pppoe-wan",
        "proto": "pppoe",
        "device": "eth0.2",
        "updated": [
                "addresses",
                "routes"
        ],
        "metric": 0,
        "dns_metric": 0,
        "delegation": true,
        "ipv4-address": [
                {
                        "address": "79.249.207.211",
                        "mask": 32,
                        "ptpaddress": "62.155.246.166"
                }
        ],
        "ipv6-address": [
                {
                        "address": "fe80::74c0:5ec0:7a4c:9c18",
                        "mask": 128
                }
        ],
        "ipv6-prefix": [

        ],
        "ipv6-prefix-assignment": [

        ],
        "route": [
                {
                        "target": "0.0.0.0",
                        "mask": 0,
                        "nexthop": "62.155.246.166",
                        "source": "0.0.0.0\/0"
                }
        ],
        "dns-server": [
                "8.8.8.8"
        ],
        "dns-search": [

        ],
        "inactive": {
                "ipv4-address": [

                ],
                "ipv6-address": [

                ],
                "route": [

                ],
                "dns-server": [
                        "217.237.151.205",
                        "217.237.148.70"
                ],
                "dns-search": [

                ]
        },
        "data": {

        }
}

ubus call hostapd.wlan1 get_clients

Get information of connected wifi clients on wlanX

{
        "freq": 2422,
        "clients": {
                "ec:fa:bc:9a:xx:xx": {
                        "auth": true,
                        "assoc": true,
                        "authorized": true,
                        "preauth": false,
                        "wds": false,
                        "wmm": true,
                        "ht": true,
                        "vht": false,
                        "wps": false,
                        "mfp": false,
                        "rrm": [
                                0,
                                0,
                                0,
                                0,
                                0
                        ],
                        "aid": 3
                },
                "84:f3:eb:3e:yy:yy": {
                        "auth": true,
                        "assoc": true,
                        "authorized": true,
                        "preauth": false,
                        "wds": false,
                        "wmm": false,
                        "ht": false,
                        "vht": false,
                        "wps": false,
                        "mfp": false,
                        "rrm": [
                                0,
                                0,
                                0,
                                0,
                                0
                        ],
                        "aid": 4
                }
        }
}

ubus call system board

Get board/hardware informations

{
        "kernel": "4.9.184",
        "hostname": "OpenWrt",
        "system": "Qualcomm Atheros QCA9558 ver 1 rev 0",
        "model": "TP-Link Archer C7 v2",
        "board_name": "archer-c7",
        "release": {
                "distribution": "OpenWrt",
                "version": "18.06.4",
                "revision": "r7808-ef686b7292",
                "target": "ar71xx\/generic",
                "description": "OpenWrt 18.06.4 r7808-ef686b7292"
        }
}

ubus call system info

Get system informations like uptime and load

{
        "localtime": 1587400204,
        "uptime": 1192311,
        "load": [
                544,
                3200,
                160
        ],
        "memory": {
                "total": 128270336,
                "free": 73379840,
                "shared": 1523712,
                "buffered": 2412544
        },
        "swap": {
                "total": 0,
                "free": 0
        }
}

ubus call network.device status '{ "name": "eth0" }'

Gets detailed information for specific Interface

Optional: Information for all present iunterfaces with "ubus call network.device status" [Without Parameter]

{
        "external": false,
        "present": true,
        "type": "Network device",
        "up": true,
        "carrier": true,
        "link-advertising": [
                "1000baseT-F"
        ],
        "link-partner-advertising": [

        ],
        "link-supported": [
                "1000baseT-F"
        ],
        "speed": "1000F",
        "autoneg": true,
        "mtu": 1500,
        "mtu6": 1500,
        "macaddr": "a4:2b:b0:df:29:32",
        "txqueuelen": 1000,
        "ipv6": true,
        "promisc": false,
        "rpfilter": 0,
        "acceptlocal": false,
        "igmpversion": 0,
        "mldversion": 0,
        "neigh4reachabletime": 30000,
        "neigh6reachabletime": 30000,
        "neigh4gcstaletime": 60,
        "neigh6gcstaletime": 60,
        "neigh4locktime": 100,
        "dadtransmits": 1,
        "multicast": true,
        "sendredirects": true,
        "statistics": {
                "collisions": 0,
                "rx_frame_errors": 0,
                "tx_compressed": 0,
                "multicast": 0,
                "rx_length_errors": 0,
                "tx_dropped": 0,
                "rx_bytes": 3637258551,
                "rx_missed_errors": 0,
                "tx_errors": 0,
                "rx_compressed": 0,
                "rx_over_errors": 0,
                "tx_fifo_errors": 0,
                "rx_crc_errors": 0,
                "rx_packets": 195581562,
                "tx_heartbeat_errors": 0,
                "rx_dropped": 0,
                "tx_aborted_errors": 0,
                "tx_packets": 87057610,
                "rx_errors": 0,
                "tx_bytes": 1985289429,
                "tx_window_errors": 0,
                "rx_fifo_errors": 5182,
                "tx_carrier_errors": 0
        }
}

Template

Some words about what we will get with the Command

{
        "temp": "late"
}
Clone this wiki locally