Changes

Line 266: Line 266:  
===Setting router parameters===
 
===Setting router parameters===
 
----
 
----
This section will describe how to use '''uci set''' commands via JSON-RPC.
+
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:
    
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"590bde71578da2fabfe77ba86c00e4e5\", \"uci\", \"set\", { \"config\":\"<span style=color:orange>network</span>\", \"type\":\"<span style=color:orange>interface</span>\", \"match\": {\"ipaddr\":\"<span style=color:red>192.168.1.1</span>\"}, \"values\": {\"ipaddr\":\"<span style=color:green>192.168.56.1</span>\"} } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"590bde71578da2fabfe77ba86c00e4e5\", \"uci\", \"set\", { \"config\":\"<span style=color:orange>network</span>\", \"type\":\"<span style=color:orange>interface</span>\", \"match\": {\"ipaddr\":\"<span style=color:red>192.168.1.1</span>\"}, \"values\": {\"ipaddr\":\"<span style=color:green>192.168.56.1</span>\"} } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
   −
The sections highlighted in orange describe the config file's name and section (in this case, network config and interface section). Highlighted in red is the exact part of the config file that you wish to change (in this case, the router's LAN IP address, '''ipaddr'''). Finally, highlighted in green is the value that is to replace the old value (in this case, change the router's LAN IP address to 192.168.56.1). If the issued command was a success, you should see a Response like this:
+
The sections highlighted in orange describe the config file's name and section (in this case, network config and interface section). Highlighted in red is the option in the config file that you wish to change (in this case, the router's LAN IP address, '''ipaddr'''). Finally, highlighted in green is the value that will to replace the old value (in this case, change the router's LAN IP address to 192.168.56.1). If the command was issued successfully, you should see a Response like this:
      Line 281: Line 281:  
====uci commit====
 
====uci commit====
 
----
 
----
In order to commit the changes from RAM to flash memory, you must first send a UCI commit command. Continuing from the example above, lets commit the network changes. 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:
    
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"9704f676709d9dedc98d7718c4e3e7d2\", \"uci\", \"commit\", {\"config\":\"<span style=color=orange>network</span>\"} ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"9704f676709d9dedc98d7718c4e3e7d2\", \"uci\", \"commit\", {\"config\":\"<span style=color=orange>network</span>\"} ] }" http://<span style=color:black>192.168.1.1</span>/ubus
Line 291: Line 291:  
====luci-reload====
 
====luci-reload====
 
----
 
----
The last step to take in order for the changes to take effect is the luci-reload command which restarts all the services relevant to our configuration. 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:
    
  curl -d "{\"jsonrpc\":\"2.0\",\"id\":1, \"method\":\"call\", \"params\":[\"428a9fa57f1a391db0bd1b865fa16bb5\", \"file\", \"exec\", {\"command\": \"<span style=color:orange>luci-reload</span>\"} ] }" http://<span style=color:black>192.168.56.1</span>/ubus
 
  curl -d "{\"jsonrpc\":\"2.0\",\"id\":1, \"method\":\"call\", \"params\":[\"428a9fa57f1a391db0bd1b865fa16bb5\", \"file\", \"exec\", {\"command\": \"<span style=color:orange>luci-reload</span>\"} ] }" http://<span style=color:black>192.168.56.1</span>/ubus
Line 303: Line 303:  
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"558a9b03c940e52f373f8c02498952e3\", \"uci\", \"set\", {\"config\":\"ping_reboot\", \"match\":{\"enable\":\"<span style=color:orange>0</span>\", \"host\":\"<span style=color:orange>8.8.8.8</span>\", \"packet_size\":\<span style=color:orange>"56</span>\"}, \"values\":{\"enable\":\"<span style=color:green>1</span>\", \"host\":\"<span style=color:green>8.8.4.4</span>\", \"packet_size\":\"<span style=color:green>64</span>\"} } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"558a9b03c940e52f373f8c02498952e3\", \"uci\", \"set\", {\"config\":\"ping_reboot\", \"match\":{\"enable\":\"<span style=color:orange>0</span>\", \"host\":\"<span style=color:orange>8.8.8.8</span>\", \"packet_size\":\<span style=color:orange>"56</span>\"}, \"values\":{\"enable\":\"<span style=color:green>1</span>\", \"host\":\"<span style=color:green>8.8.4.4</span>\", \"packet_size\":\"<span style=color:green>64</span>\"} } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
   −
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, 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.
    
==Some Additional Commands==
 
==Some Additional Commands==