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 (Linux)==
 
==Using JSON-RPC (Linux)==
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|961px|center]]
+
[[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 50: Line 50:       −
[[Image:Configuration examples json-rpc terminal gsmctl.png|961px|center]]
+
[[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 56: 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|961px|center]]
+
[[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 73: Line 73:       −
[[Image:Configuration examples json-rpc terminal uci set.png|961px|center]]
+
[[Image:Configuration examples json-rpc terminal uci set.png|961px]]
    
====UCI COMMIT====
 
====UCI COMMIT====