### Monitor System Resources using RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This example shows how to retrieve system resource information, including CPU usage, memory, disk space, and uptime, using the RouterOS REST API. It also includes an example for fetching the system identity. The `GET` method is used for retrieving this data. ```bash # Get system resources curl -X GET "https://192.168.88.1/rest/system/resource" \ -u admin:password \ -H "Content-Type: application/json" # Get system identity curl -X GET "https://192.168.88.1/rest/system/identity" \ -u admin:password \ -H "Content-Type: application/json" ``` -------------------------------- ### Manage Routing Table using RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This section details how to add and view static routes in the RouterOS routing table via the REST API. It includes examples for setting a default route and a route to a specific network, along with listing all configured routes. The `PUT` method is used for adding/updating routes, and `GET` for retrieval. ```bash # Add static default route curl -X PUT "https://192.168.88.1/rest/ip/route" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "dst-address": "0.0.0.0/0", "gateway": "192.168.88.254", "distance": 1, "comment": "Default route to ISP", "disabled": false }' # Add static route to specific network curl -X PUT "https://192.168.88.1/rest/ip/route" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "dst-address": "10.10.0.0/16", "gateway": "192.168.1.254", "distance": 1, "comment": "Route to branch office" }' # List all routes curl -X GET "https://192.168.88.1/rest/ip/route" \ -u admin:password \ -H "Content-Type: application/json" ``` -------------------------------- ### Setup DHCP Server Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Configure a DHCP server instance to automatically assign IP addresses to clients on a specified interface. Requires an associated IP address pool and supports customizable lease times. ```APIDOC ## Setup DHCP Server ### Description This section outlines the process for configuring a DHCP server on a RouterOS device. A DHCP server automatically assigns IP addresses, subnet masks, and other network configuration parameters to clients on a network. This setup typically involves defining an IP address pool and associating it with a specific network interface. ### Method POST / PUT ### Endpoint /rest/ip/dhcp-server ### Parameters #### Request Body (Example: Add DHCP Server instance) - **name** (string) - Required - A unique name for the DHCP server instance. - **interface** (string) - Required - The interface on which the DHCP server will operate (e.g., `bridge-lan`). - **address-pool** (string) - Required - The name of the IP address pool to use for assigning addresses. - **lease-time** (string) - Optional - The duration for which IP addresses are leased to clients (e.g., `1d 1:00:00` for 1 day and 1 hour). - **disabled** (boolean) - Optional - Whether to disable this DHCP server instance (defaults to `false`). ### Request Example (Add DHCP Server) ```bash # First, ensure you have an IP address pool configured # Example: POST /rest/ip/pool/add with {"name":"dhcp-pool-lan", "ranges":"192.168.88.100-192.168.88.200"} curl -X POST "https:///rest/ip/dhcp-server" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "dhcp-server-lan", "interface": "bridge-lan", "address-pool": "dhcp-pool-lan", "lease-time": "1d 1:00:00", "disabled": false }' ``` ### Response #### Success Response (200) Upon successful creation, the API typically returns the configuration of the newly created DHCP server instance, including its assigned ID. #### Response Example ```json { ".id": "*1", "name": "dhcp-server-lan", "interface": "bridge-lan", "address-pool": "dhcp-pool-lan", "lease-time": "1d 1:00:00", "disabled": false, "add-arp": false } ``` ### Request Example (List all DHCP servers) ```bash curl -X GET "https:///rest/ip/dhcp-server" \ -u admin:password \ -H "Content-Type: application/json" ``` ``` -------------------------------- ### Configure Firewall Filter Rules (Bash) Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Creates and manages firewall filter rules for packet filtering on RouterOS devices. Supports defining rules for input, forward, and output chains with various matching criteria like addresses, ports, and connection states. Includes examples for dropping invalid packets, allowing established connections, and allowing SSH from a specific subnet. ```bash # Add firewall rule to drop invalid packets curl -X PUT "https://192.168.88.1/rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "input", "action": "drop", "connection-state": "invalid", "comment": "Drop invalid connections", "disabled": false }' # Add rule to allow established/related connections curl -X PUT "https://192.168.88.1/rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "input", "action": "accept", "connection-state": "established,related", "comment": "Allow established connections" }' # Add rule to allow SSH from specific subnet curl -X PUT "https://192.168.88.1/rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "input", "action": "accept", "protocol": "tcp", "dst-port": "22", "src-address": "10.0.0.0/8", "comment": "Allow SSH from management network", "disabled": false }' # List all firewall rules curl -X GET "https://192.168.88.1/rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" # Response includes all rules with their order and configuration ``` -------------------------------- ### Configure NAT Rules using RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This snippet demonstrates how to configure Network Address Translation (NAT) rules using the RouterOS REST API. Examples include setting up a masquerade rule for internet sharing, port forwarding for HTTP and SSH services, and listing existing NAT rules. The `PUT` method adds/updates rules, while `GET` retrieves them. ```bash # Add masquerade rule for internet sharing curl -X PUT "https://192.168.88.1/rest/ip/firewall/nat" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "srcnat", "action": "masquerade", "out-interface": "ether1", "comment": "Masquerade LAN to WAN", "disabled": false }' # Port forward external port 80 to internal web server curl -X PUT "https://192.168.88.1/rest/ip/firewall/nat" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "dstnat", "action": "dst-nat", "protocol": "tcp", "dst-port": "80", "in-interface": "ether1", "to-addresses": "192.168.1.10", "to-ports": "80", "comment": "Forward HTTP to internal server" }' # Port forward SSH with port translation curl -X PUT "https://192.168.88.1/rest/ip/firewall/nat" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "dstnat", "action": "dst-nat", "protocol": "tcp", "dst-port": "2222", "in-interface": "ether1", "to-addresses": "192.168.1.20", "to-ports": "22", "comment": "Forward external port 2222 to internal SSH" }' # List NAT rules curl -X GET "https://192.168.88.1/rest/ip/firewall/nat" \ -u admin:password \ -H "Content-Type: application/json" ``` -------------------------------- ### System Backup and Configuration Export Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Provides endpoints for creating system backups, exporting configurations as text scripts, and managing backup files. ```APIDOC ## POST /rest/system/backup/save ### Description Creates a binary backup of the system configuration. ### Method POST ### Endpoint /rest/system/backup/save ### Parameters #### Request Body - **name** (string) - Required - The name for the backup file (e.g., "backup-YYYY-MM-DD"). - **password** (string) - Optional - A password to encrypt the backup file. - **dont-encrypt** (boolean) - Optional - If true, the backup will not be encrypted. Defaults to false. ### Request Example ```json { "name": "backup-2024-01-15", "password": "BackupPassword123", "dont-encrypt": false } ``` ### Response #### Success Response (200) An empty JSON object `{}` indicates success. #### Response Example ```json {} ``` ## POST /rest/export ### Description Exports the current system configuration as a text script. ### Method POST ### Endpoint /rest/export ### Parameters #### Request Body - **file** (string) - Required - The name of the file to save the exported configuration to. - **verbose** (boolean) - Optional - If true, includes comments and more detailed information in the export. Defaults to false. ### Request Example ```json { "file": "config-export-2024-01-15", "verbose": true } ``` ### Response #### Success Response (200) An empty JSON object `{}` indicates success. #### Response Example ```json {} ``` ## GET /rest/file ### Description Lists files in the system, with an option to filter by name. ### Method GET ### Endpoint /rest/file ### Parameters #### Query Parameters - **.query** (array) - Optional - An array of query conditions to filter files. For example, to list backup files: `[["name", "~", ".backup"]]`. ### Request Example ```json { ".query": [ ["name", "~", ".backup"] ] } ``` ### Response #### Success Response (200) An array of file objects, each containing details like name, type, size, and creation time. #### Response Example ```json [ { ".id": "*5", "name": "backup-2024-01-15.backup", "type": "backup", "size": 1048576, "creation-time": "jan/15/2024 10:30:00" } ] ``` ``` -------------------------------- ### Backup and Export RouterOS Configuration via REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Performs system backups and exports configurations as text scripts using curl commands to the RouterOS REST API. Supports creating binary backups with passwords and exporting configurations with verbose output. ```bash # Create binary backup curl -X POST "https://192.168.88.1/rest/system/backup/save" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "backup-2024-01-15", "password": "BackupPassword123", "dont-encrypt": false }' # Export configuration as script curl -X POST "https://192.168.88.1/rest/export" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "file": "config-export-2024-01-15", "verbose": true }' # List backup files curl -X GET "https://192.168.88.1/rest/file" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ ".query": [ ["name", "~", ".backup"] ] }' ``` -------------------------------- ### Add IP Address to Interface (Bash) Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Assigns an IP address with subnet mask to a network interface on the RouterOS device. Supports specifying network address, comments, and disabling the address. Includes an example for listing all IP addresses. ```bash # Add IP address to an interface curl -X POST "https://192.168.88.1/rest/ip/address/add" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "address": "192.168.1.1/24", "interface": "ether2", "network": "192.168.1.0", "comment": "LAN Gateway", "disabled": false }' # Response: { ".id": "*3", "address": "192.168.1.1/24", "interface": "ether2", "network": "192.168.1.0", "comment": "LAN Gateway", "disabled": false, "invalid": false, "dynamic": false } # List all IP addresses curl -X GET "https://192.168.88.1/rest/ip/address" \ -u admin:password \ -H "Content-Type: application/json" ``` -------------------------------- ### List Network Interfaces (Bash) Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Retrieves all network interfaces configured on the RouterOS device. Supports fetching all interfaces or a specific interface by its number. Returns detailed status and configuration for each interface. ```bash # List all interfaces curl -X GET "https://192.168.88.1/rest/interface" \ -u admin:password \ -H "Content-Type: application/json" # Response: [ { ".id": "*1", "name": "ether1", "type": "ether", "mtu": 1500, "actual-mtu": 1500, "mac-address": "48:8F:5A:12:34:56", "running": true, "disabled": false, "comment": "WAN Interface", "rx-byte": 1048576000, "tx-byte": 524288000, "rx-packet": 1000000, "tx-packet": 500000, "link-downs": 0 }, { ".id": "*2", "name": "ether2", "type": "ether", "mtu": 1500, "running": true, "disabled": false, "comment": "LAN Interface" } ] # Get specific interface by number curl -X GET "https://192.168.88.1/rest/interface?number=*1" \ -u admin:password \ -H "Content-Type: application/json" ``` -------------------------------- ### Configure DHCP Server using RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This snippet shows how to create an IP pool, define a DHCP network, and add a DHCP server using the RouterOS REST API. It requires administrative access to the RouterOS device and specifies parameters like IP ranges, gateway, DNS servers, and lease times. ```bash curl -X POST "https://192.168.88.1/rest/ip/pool/add" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "dhcp-pool", "ranges": "192.168.1.100-192.168.1.200" }' curl -X POST "https://192.168.88.1/rest/ip/dhcp-server/network/add" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "address": "192.168.1.0/24", "gateway": "192.168.1.1", "dns-server": "8.8.8.8,8.8.4.4", "domain": "lan.local", "comment": "LAN DHCP Network" }' curl -X POST "https://192.168.88.1/rest/ip/dhcp-server/add" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "dhcp-lan", "interface": "ether2", "address-pool": "dhcp-pool", "lease-time": "1d", "disabled": false, "comment": "LAN DHCP Server" }' # View active DHCP leases curl -X GET "https://192.168.88.1/rest/ip/dhcp-server/lease" \ -u admin:password \ -H "Content-Type: application/json" ``` -------------------------------- ### Bulk Operations with Query Filters using RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This snippet illustrates how to perform bulk operations on RouterOS devices using the REST API with query filters. It covers finding resources based on criteria, and then performing actions like disabling or removing multiple items in a single request. ```bash # Find and disable all firewall rules with specific comment curl -X POST "https://192.168.88.1/rest/ip/firewall/filter/find" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ ".query": [ ["comment", "~", "temp"] ] }' # Bulk disable multiple items curl -X POST "https://192.168.88.1/rest/ip/firewall/filter/disable" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "numbers": ["*10", "*11", "*15"] }' # Remove multiple DHCP leases curl -X POST "https://192.168.88.1/rest/ip/dhcp-server/lease/remove" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ ".query": [ ["status", "=", "waiting"] ] }' ``` -------------------------------- ### Routing Table Management Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt APIs for adding and viewing static and dynamic routes in the routing table. ```APIDOC ## PUT /rest/ip/route ### Description Adds or modifies a static route in the routing table. Use POST for specific operations if needed, but PUT is common for adding/changing routes. ### Method PUT ### Endpoint `/rest/ip/route` ### Parameters #### Request Body - **dst-address** (string) - Required - The destination network address in CIDR notation. - **gateway** (string) - Required - The IP address of the gateway. - **distance** (integer) - Optional - The metric (distance) of the route. - **comment** (string) - Optional - A descriptive comment for the route. - **disabled** (boolean) - Optional - Whether the route is disabled. ### Request Example ```json { "dst-address": "0.0.0.0/0", "gateway": "192.168.88.254", "distance": 1, "comment": "Default route to ISP", "disabled": false } ``` ## GET /rest/ip/route ### Description Retrieves a list of all routes (static and dynamic) in the routing table. ### Method GET ### Endpoint `/rest/ip/route` ### Parameters None. ### Response #### Success Response (200) - Returns a list of route objects, including destination, gateway, distance, and status. #### Response Example ```json [ { ".id": "*1", "dst-address": "0.0.0.0/0", "gateway": "192.168.88.254", "gateway-status": "192.168.88.254 reachable ether1", "distance": 1, "scope": 30, "active": true, "dynamic": false, "comment": "Default route to ISP" } ] ``` ``` -------------------------------- ### Execute Diagnostic Tools with RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This snippet demonstrates how to use the RouterOS REST API to execute various network diagnostic tools, including ping, traceroute, bandwidth tests, and DNS lookups. The results are returned in a structured JSON format, suitable for automated analysis. ```bash # Ping a host curl -X POST "https://192.168.88.1/rest/tool/ping" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "address": "8.8.8.8", "count": 5, "size": 64 }' # Traceroute curl -X POST "https://192.168.88.1/rest/tool/traceroute" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "address": "google.com", "count": 1 }' # Bandwidth test between routers curl -X POST "https://192.168.88.1/rest/tool/bandwidth-test" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "address": "192.168.10.1", "protocol": "tcp", "direction": "both", "duration": "10s", "user": "admin", "password": "password" }' # DNS lookup curl -X POST "https://192.168.88.1/rest/tool/dns-lookup" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "example.com", "server": "8.8.8.8" }' ``` -------------------------------- ### System Resource Monitoring Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt APIs for retrieving system resource utilization, including CPU, memory, disk space, and system identity. ```APIDOC ## GET /rest/system/resource ### Description Retrieves real-time system resource utilization information. ### Method GET ### Endpoint `/rest/system/resource` ### Parameters None. ### Response #### Success Response (200) - **uptime** (string) - System uptime. - **version** (string) - RouterOS version. - **build-time** (string) - Build date and time. - **free-memory** (integer) - Amount of free memory in bytes. - **total-memory** (integer) - Total amount of memory in bytes. - **cpu** (string) - CPU model. - **cpu-count** (integer) - Number of CPU cores. - **cpu-frequency** (integer) - CPU frequency in MHz. - **cpu-load** (integer) - Current CPU load percentage. - **free-hdd-space** (integer) - Free hard drive space in bytes. - **total-hdd-space** (integer) - Total hard drive space in bytes. - **architecture-name** (string) - CPU architecture name. - **board-name** (string) - Board name. - **platform** (string) - Platform type. #### Response Example ```json { "uptime": "2w3d04:23:15", "version": "7.21beta8 (testing)", "build-time": "Dec/15/2024 10:23:45", "free-memory": 134217728, "total-memory": 268435456, "cpu": "ARMv7", "cpu-count": 4, "cpu-frequency": 1400, "cpu-load": 5, "free-hdd-space": 104857600, "total-hdd-space": 134217728, "write-sect-since-reboot": 12345, "write-sect-total": 987654, "architecture-name": "arm", "board-name": "RB750Gr3", "platform": "MikroTik" } ``` ## GET /rest/system/identity ### Description Retrieves the system identity (hostname) of the router. ### Method GET ### Endpoint `/rest/system/identity` ### Parameters None. ### Response #### Success Response (200) - **name** (string) - The name (hostname) of the system. #### Response Example ```json { "name": "MikroTik-Router-01" } ``` ``` -------------------------------- ### Manage User Accounts with RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This snippet demonstrates how to create, list, and disable user accounts on a RouterOS device using the REST API. It covers basic user management operations and requires authentication with admin credentials. ```bash # List all users curl -X GET "https://192.168.88.1/rest/user" \ -u admin:password \ -H "Content-Type: application/json" # Add new user curl -X POST "https://192.168.88.1/rest/user/add" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "operator1", "password": "SecurePass123!", "group": "read", "address": "10.0.0.0/8", "comment": "Network operator - read-only access", "disabled": false }' # Add admin user curl -X POST "https://192.168.88.1/rest/user/add" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "admin2", "password": "VerySecure456!", "group": "full", "comment": "Secondary administrator" }' # Disable a user curl -X POST "https://192.168.88.1/rest/user/disable" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "numbers": ["*3"] }' ``` -------------------------------- ### DHCP Server Management Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt APIs for creating IP pools, DHCP network configurations, and DHCP servers. ```APIDOC ## POST /rest/ip/pool/add ### Description Creates a new IP address pool. ### Method POST ### Endpoint `/rest/ip/pool/add` ### Parameters #### Request Body - **name** (string) - Required - The name of the IP pool. - **ranges** (string) - Required - A comma-separated list of IP address ranges. ### Request Example ```json { "name": "dhcp-pool", "ranges": "192.168.1.100-192.168.1.200" } ``` ## POST /rest/ip/dhcp-server/network/add ### Description Creates a new DHCP server network configuration. ### Method POST ### Endpoint `/rest/ip/dhcp-server/network/add` ### Parameters #### Request Body - **address** (string) - Required - The network address in CIDR notation. - **gateway** (string) - Optional - The default gateway for the network. - **dns-server** (string) - Optional - A comma-separated list of DNS servers. - **domain** (string) - Optional - The domain name for the network. - **comment** (string) - Optional - A descriptive comment for the network. ### Request Example ```json { "address": "192.168.1.0/24", "gateway": "192.168.1.1", "dns-server": "8.8.8.8,8.8.4.4", "domain": "lan.local", "comment": "LAN DHCP Network" } ``` ## POST /rest/ip/dhcp-server/add ### Description Adds a new DHCP server to a specified interface. ### Method POST ### Endpoint `/rest/ip/dhcp-server/add` ### Parameters #### Request Body - **name** (string) - Required - The name of the DHCP server. - **interface** (string) - Required - The interface to which the DHCP server will be bound. - **address-pool** (string) - Required - The name of the IP pool to use for address assignment. - **lease-time** (string) - Optional - The lease time for DHCP addresses (e.g., "1d"). - **disabled** (boolean) - Optional - Whether the DHCP server is disabled (default is false). - **comment** (string) - Optional - A descriptive comment for the DHCP server. ### Request Example ```json { "name": "dhcp-lan", "interface": "ether2", "address-pool": "dhcp-pool", "lease-time": "1d", "disabled": false, "comment": "LAN DHCP Server" } ``` ### Response #### Success Response (200) - **.id** (string) - The unique identifier of the created DHCP server. - **name** (string) - The name of the DHCP server. - **interface** (string) - The interface the DHCP server is bound to. - **address-pool** (string) - The IP pool used by the DHCP server. - **lease-time** (string) - The lease time configured for the DHCP server. - **disabled** (boolean) - Indicates if the DHCP server is disabled. #### Response Example ```json { ".id": "*5", "name": "dhcp-lan", "interface": "ether2", "address-pool": "dhcp-pool", "lease-time": "1d", "disabled": false } ``` ## GET /rest/ip/dhcp-server/lease ### Description Retrieves a list of active DHCP leases. ### Method GET ### Endpoint `/rest/ip/dhcp-server/lease` ### Parameters None. ### Response #### Success Response (200) - Returns a list of DHCP lease objects, each containing details like client IP, MAC address, and lease status. ### Response Example ```json [ { "mac-address": "AA:BB:CC:DD:EE:FF", "address": "192.168.1.101", "lease-time": "1d 00:00:00", "server": "dhcp-lan" } ] ``` ``` -------------------------------- ### Configure Wireless Interfaces with RouterOS REST API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt This snippet shows how to configure wireless interfaces on a RouterOS device, including creating security profiles and setting up access point configurations. It utilizes the REST API to manage wireless settings like SSID, band, and security. ```bash # Create security profile curl -X POST "https://192.168.88.1/rest/interface/wireless/security-profiles/add" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "name": "wifi-security", "mode": "dynamic-keys", "authentication-types": ["wpa2-psk"], "wpa2-pre-shared-key": "MySecureWiFiPassword123", "comment": "WPA2 PSK Profile" }' # Configure wireless interface curl -X PATCH "https://192.168.88.1/rest/interface/wireless/wlan1" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "mode": "ap-bridge", "ssid": "MyNetwork-5G", "security-profile": "wifi-security", "frequency": "auto", "band": "5ghz-a/n/ac", "channel-width": "20/40/80mhz-XXXX", "country": "united states3", "disabled": false, "comment": "Main 5GHz AP" }' # List wireless interfaces and their status curl -X GET "https://192.168.88.1/rest/interface/wireless" \ -u admin:password \ -H "Content-Type: application/json" # View connected wireless clients curl -X GET "https://192.168.88.1/rest/interface/wireless/registration-table" \ -u admin:password \ -H "Content-Type: application/json" ``` -------------------------------- ### Enable Interfaces Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Enables all interfaces that match the specified criteria. This is useful for bulk enabling interfaces based on type or status. ```APIDOC ## POST /rest/interface/enable ### Description Enables all interfaces matching the provided query criteria. ### Method POST ### Endpoint /rest/interface/enable ### Parameters #### Request Body - **.query** (array) - Required - An array of query conditions to filter interfaces. Each condition is an array with three elements: field, operator, and value. ### Request Example ```json { ".query": [ ["type", "=", "ether"], ["disabled", "=", "true"] ] } ``` ### Response #### Success Response (200) An empty JSON object `{}` indicates success. #### Response Example ```json {} ``` ``` -------------------------------- ### Configure Firewall Filter Rules Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Create and manage firewall filter rules for packet filtering. Supports various matching criteria and actions across different chains. ```APIDOC ## PUT /rest/ip/firewall/filter ### Description Adds or updates a firewall filter rule. This endpoint allows for granular control over packet filtering by defining chains, actions, and various matching criteria such as addresses, ports, protocols, connection states, and interfaces. ### Method PUT ### Endpoint /rest/ip/firewall/filter ### Parameters #### Request Body - **chain** (string) - Required - The firewall chain to apply the rule to (e.g., `input`, `forward`, `output`). - **action** (string) - Required - The action to take for matching packets (e.g., `accept`, `drop`, `reject`). - **connection-state** (string) - Optional - Match packets based on connection state (e.g., `invalid`, `established,related`). - **protocol** (string) - Optional - Match packets based on the protocol (e.g., `tcp`, `udp`). - **dst-port** (string) - Optional - Match packets destined for a specific port (e.g., `22`). - **src-address** (string) - Optional - Match packets originating from a specific source IP address or subnet (e.g., `10.0.0.0/8`). - **comment** (string) - Optional - A descriptive comment for the firewall rule. - **disabled** (boolean) - Optional - Whether to disable this firewall rule (defaults to `false`). ### Request Example (Drop invalid connections) ```bash curl -X PUT "https:///rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "input", "action": "drop", "connection-state": "invalid", "comment": "Drop invalid connections", "disabled": false }' ``` ### Request Example (Allow established/related connections) ```bash curl -X PUT "https:///rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "input", "action": "accept", "connection-state": "established,related", "comment": "Allow established connections" }' ``` ### Request Example (Allow SSH from specific subnet) ```bash curl -X PUT "https:///rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" \ -d '{ "chain": "input", "action": "accept", "protocol": "tcp", "dst-port": "22", "src-address": "10.0.0.0/8", "comment": "Allow SSH from management network", "disabled": false }' ``` ### Response #### Success Response (200) The response typically confirms the successful addition or update of the rule, potentially returning the rule's configuration details. ### Request Example (List all firewall rules) ```bash curl -X GET "https:///rest/ip/firewall/filter" \ -u admin:password \ -H "Content-Type: application/json" ``` ### Response Example (List all firewall rules) ```json # Response includes all rules with their order and configuration [ { ".id": "*0", "chain": "input", "action": "drop", "connection-state": "invalid", "comment": "Drop invalid connections", "disabled": false }, { ".id": "*1", "chain": "input", "action": "accept", "connection-state": "established,related", "comment": "Allow established connections" }, { ".id": "*2", "chain": "input", "action": "accept", "protocol": "tcp", "dst-port": "22", "src-address": "10.0.0.0/8", "comment": "Allow SSH from management network", "disabled": false } ] ``` ``` -------------------------------- ### NAT Rule Configuration Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt APIs for configuring NAT rules, including masquerading, port forwarding, and destination NAT. ```APIDOC ## PUT /rest/ip/firewall/nat ### Description Adds or modifies a NAT rule in the firewall NAT table. ### Method PUT ### Endpoint `/rest/ip/firewall/nat` ### Parameters #### Request Body - **chain** (string) - Required - The NAT chain (e.g., "srcnat", "dstnat"). - **action** (string) - Required - The action to perform (e.g., "masquerade", "dst-nat"). - **out-interface** (string) - Optional - The outgoing interface for srcnat rules. - **chain** (string) - Required - The NAT chain (e.g., "srcnat", "dstnat"). - **action** (string) - Required - The action to perform (e.g., "masquerade", "dst-nat"). - **protocol** (string) - Optional - The protocol for the rule (e.g., "tcp", "udp"). - **dst-port** (string) - Optional - The destination port for dstnat rules. - **in-interface** (string) - Optional - The incoming interface for dstnat rules. - **to-addresses** (string) - Optional - The destination IP address for dst-nat. - **to-ports** (string) - Optional - The destination port for dst-nat. - **comment** (string) - Optional - A descriptive comment for the NAT rule. - **disabled** (boolean) - Optional - Whether the NAT rule is disabled. ### Request Example (Masquerade) ```json { "chain": "srcnat", "action": "masquerade", "out-interface": "ether1", "comment": "Masquerade LAN to WAN", "disabled": false } ``` ### Request Example (Port Forward) ```json { "chain": "dstnat", "action": "dst-nat", "protocol": "tcp", "dst-port": "80", "in-interface": "ether1", "to-addresses": "192.168.1.10", "to-ports": "80", "comment": "Forward HTTP to internal server" } ``` ## GET /rest/ip/firewall/nat ### Description Retrieves a list of all configured NAT rules. ### Method GET ### Endpoint `/rest/ip/firewall/nat` ### Parameters None. ### Response #### Success Response (200) - Returns a list of NAT rule objects, each containing details about the rule's configuration. ### Response Example ```json [ { "chain": "srcnat", "action": "masquerade", "out-interface": "ether1", "comment": "Masquerade LAN to WAN" } ] ``` ``` -------------------------------- ### Wireless Interface Configuration API Source: https://context7.com/cr4ckpwd/routeros-rest-api/llms.txt Configure and manage wireless interfaces, including security profiles, SSIDs, and client management. Supports advanced standards and centralized management. ```APIDOC ## POST /rest/interface/wireless/security-profiles/add ### Description Creates a new wireless security profile. ### Method POST ### Endpoint /rest/interface/wireless/security-profiles/add ### Parameters #### Request Body - **name** (string) - Required - The name for the security profile. - **mode** (string) - Required - The security mode (e.g., "dynamic-keys", "static-keys"). - **authentication-types** (array of strings) - Required - Array of authentication types (e.g., ["wpa2-psk"]). - **wpa2-pre-shared-key** (string) - Required if mode is "dynamic-keys" - The WPA2 Pre-Shared Key. - **comment** (string) - Optional - A descriptive comment for the profile. ### Request Example ```json { "name": "wifi-security", "mode": "dynamic-keys", "authentication-types": ["wpa2-psk"], "wpa2-pre-shared-key": "MySecureWiFiPassword123", "comment": "WPA2 PSK Profile" } ``` ### Response #### Success Response (200) - **.id** (string) - The unique identifier of the new security profile. #### Response Example ```json { ".id": "*1" } ``` ## PATCH /rest/interface/wireless/[interface-name] ### Description Configures a specific wireless interface. ### Method PATCH ### Endpoint /rest/interface/wireless/[interface-name] (e.g., /rest/interface/wireless/wlan1) ### Parameters #### Path Parameters - **interface-name** (string) - Required - The name of the wireless interface to configure (e.g., "wlan1"). #### Request Body - **mode** (string) - Optional - The operating mode (e.g., "ap-bridge"). - **ssid** (string) - Optional - The Service Set Identifier (SSID) for the network. - **security-profile** (string) - Optional - The name of the security profile to use. - **frequency** (string) - Optional - The operating frequency (e.g., "auto", "2412"). - **band** (string) - Optional - The wireless band (e.g., "2ghz-b/g/n", "5ghz-a/n/ac"). - **channel-width** (string) - Optional - The channel width (e.g., "20/40/80mhz-XXXX"). - **country** (string) - Optional - The country code for regulatory compliance. - **disabled** (boolean) - Optional - Whether the interface is disabled. - **comment** (string) - Optional - A descriptive comment for the interface. ### Request Example ```json { "mode": "ap-bridge", "ssid": "MyNetwork-5G", "security-profile": "wifi-security", "frequency": "auto", "band": "5ghz-a/n/ac", "channel-width": "20/40/80mhz-XXXX", "country": "united states3", "disabled": false, "comment": "Main 5GHz AP" } ``` ### Response #### Success Response (200) Returns an empty object or a success message upon successful configuration. #### Response Example ```json {} ``` ## GET /rest/interface/wireless ### Description Retrieves a list of all wireless interfaces and their current status. ### Method GET ### Endpoint /rest/interface/wireless ### Parameters None ### Request Example ```bash curl -X GET "https:///rest/interface/wireless" \ -u admin:password \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **\[\]** (array) - Array of wireless interface objects. #### Response Example ```json [ { ".id": "*4", "name": "wlan1", "mac-address": "AA:BB:CC:DD:EE:FF", "ssid": "MyNetwork-5G", "running": true, "disabled": false } ] ``` ## GET /rest/interface/wireless/registration-table ### Description Retrieves a list of currently connected wireless clients. ### Method GET ### Endpoint /rest/interface/wireless/registration-table ### Parameters None ### Request Example ```bash curl -X GET "https:///rest/interface/wireless/registration-table" \ -u admin:password \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **\[\]** (array) - Array of connected client objects, including details like signal strength and rates. #### Response Example ```json [ { ".id": "00:11:22:33:44:55", "interface": "wlan1", "ssid": "MyNetwork-5G", "registered": true, "connected": true, "signal-strength": -55, "tx-rate": "866.7Mbps" } ] ``` ```