Changes

21,629 bytes added ,  14:39, 2 August 2023
no edit summary
Line 1: Line 1:  +
<p style="color:red">The information on this page is updated in accordance with the [https://wiki.teltonika-networks.com/view/FW_%26_SDK_Downloads'''00.07.4'''] firmware version .</p>
 +
 +
 
'''Unified Configuration Interface''' ('''UCI''') is a small utility written in C (a shell script-wrapper is available as well) and is intended to centralize the whole configuration of a device running on OpenWrt.
 
'''Unified Configuration Interface''' ('''UCI''') is a small utility written in C (a shell script-wrapper is available as well) and is intended to centralize the whole configuration of a device running on OpenWrt.
 +
 
__TOC__
 
__TOC__
 +
 
==Summary==
 
==Summary==
    
UCI commands provide the user with the maximum degree of control since they can be issued via many different forms of router monitoring and administration (SSH, CLI, SMS, JSON-RPC) and can be used to set or get any router parameter. This chapter is a guide on how to use UCI commands with RUT devices.
 
UCI commands provide the user with the maximum degree of control since they can be issued via many different forms of router monitoring and administration (SSH, CLI, SMS, JSON-RPC) and can be used to set or get any router parameter. This chapter is a guide on how to use UCI commands with RUT devices.
   −
==Obtaining parameters==
+
==How do I execute UCI commands?==
 +
 
 +
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 (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]]'''
 +
 
 +
*'''SMS''' - you can execute UCI commands via SMS messages with the SMS Utilities '''[[SMS_Utilities#UCI_API_rule|uci api]]''' rule
 +
 
 +
*'''JSON-RPC''' - you can execute UCI commands via JSON-RPC. Refer to this guide for more information: '''[[Monitoring via JSON-RPC]]'''
 +
 
 +
==Available commands==
 +
 
 +
This section provides a list of possible UCI commands and options.
 +
 
 +
{| class="wikitable"
 +
|+ style="text-align: left;" | UCI commands
 +
! style="width: 100px; background: black; color: white;"  | Command
 +
! style="width: 340px; background: black; color: white;"  | Target
 +
! style="width: 1200px; background: black; color: white;" | Description
 +
|-
 +
! style="text-align: left; vertical-align: top;" | batch
 +
| style="text-align: left; vertical-align: top;" | -
 +
| style="text-align: left; vertical-align: top;" | Executes a multi-line UCI script which is typically wrapped into a here document syntax
 +
|-
 +
! style="text-align: left; vertical-align: top;" | export
 +
| style="text-align: left; vertical-align: top;" | [<config>]
 +
| style="text-align: left; vertical-align: top;" | Exports the configuration in a machine readable format. It is used internally to evaluate configuration files as shell scripts
 +
|-
 +
! style="text-align: left; vertical-align: top;" | import
 +
| style="text-align: left; vertical-align: top;" | [<config>]
 +
| style="text-align: left; vertical-align: top;" | Imports configuration files in UCI syntax
 +
|-
 +
! style="text-align: left; vertical-align: top;" | changes
 +
| style="text-align: left; vertical-align: top;" | [<config>]
 +
| style="text-align: left; vertical-align: top;" | Lists staged changes to the given configuration file or if none given, all configuration files
 +
|-
 +
! style="text-align: left; vertical-align: top;" | commit
 +
| style="text-align: left; vertical-align: top;" | [<config>]
 +
| style="text-align: left; vertical-align: top;" | Writes changes of the given configuration file, or if none is given, all configuration files, to the filesystem. All "uci set", "uci add", "uci rename" and "uci delete" commands are staged into a temporary location until they are written to flash with the "uci commit" command. This is used exclusively for UCI commands and is not needed after editing configuration files with a text editor
 +
|-
 +
! style="text-align: left; vertical-align: top;" | add
 +
| style="text-align: left; vertical-align: top;" | <config> <section-type>
 +
| style="text-align: left; vertical-align: top;" | Adds an anonymous section of type ''section-type'' to the given configuration
 +
|-
 +
! style="text-align: left; vertical-align: top;" | add_list
 +
| style="text-align: left; vertical-align: top;" | <config>.<section>.<option>=<string>
 +
| style="text-align: left; vertical-align: top;" | Adds the given ''string'' to an existing list option
 +
|-
 +
! style="text-align: left; vertical-align: top;" | del_list
 +
| style="text-align: left; vertical-align: top;" | <config>.<section>.<option>=<string>
 +
| style="text-align: left; vertical-align: top;" | Removes the given ''string'' from an existing list option
 +
|-
 +
! style="text-align: left; vertical-align: top;" | show
 +
| style="text-align: left; vertical-align: top;" | [<config>[.<section>[.<option>]]]
 +
| style="text-align: left; vertical-align: top;" | Shows the given option, section or configuration in compressed notation. If no option is given, shows all configuration files
 +
|-
 +
! style="text-align: left; vertical-align: top;" | get
 +
| style="text-align: left; vertical-align: top;" | <config>.<section>[.<option>]
 +
| style="text-align: left; vertical-align: top;" | Gets the value of the given option or the type of the given section
 +
|-
 +
! style="text-align: left; vertical-align: top;" | set
 +
| style="text-align: left; vertical-align: top;" | <config>.<section>[.<option>]=<value>
 +
| style="text-align: left; vertical-align: top;" | Sets the value of the given option, or add a new section with the type set to the given ''value''
 +
|-
 +
! style="text-align: left; vertical-align: top;" | delete
 +
| style="text-align: left; vertical-align: top;" | <config>[.<section>[[.<option>][=<id>]]]
 +
| style="text-align: left; vertical-align: top;" | Deletes the given section or option
 +
|-
 +
! style="text-align: left; vertical-align: top;" | rename
 +
| style="text-align: left; vertical-align: top;" | <config>.<section>[.<option>]=<name>
 +
| style="text-align: left; vertical-align: top;" | Renames the given option or section to the given name
 +
|-
 +
! style="text-align: left; vertical-align: top;" | revert
 +
| style="text-align: left; vertical-align: top;" | <config>[.<section>[.<option>]]
 +
| style="text-align: left; vertical-align: top;" | Reverts the given option, section or configuration file. Used to undo any changes performed with UCI and not yet committed with ''uci commit''
 +
|-
 +
! style="text-align: left; vertical-align: top;" | reorder
 +
| style="text-align: left; vertical-align: top;" | <config>.<section>=<position>
 +
| style="text-align: left; vertical-align: top;" | Moves the specified section to the given ''position''. Used for easier management purposes
 +
|-
 +
|}
 +
 
 +
 
 +
'''Options'''
 +
-c  <path>  set the search path for config files (default: /etc/config)
 +
-d  <str>  set the delimiter for list values in uci show
 +
-f  <file>  use <file> as input instead of stdin
 +
-m          when importing, merge data into an existing package
 +
-n          name unnamed sections on export (default)
 +
-N          don't name unnamed sections
 +
-p  <path>  add a search path for config change files
 +
-P  <path>  add a search path for config change files and use as default
 +
-q          quiet mode (don't print error messages)
 +
-s          force strict mode (stop on parser errors, default)
 +
-S          disable strict mode
 +
-X          do not use extended syntax on 'show'
   −
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.
+
==Configuration hierarchy==
   −
===Configuration hierarchy===
  −
----
   
UCI commands can be used to set and obtain parameters, but to do so, one has to first know the names of the '''config''' file, its '''section''' and the '''option''' that they are trying to interact with. Different configurations for different router functions and services are stored in config files. These config files have sections and section usually store multiple options
 
UCI commands can be used to set and obtain parameters, but to do so, one has to first know the names of the '''config''' file, its '''section''' and the '''option''' that they are trying to interact with. Different configurations for different router functions and services are stored in config files. These config files have sections and section usually store multiple options
   Line 21: Line 121:  
* 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===
 
----
 
----
 
Sections deserve some extra explanation in regard to naming. A section can be '''named''' or '''unnamed'''. Unnamed sections will get an autogenerated ID/CFGID (like "cfg023579") and be presented with an anonymous-name (like "@wifi-iface[0]")
 
Sections deserve some extra explanation in regard to naming. A section can be '''named''' or '''unnamed'''. Unnamed sections will get an autogenerated ID/CFGID (like "cfg023579") and be presented with an anonymous-name (like "@wifi-iface[0]")
Line 44: Line 144:  
  wireless.cfg023579.mode=ap
 
  wireless.cfg023579.mode=ap
 
  ...
 
  ...
 +
 +
===Configuration files===
 +
----
 +
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"
 +
|+
 +
! style="width: 250px; background: black; color: white;"  | File
 +
! style="width: 340px; background: black; color: white;"  | Description
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/avl
 +
| style="text-align: left; vertical-align: top;" | Stores AVL (Automatic Vehicle Location) configuration settings
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/buttons
 +
| style="text-align: left; vertical-align: top;" | Defines the behavior of the reset button on the device
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/call_utils
 +
| style="text-align: left; vertical-align: top;" | Provides utilities for making and managing calls
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/cli
 +
| style="text-align: left; vertical-align: top;" | Defines command-line interface (CLI) settings
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/dhcp
 +
| style="text-align: left; vertical-align: top;" | Configures Dynamic Host Configuration Protocol (DHCP) settings for the network
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/dropbear
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the Dropbear SSH server
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/email_to_sms
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the email-to-SMS gateway
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/events_reporting
 +
| style="text-align: left; vertical-align: top;" | Configures settings for reporting system events
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/firewall
 +
| style="text-align: left; vertical-align: top;" | Configures firewall settings
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/fstab
 +
| style="text-align: left; vertical-align: top;" | Configures file system mount points
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/gps
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the Global Positioning System (GPS)
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/hwinfo
 +
| style="text-align: left; vertical-align: top;" | Provides hardware information about the device
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/iojuggler
 +
| style="text-align: left; vertical-align: top;" | Provides utilities for managing input/output (IO) settings
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/ioman
 +
| style="text-align: left; vertical-align: top;" | Provides utilities for managing input/output (IO) settings
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/ip_blockd
 +
| style="text-align: left; vertical-align: top;" | Configures IP address blocking settings and stores blocked IP addresses
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/ipsec
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the IPsec VPN
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/kmod_man
 +
| style="text-align: left; vertical-align: top;" | Manages kernel modules
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/mdcollectd
 +
| style="text-align: left; vertical-align: top;" | Collects and sends system metrics to a remote server
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/modbus
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the Modbus protocol
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/modbus_data_sender
 +
| style="text-align: left; vertical-align: top;" | Sends Modbus data to a remote server
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/modbus_master
 +
| style="text-align: left; vertical-align: top;" | Configures the device as a Modbus master.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/modbusgateway
 +
| style="text-align: left; vertical-align: top;" | Configures the device as a Modbus gateway.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/multi_wifi
 +
| style="text-align: left; vertical-align: top;" | Configures settings for multiple Wi-Fi networks.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/mwan3
 +
| style="text-align: left; vertical-align: top;" | Configures settings for Multi-WAN load balancing and failover.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/network
 +
| style="text-align: left; vertical-align: top;" | Configures network settings.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/ntpclient
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the Network Time Protocol (NTP) client.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/ntpserver
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the NTP server.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/openvpn
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the OpenVPN VPN.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/operctl
 +
| style="text-align: left; vertical-align: top;" | Provides utilities for managing system operations.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/overview
 +
| style="text-align: left; vertical-align: top;" | Provides an overview of the system.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/p910nd
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the p910nd printer server.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/package_restore
 +
| style="text-align: left; vertical-align: top;" | Restores installed packages after formware update.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/periodic_reboot
 +
| style="text-align: left; vertical-align: top;" | Configures periodic system reboots.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/ping_reboot
 +
| style="text-align: left; vertical-align: top;" | Configures system reboots triggered by ping responses.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/post_get
 +
| style="text-align: left; vertical-align: top;" | Configures POST/GET service.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/pptpd
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the PPTP VPN server.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/profiles
 +
| style="text-align: left; vertical-align: top;" | Configures profiles for the system.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/quota_limit
 +
| style="text-align: left; vertical-align: top;" | Configures mobile Data Limits.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/rms_mqtt
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the RMS connect.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/rpcd
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the Remote Procedure Call (RPC) daemon.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/rs_console
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the serial console.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/rs_modbus
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the Modbus protocol over serial.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/rs_modem
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the modem.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/rs_overip
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the serial over IP protocol.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/rut_fota
 +
| style="text-align: left; vertical-align: top;" | Configures settings for firmware over the air (FOTA) updates.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/sim_switch
 +
| style="text-align: left; vertical-align: top;" | Configures settings for switching between SIM cards.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/simcard
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the SIM card.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/sms_gateway
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the SMS gateway.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/sms_utils
 +
| style="text-align: left; vertical-align: top;" | Provides utilities for managing SMS messages.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/snmpd
 +
| style="text-align: left; vertical-align: top;" | Configures the Simple Network Management Protocol (SNMP) daemon.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/snmptrap
 +
| style="text-align: left; vertical-align: top;" | Configures settings for SNMP traps.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/snmptrap-opkg
 +
| style="text-align: left; vertical-align: top;" | Installs and configures the SNMP trap package.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/socat
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the socat command-line utility.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/system
 +
| style="text-align: left; vertical-align: top;" | Configures system settings.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/telnetd
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the Telnet daemon.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/uhttpd
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the HTTP server.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/user_groups
 +
| style="text-align: left; vertical-align: top;" | Configures user groups.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/vuci
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the VuCI web interface.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/widget
 +
| style="text-align: left; vertical-align: top;" | Configures widgets for the web interface.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/wireless
 +
| style="text-align: left; vertical-align: top;" | Configures wireless network settings.
 +
|-
 +
! style="text-align: left; vertical-align: top;" | /etc/config/xl2tpd
 +
| style="text-align: left; vertical-align: top;" | Configures settings for the L2TP VPN server.
 +
|-
 +
|}
 +
 +
==Obtaining parameters==
 +
 +
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 55: Line 353:  
[[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 69: Line 367:  
[[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 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:
    
  # <span style=color:purple>ls /etc/config</span>
 
  # <span style=color:purple>ls /etc/config</span>
Line 78: Line 376:     
[[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 91: Line 391:  
As you may have noticed, the command is very similar to uci get, except it has an equals to (''''='''') sign added at the end and after the sign is the value that we want to assign to the option.
 
As you may have noticed, the command is very similar to uci get, except it has an equals to (''''='''') sign added at the end and after the sign is the value that we want to assign to the option.
   −
The next step is to commit the changes by using the '''uci commit''' command and to restart all the services relevant to our configuration by using the '''luci-reload''' command:
+
The next step is to commit the changes by using the '''uci commit''' command and to restart all the services relevant to our configuration by using the '''/etc/init.d/wireless restart''' command:
    
  # uci commit wireless
 
  # uci commit wireless
  # luci-reload
+
  # /etc/init.d/wireless restart
    
After this, your changes will be applied and in use. Notice that when using uci commit you can specify the config file for which you want to commit changes (you can even specify the exact section and option). This is useful when making changes to multiple options in case you make any mistakes, because before committing any changes you can easily undo them with the '''uci revert''' command. The command by itself will undo all the changes made by uci up until the last commit. It can also be used on specific config files, sections and options in order to undo specific changes.
 
After this, your changes will be applied and in use. Notice that when using uci commit you can specify the config file for which you want to commit changes (you can even specify the exact section and option). This is useful when making changes to multiple options in case you make any mistakes, because before committing any changes you can easily undo them with the '''uci revert''' command. The command by itself will undo all the changes made by uci up until the last commit. It can also be used on specific config files, sections and options in order to undo specific changes.
Line 100: Line 400:  
===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 115: Line 415:  
  # uci add_list wireless.@wifi-iface[0].maclist=33:33:33:33:33:33
 
  # uci add_list wireless.@wifi-iface[0].maclist=33:33:33:33:33:33
 
  # uci commit wireless
 
  # uci commit wireless
  # luci-reload
+
  # /etc/init.d/wireless restart
    
Notice that you have to use a separate command for adding each value and as with uci set you have to use uci commit and luci-reload in order for the changes to take effect.
 
Notice that you have to use a separate command for adding each value and as with uci set you have to use uci commit and luci-reload in order for the changes to take effect.
    
===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 150: Line 450:  
  # uci add_list openvpn.server_MyServer.push="route 192.168.56.0 255.255.255.0'
 
  # uci add_list openvpn.server_MyServer.push="route 192.168.56.0 255.255.255.0'
   −
And don't forget to ''uci commit'' and ''luci-reload'':
+
And don't forget to ''uci commit'' and ''restart the daemon'':
    
  # uci commit openvpn
 
  # uci commit openvpn
  # luci-reload
+
  # /etc/init.d/openvpn restart
    
A few notes about the configuration:
 
A few notes about the configuration:
Line 171: Line 471:     
===Site Blocking===
 
===Site Blocking===
 +
----
 +
This example will provide instructions on how to enable RUT routers' Site Blocking feature and how to add hostnames to the Blacklist or Whitelist using only UCI commands. For the sake of our example lets say that you want to create a Blacklist that excludes access to all sites contained within the list. The sites in question are <nowiki>www.facebook.com</nowiki>, <nowiki>www.youtube.com</nowiki> and <nowiki>9gag.com</nowiki>.
   −
This example will provide instructions on how to enable RUT routers' Site Blocking feature and how to add hostnames to the Blacklist or Whitelist.  Let's say for the sake of our example that you want to create a Blacklist that excludes access to all sites contained within the list. The sites in question are <nowiki>www.facebook.com</nowiki>, <nowiki>www.youtube.com</nowiki> and <nowiki>9gag.com</nowiki>.
+
To achieve such a task, the first relevant piece of required information is the config name, '''hostblock''', where all the necessary configuration settings are stored. The next important thing to know is that each different website must be stored in a separate section of the type '''block'''. So we'll need to create a new section and enable each added element. Lets start:
 
  −
To achieve such a task, the first relevant piece of required information is the config name, '''hostblock''', where all the necessary configuration lines are stored. The next important thing to know is that each different website must be stored in a separate section of the type '''block'''. So we'll need to create a new section and enable each added element. Let's start:
      
First element:
 
First element:
Line 194: Line 494:  
  # uci set hostblock.config.enabled=1
 
  # uci set hostblock.config.enabled=1
   −
Last steps:
+
Final steps:
 
  # uci commit hostblock
 
  # uci commit hostblock
  # luci-reload
+
  # /etc/init.d/hostblock restart
 +
 
 +
The first-third steps add hostnames of the websites to be blocked, which are saved under the option ''host''. Each of the first three elements also need to be enabled, therefore, the option ''enabled'' is set to ''1'' next to each host. The fourth step is for enabling the Site Blocking service (by setting the option ''enabled'' in section ''config'' to ''1'').
 +
===DHCP Server===
 +
----
 +
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.  ''Lets start:''
 +
 
 +
Setting start address and limit:
 +
# uci set dhcp.lan.start=2
 +
# uci set dhcp.lan.limit=199
 +
 
 +
Setting lease time
 +
# uci set dhcp.lan.leasetime=30m
 +
 
 +
Final steps:
 +
# uci commit dhcp
 +
# /etc/init.d/dhcp restart
 +
 
 +
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, '''quota_limit''', where all the necessary configuration settings are stored:
 +
 
 +
Enabling Mobile Data Limit and SMS Warning:
 +
# uci set quota_limit.mob1s1a1=interface
 +
# uci set quota_limit.mob1s1a1.enabled='1'
 +
# uci set quota_limit.mob1s1a1.ifname='mob1s1a1'
 +
# uci set quota_limit.mob1s1a1.reset_hour='10'
 +
# uci set quota_limit.mob1s1a1.sim='1'
 +
# uci set quota_limit.mob1s1a1.data_limit='10000'
 +
# uci set quota_limit.mob1s1a1.enable_warning='1'
 +
# uci set quota_limit.mob1s1a1.period='1'
 +
# uci set quota_limit.mob1s1a1.warning_limit='8000'
 +
# uci set quota_limit.mob1s1a1.warning_num='+37012345678'
 +
 
 +
Commit changes and restart the daemon
 +
 
 +
# uci commit quota_limit
 +
# /etc/init.d/quota_limit restart
 +
 
 +
 
 +
'''Disabling / Deleting configuration'''
 +
-----
 +
Let us take the above example and disable the data limit using '''uci'''. For this, we simply need to change the "enabled" value to '0':
 +
# uci set quota_limit.mob1s1a1.enabled='0'
 +
# uci commit quota_limit
 +
# /etc/init.d/quota_limit restart
 +
 
 +
If you wish to delete the whole configuration, '''uci delete''' can be used. Let us delete the entire block of configuration of mob1s1a1 interface:
 +
# uci delete quota_limit.mob1s1a1
 +
# uci commit quota_limit
 +
# /etc/init.d/quota_limit restart
 +
 
 +
==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
 +
 
 +
[[Category:Router control and monitoring]]

Navigation menu