Openwrt笔记---UCI

UCI是什么?

The abbreviation UCI stands for Unified Configuration Interface, and is a system to centralize the configuration of OpenWrt services.

Configuration files

File Description
Basic
/etc/config/dhcp Dnsmasq and odhcpd settings: DNS, DHCP, DHCPv6
/etc/config/dropbear SSH server options
/etc/config/firewall NAT, packet filter, port forwarding, etc.
/etc/config/network Switch, interface and route configuration:
General, IPv4, IPv6, Routes, Rules, WAN, Aliases, Switches, VLAN, IPv4/IPv6 transitioning, Tunneling
/etc/config/system Misc. system settings, NTP, RNG, Watchcat
/etc/config/wireless Wireless settings and wifi network definition
IPv6
/etc/config/ahcpd Ad-Hoc Configuration Protocol (AHCP) server and forwarder configuration
/etc/config/dhcp6c WIDE-DHCPv6 client
/etc/config/dhcp6s WIDE-DHCPv6 server
/etc/config/gw6c GW6c client configuration
Other
/etc/config/babeld babeld configuration
/etc/config/bbstored BoxBackup server configuration
/etc/config/ddns Dynamic DNS configuration (ddns-scripts)
/etc/config/dnscrypt-proxy DNSCrypt proxy
/etc/config/dockerd The Docker CE Engine Daemon
/etc/config/emailrelay E-MailRelay: simple SMTP server and proxy with POP support. Package emailrelay
/etc/config/etherwake Wake-on-Lan: etherwake
/etc/config/freifunk_p2pblock Uses iptables layer7-, ipp2p- and recent-modules to block p2p/filesharing traffic
/etc/config/fstab Mount points and swap
/etc/config/hd-idle Another idle-daemon for attached hard drives
/etc/config/httpd Web server options (Busybox httpd, deprecated)
/etc/config/ipset-dns Configure ipset-dns
/etc/config/kadnode KadNode p2p DNS
/etc/config/luci Base LuCI config
/etc/config/luci_statistics Configuration of Statistics packet
/etc/config/mini_snmpd mini_snmpd settings
/etc/config/minidlna MiniDLNA settings
/etc/config/mjpg-streamer Streaming application for Linux-UVC compatible webcams
/etc/config/mountd OpenWrt automount daemon
/etc/config/mroute Configuration files for multiple WAN routes
/etc/config/multiwan Simple multi WAN configuration
/etc/config/mwan3 Multi-WAN config with load balancing and failover
/etc/config/nodogsplash nodogsplash configuration
/etc/config/ntpclient Getting the correct time
/etc/config/nut_server Controlling a UPS (Uninterruptible Power Supply) and/or sharing with other hosts
/etc/config/nut_monitor Monitoring a UPS (Uninterruptible Power Supply) from a remote host or local nut-server
/etc/config/nut_cgi Web UI for NUT (viewing only in UCI)
/etc/config/p910nd config for non-spooling Printer daemon p910nd.server
/etc/config/pure-ftpd Pure-FTPd server config
/etc/config/qos Implementing Quality of Service for the upload
/etc/config/racoon racoon IPsec daemon
/etc/config/samba settings for the Microsoft file and print services daemon
/etc/config/snmpd SNMPd settings
/etc/config/sqm SQM settings
/etc/config/sshtunnel Settings for the package sshtunnel
/etc/config/stund STUN server configuration
/etc/config/tinc tinc package configuration
/etc/config/tor Tor configuration
/etc/config/tor-hs Tor hidden services configuration
/etc/config/transmission BitTorrent configuration
/etc/config/uhttpd Web server options (uHTTPd)
/etc/config/upnpd miniupnpd UPnP server settings
/etc/config/users user database for different services
/etc/config/ushare uShare UPnP server settings
/etc/config/vblade vblade userspace AOE target
/etc/config/vnstat vnstat downloader settings
/etc/config/wifitoggle Toggle WiFi with a button
/etc/config/wol Wake-on-Lan: wol
/etc/config/znc ZNC bouncer configuration

举例子

Openwrt笔记---UCI_第1张图片

# uci
Usage: uci []  []

Commands:
	batch
	export     []
	import     []
	changes    []
	commit     []
	add         
	add_list   .
.
Command  Target  Description 
commit [] 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 and written to flash at once with “uci commit”. This is not needed after editing configuration files with a text editor, but for scripts, GUIs and other programs working directly with UCI files.
batch - Executes a multi-line UCI script which is typically wrapped into a here document syntax.
export [] Exports the configuration in a machine readable format. It is used internally to evaluate configuration files as shell scripts.
import [] Imports configuration files in UCI syntax.
changes [] List staged changes to the given configuration file or if none given, all configuration files.
add Add an anonymous section of type section-type to the given configuration.
add_list .
.
Add the given string to an existing list option.
del_list .
.
Remove the given string from an existing list option.
show [[.
[.
Show the given option, section or configuration in compressed notation.
get .
[.
Get the value of the given option or the type of the given section.
set .
[.
Set the value of the given option, or add a new section with the type set to the given value.
delete .
[.
Delete the given section or option.
rename .
[.
Rename the given option or section to the given name.
revert [.
[.
Revert the given option, section or configuration file.
reorder .
=
Move a section to another position.

UCI配置实例(以MT7628开发板为例)

配置switch和vlan mt7628开发板有五个网口port0~port4 实际开发板仅仅引出三个网口,这里计划port0作为wan口 ,port1 port2 作为lan口

#使能vlan功能

uci add network switch
uci set network.@switch[0].name=switch0
uci set network.@switch[0].reset=1
uci set network.@switch[0].enable_vlan=1
uci commit

# 设置vlan1 port 0 后面作为wan口
uci add network switch_vlan
uci set network.@switch_vlan[0].device=switch0
uci set network.@switch_vlan[0].vlan=1
uci set network.@switch_vlan[0].ports='0 6t'
uci commit

# 设置vlan2 port 1 2 后面作为lan口
uci add network switch_vlan
uci set network.@switch_vlan[1].device=switch0
uci set network.@switch_vlan[1].vlan=2
uci set network.@switch_vlan[1].ports='1 2 6t'


####设置网桥
uci add network device
uci set network.@device[0].name=br-lan
uci set network.@device[0].type=bridge
uci add_list network.@device[0].ports=eth0.2

###设置lan口信息
uci set network.lan=interface
uci set network.lan.device=br-lan
uci set network.lan.proto=static
uci set network.lan.ipaddr=192.168.56.1
uci set network.lan.netmask=255.255.255.0

###设置wan口信息

uci set network.wan=interface
uci set network.wan.device=eth0.1
uci set network.wan.proto=dhcp
uci commit



root@openwrt:/# uci show network
network.loopback=interface
network.loopback.device='lo'
network.loopback.proto='static'
network.loopback.ipaddr='127.0.0.1'
network.loopback.netmask='255.0.0.0'
network.globals=globals
network.globals.ula_prefix='auto'
network.@switch[0]=switch
network.@switch[0].name='switch0'
network.@switch[0].reset='1'
network.@switch[0].enable_vlan='1'
network.@switch_vlan[0]=switch_vlan
network.@switch_vlan[0].device='switch0'
network.@switch_vlan[0].vlan='1'
network.@switch_vlan[0].ports='0 6t'
network.@switch_vlan[1]=switch_vlan
network.@switch_vlan[1].device='switch0'
network.@switch_vlan[1].vlan='2'
network.@switch_vlan[1].ports='1 2 6t'
network.@device[0]=device
network.@device[0].name='br-lan'
network.@device[0].type='bridge'
network.@device[0].ports='eth0.2'
network.lan=interface
network.lan.device='br-lan'
network.lan.proto='static'
network.lan.ipaddr='192.168.56.1'
network.lan.netmask='255.255.255.0'
network.wan=interface
network.wan.device='eth0.1'
network.wan.proto='dhcp'
root@openwrt:/#



###开启WIFI

root@openwrt:/# uci show wireless
wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.path='platform/10300000.wmac'
wireless.radio0.channel='1'
wireless.radio0.band='2g'
wireless.radio0.htmode='HT20'
wireless.radio0.disabled='1'
wireless.default_radio0=wifi-iface
wireless.default_radio0.device='radio0'
wireless.default_radio0.network='lan'
wireless.default_radio0.mode='ap'
wireless.default_radio0.ssid='OpenWrt'
wireless.default_radio0.encryption='none'


###设置ap的ssid

uci set wireless.default_radio0.ssid=openwrt_ap_test

###设置密码的加密方法
uci set wireless.default_radio0.encryption=psk2

###设置密码
uci set wireless.default_radio0.key=test123456
###开启WiFi
uci set wireless.radio0.disabled=0






你可能感兴趣的:(笔记,笔记)