Changes

2,670 bytes added ,  12:10, 24 July 2019
m
Line 9: Line 9:  
UCI commands can executed via the following methods:
 
UCI commands can executed via the following methods:
   −
*'''SSH''' - you can use UCI commands via SSH either with Linux OS's Terminal app or the PuTTY app with Windows OS
+
*'''SSH''' - you can use UCI commands via SSH either with Linux OS's Terminal app or the PuTTY app with Windows OS (a download link is provided at the bottom of this page)
    
*'''CLI''' - you can use UCI commands via the Command Line Interface found in the router's '''[[CLI|WebUI]]'''
 
*'''CLI''' - you can use UCI commands via the Command Line Interface found in the router's '''[[CLI|WebUI]]'''
Line 116: Line 116:  
* values: value of an option
 
* values: value of an option
   −
[[File:Uci config hierarchy v2.png]]
+
[[File:Uci config hierarchy v3.jpg|1000px]]
    
===Sections===
 
===Sections===
Line 142: Line 142:  
===Configuration files===
 
===Configuration files===
 
----
 
----
This section provides a list of all available configuration files of RUT routes.  
+
This section provides a list of all available configuration files of RUT routers. Note that these are all possible config files from any RUT router ([[RUT230]], [[RUT240]], [[RUT850]], [[RUT950]], [[RUT955]]) and that therefore some of them may not exist in your router.
    
{| class="wikitable"
 
{| class="wikitable"
Line 308: Line 308:  
| style="text-align: left; vertical-align: top;" | Stores SAMBA configuration settings
 
| style="text-align: left; vertical-align: top;" | Stores SAMBA configuration settings
 
|-
 
|-
! style="text-align: left; vertical-align: top;" | /etc/config/simThis section contains no values yet_idle_protection
+
! style="text-align: left; vertical-align: top;" | /etc/config/sim_idle_protection
 
| style="text-align: left; vertical-align: top;" | Stores SIM Idle Protection configuration settings
 
| style="text-align: left; vertical-align: top;" | Stores SIM Idle Protection configuration settings
 
|-
 
|-
Line 369: Line 369:  
==Obtaining parameters==
 
==Obtaining parameters==
   −
This section will overview uci get and uci show commands used to obtain router parameters as well as provide some basic knowledge on configuration hierarchy needed to successfully use most uci commands.
+
This section will overview uci get and uci show commands used to obtain router parameters, option and section names and contents of entire configs or sections.
    
===UCI get===
 
===UCI get===
Line 381: Line 381:  
[[File:Uci get wireless ssid response.png]]
 
[[File:Uci get wireless ssid response.png]]
   −
The command above returns the Wi-Fi Access Point's SSID. As you can see the  <span style=color:purple>uci get</span> command is used. What follows after the command is the path to the value that we're looking for (SSID, in this case). The SSID value can be found in the <span style=color:red>wireless</span> config, the <span style=color:blue>@wifi-iface[0]</span> section, stored in an option called <span style=color:green>ssid</span>. So the basic syntax for a uci get command is this:
+
The command above returns the Wi-Fi Access Point's SSID. As you can see the  <span style=color:purple>uci get</span> command is used. What follows after the command is the path to the value that we're looking for (SSID, in this case). The SSID value can be found in the <span style=color:red>wireless</span> config, the <span style=color:blue>@wifi-iface[0]</span> section, stored under an option called <span style=color:green>ssid</span>. So the basic syntax for a uci get command is this:
    
  # <span style=color:purple>uci get</span> <span style=color:red><config></span>.<span style=color:blue><section></span>[.<span style=color:green><option></span>]
 
  # <span style=color:purple>uci get</span> <span style=color:red><config></span>.<span style=color:blue><section></span>[.<span style=color:green><option></span>]
Line 395: Line 395:  
[[File:Uci show wireless response v2.png]]
 
[[File:Uci show wireless response v2.png]]
   −
As you can see, this time the response shows the entire wireless config and instead of just showing values (like in the case of uci get) you can see the config name, section name and option name before each one.
+
As you can see, the response shows the entire wireless config and its entities. Note that instead of just showing values (like in the case of uci get) you can see the config name, section name and option name before each one.
    
Most config file names are simple. Wireless config is called wireless, OpenVPN config is called openvpn, etc. But even so one doesn't necessarily have to know what a config file is called, especially before interacting with it. To see the names of all config files and what kind of settings they store you can refer to the '''[[UCI_command_usage#Configuration_files|table above]]'''. Or if you're CLI or SSH and want to check the names of config files on the spot, you can use the '''ls''' command. Since RUT configs ar stored in '''/etc/config''', the full commands should look like this:
 
Most config file names are simple. Wireless config is called wireless, OpenVPN config is called openvpn, etc. But even so one doesn't necessarily have to know what a config file is called, especially before interacting with it. To see the names of all config files and what kind of settings they store you can refer to the '''[[UCI_command_usage#Configuration_files|table above]]'''. Or if you're CLI or SSH and want to check the names of config files on the spot, you can use the '''ls''' command. Since RUT configs ar stored in '''/etc/config''', the full commands should look like this:
Line 404: Line 404:     
[[File:Uci ls config.png]]
 
[[File:Uci ls config.png]]
 +
 +
So when you plan on obtaining specific parameters or setting parameter values, you should always start with finding out option and section names. To accomplish this, we recommend using the uci show <config> commands.
    
==Setting parameters==
 
==Setting parameters==
Line 426: Line 428:  
===UCI add_list===
 
===UCI add_list===
 
----
 
----
Some variables hold more than one value unlike options. These variables are called '''lists'''. For example, if you use MAC filter on your Wi-Fi Acsess point, the MAC addresses are saved not as options but as a list.
+
Some variables hold more than one value, unlike options. These variables are called '''lists'''. For example, if you use MAC filter on your Wi-Fi Access point, the MAC addresses are saved not as options but as a list.
    
Example of maclist (cmd: uci show wireless):
 
Example of maclist (cmd: uci show wireless):
Line 446: Line 448:     
===Extensive example===
 
===Extensive example===
 
+
----
 
With all that we have learned lets try a more complicated example: lets you want to create an OpenVPN server. The server will be called '''MyServer''', will use a '''TUN''' type interface and '''TLS''' authentication. In order to create this server we will first have to create a section for the server in the openvpn config:
 
With all that we have learned lets try a more complicated example: lets you want to create an OpenVPN server. The server will be called '''MyServer''', will use a '''TUN''' type interface and '''TLS''' authentication. In order to create this server we will first have to create a section for the server in the openvpn config:
   −
  # uci uci add openvpn server_MyServer
+
  # uci add openvpn server_MyServer
 
  # uci set openvpn.server_MyServer=openvpn
 
  # uci set openvpn.server_MyServer=openvpn
   Line 527: Line 529:  
===DHCP Server===
 
===DHCP Server===
 
----
 
----
This example will provide instructions on how configure RUT routers' DHCP Server using only. For the sake of the example lets say that you want to change the dhcp range to ''192.168.1.2'' - ''192.168.1.200'' and the lease time to ''30 minutes''  
+
This example will provide instructions on how configure RUT routers' DHCP Server using only UCI commands. For the sake of the example lets say that you want to change the dhcp range to ''192.168.1.2'' - ''192.168.1.200'' and the lease time to ''30 minutes''  
    
To achieve such a task, the first relevant piece of required information is the config name, '''dhcp''', where all the necessary configuration settings are stored. Another important thing to know is that when changing the lease time, three options are relevant - the time (option ''time''), the unit of time measurement (option ''letter'') and lease time(option ''leasetime), which is basically ''time'' ''+'' ''letter'', e.g., 12 hour lease time is ''12h''. Other options in question are start address (option ''start'') and address limit (option ''limit''). Lets start:
 
To achieve such a task, the first relevant piece of required information is the config name, '''dhcp''', where all the necessary configuration settings are stored. Another important thing to know is that when changing the lease time, three options are relevant - the time (option ''time''), the unit of time measurement (option ''letter'') and lease time(option ''leasetime), which is basically ''time'' ''+'' ''letter'', e.g., 12 hour lease time is ''12h''. Other options in question are start address (option ''start'') and address limit (option ''limit''). Lets start:
Line 545: Line 547:     
The first step sets the start address to 2 and the limit of addresses to 199. The value of the ''start'' option is associated with the last section of an IP address (if start value is '''2''' then the starting IP address is 192.168.1.'''2'''(provided that the router's LAN IP is in the 192.168.1.0/24 network)), the value of the ''limit'' option denotes how many IP addresses can be leased out starting from and including the the start address. Then the second step is used to set the lease time. The ''letter'' option specifies the unit of time measurement (either ''m'' for minutes or ''h'' for hours). The ''time'' option specifies number of minutes (or hours in other cases) and the ''leasetime'' option is just the representation (nonetheless, it's still mandatory) of the previous two values, i.e., 30m - thirty minutes.
 
The first step sets the start address to 2 and the limit of addresses to 199. The value of the ''start'' option is associated with the last section of an IP address (if start value is '''2''' then the starting IP address is 192.168.1.'''2'''(provided that the router's LAN IP is in the 192.168.1.0/24 network)), the value of the ''limit'' option denotes how many IP addresses can be leased out starting from and including the the start address. Then the second step is used to set the lease time. The ''letter'' option specifies the unit of time measurement (either ''m'' for minutes or ''h'' for hours). The ''time'' option specifies number of minutes (or hours in other cases) and the ''leasetime'' option is just the representation (nonetheless, it's still mandatory) of the previous two values, i.e., 30m - thirty minutes.
 +
 +
===Mobile Data Limit===
 +
----
 +
This example will provide instructions on how configure Mobile Data Limit and SMS Warning on RUT routers' using only UCI commands. For the sake of the example lets say that you want to set up a data limit of 1 GB with the limit counter restarting everyday at 10 a.m. and an SMS Warning that sends out a message when the 800 MB threshold is reached that also restarts everyday at 10 a.m.
 +
 +
To achieve such a task, the first relevant piece of required information is the config name, '''data_limit''', where all the necessary configuration settings are stored. This task will require the knowledge of many mandatory option so lets begin the step-by-step part (comments will be provided along with each step and a short summary afterwards):
 +
 +
Enabling Mobile Data Limit and SMS Warning:
 +
# uci set data_limit.limit.prim_enb_conn=1
 +
# uci set data_limit.limit.prim_end_wrn=1
 +
 +
Setting the Mobile Data and SMS Warning limits:
 +
# uci set data_limit.limit.prim_conn_limit=1000
 +
# uci set data_limit.limit.prim_wrn_limit=800
 +
 +
Setting the Mobile Data Limit period:
 +
# uci set data_limit.limit.prim_conn_period=day
 +
# uci set data_limit.limit.prim_conn_hour=10
 +
 +
Setting the SMS Warning period and phone number:
 +
# uci set data_limit.limit.prim_wrn_period=day
 +
# uci set data_limit.limit.prim_wrn_hour=10
 +
# uci set data_limit.limit.prim_wrn_number=+37012345678
 +
 +
The first enables both SMS Warning and Mobile Data Limit services by setting the options ''prim_enb_conn'' and ''prim_enb_wrn'' to ''1''. The second step sets up the to limits by setting the options ''prim_conn_limit'' and ''prim_wrn_limit'' to ''1000'' and ''800'' respectively. The third step specifies the frequency at which Mobile Data Limit will be reset. The option ''prim_conn_period'' can take values ''month'', ''week'' or in this case, ''day'', and ''prim_conn_hour'' indicates the hour of the day (in this case, ''10''). The fourth step sets up the SMS Warning period in the same manner and also adds the phone number ''+37012345678'' to the option ''prim_wrn_number''
 +
 +
==External links==
 +
 +
* https://wiki.openwrt.org/doc/uci?do= - OpenWRT wiki page on the UCI system
 +
* https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html - PuTTY downloads page
0

edits

Navigation menu