OpenWRT under hood - ScienceChronicle
ScienceChronicle
July 8, 2024

OpenWRT under hood

Posted on July 8, 2024  •  3 minutes  • 543 words
Table of contents

Wireless configuration

Behind the scenes, UCI (Unified Configuration Interface) in OpenWRT uses various command-line utilities and services to apply the wireless configurations defined in /etc/config/wireless. Here are some key components and commands involved in this process:

  1. netifd:
  1. hostapd and wpa_supplicant:
  1. iw and ip commands:

Example Workflow

When you configure an SSID in /etc/config/wireless and run wifi reload, the following steps typically occur:

  1. netifd reads the UCI configuration:
  1. netifd interacts with hostapd or wpa_supplicant:
  1. Use of iw and ip commands:

Example Commands Used by netifd

For a given wireless interface setup, the following types of commands might be used:

Example Configuration and Commands

Here is a more detailed look at how you might see these processes play out:

  1. Configuration in /etc/config/wireless:
config wifi-device 'radio0'
    option type 'mac80211'
    option channel '6'
    option hwmode '11g'

config wifi-iface
    option device 'radio0'
    option network 'lan'
    option mode 'ap'
    option ssid 'YourSSID'
    option encryption 'psk2'
    option key 'YourPassphrase'
    option ifname 'phy0-ap2'
  1. netifd generates hostapd configuration:
interface=phy0-ap2
driver=nl80211
ssid=YourSSID
hw_mode=g
channel=6
auth_algs=1
wpa=2
wpa_passphrase=YourPassphrase
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
  1. Commands executed by netifd:
ip link set dev phy0-ap2 up
iw dev phy0-ap2 set ssid YourSSID
iw dev phy0-ap2 set channel 6
hostapd /var/run/hostapd-phy0.conf

An example of real wifi config

cat /etc/config/wireless

config wifi-device 'radio0'
	option type 'mac80211'
	option path 'platform/soc/18000000.wifi'
	option channel '1'
	option band '2g'
	option htmode 'HE20'
	option disabled '0'
	option country 'US'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option ssid 'tuf-ax4200-2g-0-0'
	option encryption 'psk2'
	option key '12345678'
	option ifname 'vif0'

config wifi-iface 'vif1_radio0'
  option device 'radio0'
  option network 'lan'
  option mode 'ap'
	option ssid 'tuf-ax4200-2g-0-1'
	option encryption 'psk2'
	option key '12345678'
	option ifname 'vif1'

config wifi-device 'radio1'
	option type 'mac80211'
	option path 'platform/soc/18000000.wifi+1'
	option channel '36'
	option band '5g'
	option htmode 'HE80'
	option disabled '0'
	option country 'US'

config wifi-iface 'default_radio1'
	option device 'radio1'
	option network 'lan'
	option mode 'ap'
	option ssid 'tuf-ax4200-5g-1'
	option encryption 'psk2'
	option key '12345678'

Share


Tags


Counters

Support us

Science Chronicle