Changes

Line 13: Line 13:  
* One RUTxxx series router.<br>
 
* One RUTxxx series router.<br>
 
'''Configuration scheme:'''
 
'''Configuration scheme:'''
[[File:{{{file_scheme}}}|border|class=tlt-border|center]]
+
[[File:{{{file_scheme}}}|border|class=tlt-border]]
    
==Enabling JSON-RPC==
 
==Enabling JSON-RPC==
 
Before anything else, you'll need to make sure JSON-RPC is enabled on your router. JSON-RPC is enabled by default, so if you haven't made any changes to the router's access settings, everything should be in order. Otherwise you can check JSON-RPC status by logging into your router's WebUI and navigating to '''System → Administration → Access Control'''. Look for the ''WebUI'' section; there will be an '''Enable JSON RPC''' field. Make sure it is checked:
 
Before anything else, you'll need to make sure JSON-RPC is enabled on your router. JSON-RPC is enabled by default, so if you haven't made any changes to the router's access settings, everything should be in order. Otherwise you can check JSON-RPC status by logging into your router's WebUI and navigating to '''System → Administration → Access Control'''. Look for the ''WebUI'' section; there will be an '''Enable JSON RPC''' field. Make sure it is checked:
   −
[[File:WEBUI JSON.jpg|border|class=tlt-border|center]]
+
[[File:WEBUI JSON.jpg|border|class=tlt-border]]
   −
==Using JSON-RPC with Linux OS==
+
==Using JSON-RPC (Linux)==
   −
This section describes how to use JSON-RPC commands with a Linux OS system. To find the guide for Windows users, jump to this section: '''[[Monitoring_via_JSON-RPC#Using_JSON-RPC_with_Windows_OS|JSON-RPC on Widnows]]'''
+
This section describes how to use JSON-RPC commands with a Linux OS system. To find the guide for Windows users, jump to this section: '''[[{{{link}}}|JSON-RPC on Widnows]]'''
    
===Obtaining a session ID===
 
===Obtaining a session ID===
Line 30: Line 30:  
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"00000000000000000000000000000000\", \"session\", \"login\", { \"username\": \"root\", \"password\": \"<span style=color:orange>admin01</span>\"  } ] }" http://<span style=color:green>192.168.1.1</span>/ubus   
 
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"00000000000000000000000000000000\", \"session\", \"login\", { \"username\": \"root\", \"password\": \"<span style=color:orange>admin01</span>\"  } ] }" http://<span style=color:green>192.168.1.1</span>/ubus   
   −
The section highlighted in orange is the router's admin password. admin01 is the default value, replace it with your router's password. The address highlighted in green is the router's IP address. Replace this value with your router's IP. If you're trying to reach the router from '''[[LAN]]''', use the local IP address (default: 192.168.1.1), if you're trying to reach the router from '''[[WAN]]''', use the router's WAN IP address.
+
The section highlighted in orange is the router's admin password. admin01 is the default value, replace it with your router's password. The address highlighted in green is the router's IP address. Replace this value with your router's IP. If you're trying to reach the router from '''[[{{{name}}}_LAN|LAN]]''', use the local IP address (default: 192.168.1.1), if you're trying to reach the router from '''[[{{{name}}} WAN|WAN]]''', use the router's WAN IP address.
      −
[[Image:Configuration examples json-rpc terminal get id.png]]
+
[[Image:Configuration examples json-rpc terminal get id.png|961px]]
    
The picture above depicts the process of obtaining a Session ID. The ID itself is encapsulated in a blue rectangle. Copy this ID as you will need it to authenticate yourself when using other commands.
 
The picture above depicts the process of obtaining a Session ID. The ID itself is encapsulated in a blue rectangle. Copy this ID as you will need it to authenticate yourself when using other commands.
Line 39: Line 39:  
===Getting router parameters===
 
===Getting router parameters===
 
----
 
----
Now that you have obtained a Session ID, you can issue commands to the router. Lets start with commands that return information about the router. For example, this is a command that returns the router's '''[[RSSI]]'''(signal strength) value:
+
Now that you have obtained a Session ID, you can issue commands to the router. Lets start with commands that return information about the router.  
 +
====Getting RSSI====
 +
----
 +
This is a command that returns the router's '''[[RSSI]]'''(signal strength) value:
    
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"<span style=color:red>a74c8e07646f0da2bfddce35bf3de1f3</span>\", \"file\", \"exec\", { \"command\":\"<span style=color:orange>gsmctl</span>\", \"params\": [\"<span style=color:green>-q</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"<span style=color:red>a74c8e07646f0da2bfddce35bf3de1f3</span>\", \"file\", \"exec\", { \"command\":\"<span style=color:orange>gsmctl</span>\", \"params\": [\"<span style=color:green>-q</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
Highlighted in red is the Session ID. Replace it with the Session ID that was provided to you. Highlighted in orange is the command that we used for our query and highlighted in green is the parameter for the command: '''gsmctl -q'''.
 
Highlighted in red is the Session ID. Replace it with the Session ID that was provided to you. Highlighted in orange is the command that we used for our query and highlighted in green is the parameter for the command: '''gsmctl -q'''.
   −
The picture bellow is a visual representation of this example. Encapsulated in a blue rectangle is the answer to the ''gsmctl -q'' query: '''-69 dBm'''.  
+
The picture bellow is a visual representation of this example. Encapsulated in a blue rectangle is the answer to the ''gsmctl -q'' query: '''-73 dBm'''.  
      −
[[Image:Configuration examples json-rpc terminal gsmctl.png]]
+
[[Image:Configuration examples json-rpc terminal gsmctl.png|961px]]
    
You can issue almost any Linux command in a similar manner. For example, if you wish to get a list of file names contained in the config folder, the Linux command to do so would be '''ls /etc/config''', which, translated to JSON-RPC, would be:
 
You can issue almost any Linux command in a similar manner. For example, if you wish to get a list of file names contained in the config folder, the Linux command to do so would be '''ls /etc/config''', which, translated to JSON-RPC, would be:
Line 53: Line 56:  
  curl -d "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"a74c8e07646f0da2bfddce35bf3de1f3\", \"file\", \"exec\", {\"command\":\"<span style=color:orange>ls</span>\", \"params\": [\"<span style=color:orange>/etc/config</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  curl -d "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"a74c8e07646f0da2bfddce35bf3de1f3\", \"file\", \"exec\", {\"command\":\"<span style=color:orange>ls</span>\", \"params\": [\"<span style=color:orange>/etc/config</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
   −
[[Image:Configuration examples json-rpc terminal ls.png]]
+
[[Image:Configuration examples json-rpc terminal ls.png|961px]]
    
The command is encapsulated in an orange rectangle and the answer - in a blue one.
 
The command is encapsulated in an orange rectangle and the answer - in a blue one.
Line 61: Line 64:  
This section will describe how to use '''uci set''' commands in order to set or change various router parameters via JSON-RPC. For more general information about the usage and syntax of UCI commands, check out our '''[[UCI command usage]]''' guide.
 
This section will describe how to use '''uci set''' commands in order to set or change various router parameters via JSON-RPC. For more general information about the usage and syntax of UCI commands, check out our '''[[UCI command usage]]''' guide.
   −
====uci set====
+
====UCI SET====
 
----
 
----
 
The ''uci set'' command is used to set router parameters. As an example, lets try to change the router's '''LAN IP address'''. The command to do so looks like this:
 
The ''uci set'' command is used to set router parameters. As an example, lets try to change the router's '''LAN IP address'''. The command to do so looks like this:
Line 70: Line 73:       −
[[Image:Configuration examples json-rpc terminal uci set.png]]
+
[[Image:Configuration examples json-rpc terminal uci set.png|961px]]
   −
====uci commit====
+
====UCI COMMIT====
 
----
 
----
 
In order to commit the changes from RAM to flash memory, you must execute a '''uci commit''' command. Continuing from the example above, lets commit the changes made to the ''network'' config. The command to do so looks like this:
 
In order to commit the changes from RAM to flash memory, you must execute a '''uci commit''' command. Continuing from the example above, lets commit the changes made to the ''network'' config. The command to do so looks like this:
Line 82: Line 85:  
'''{"jsonrpc":"2.0","id":1,"result":[0]}'''
 
'''{"jsonrpc":"2.0","id":1,"result":[0]}'''
   −
====luci-reload====
+
====LUCI-RELOAD====
 
----
 
----
 
In order for the changes to take effect, use the '''luci-reload''' command which restarts all of the router's services. The luci-reload command looks like this:
 
In order for the changes to take effect, use the '''luci-reload''' command which restarts all of the router's services. The luci-reload command looks like this:
Line 97: Line 100:     
The command above will '''enable''' the Ping Reboot function, set the host to ping to '''8.8.4.4''' and ping packet size to '''64'''. The default values are highlighted in orange and the new ones are highlighted in green.
 
The command above will '''enable''' the Ping Reboot function, set the host to ping to '''8.8.4.4''' and ping packet size to '''64'''. The default values are highlighted in orange and the new ones are highlighted in green.
 +
 +
'''Note: Remember always to use the commands in the order (set, commit, luci-reload)'''

Navigation menu