Skip to content

NETWORK

alan-wt edited this page Apr 28, 2021 · 5 revisions

如何使用wifi

AP模式

将wifi作为AP模式供其他wifi设备连接

修改配置

无密码模式

uci set wireless.wlan0.ssid='WT-AP'
uci set wireless.wlan0.encryption='none'
uci set wireless.wlan0.disabled=0
uci set wireless.wisp0.disabled=1
uci commit wireless

有密码模式

uci set wireless.wlan0.ssid='WT-AP'
uci set wireless.wlan0.encryption='mixed-psk'
uci set wireless.wlan0.key='12345678'
uci set wireless.wlan0.disabled=0
uci set wireless.wisp0.disabled=1
uci commit wireless

生效配置

wifi

STA模式

将wifi作为sta模式连接其他AP

修改配置

无密码模式

uci set wireless.wisp0.ssid='WT-AP'
uci set wireless.wisp0.encryption='none'
uci set wireless.wisp0.disabled=0
uci set wireless.wlan0.disabled=1
uci set wireless.wlan0.disabled=1
uci set network.wisp0.disabled=0
uci commit wireless
uci commit network

有密码模式

uci set wireless.wisp0.ssid='WT-AP'
uci set wireless.wisp0.encryption='mixed-psk'
uci set wireless.wisp0.key='12345678'
uci set wireless.wisp0.disabled=0
uci set wireless.wlan0.disabled=1
uci set wireless.wlan0.disabled=1
uci set network.wisp0.disabled=0
uci commit wireless
uci commit network

生效配置

wifi
ifup -w wisp0

备注

名字 描述
ssid 无线名称
encryption 加密方式
key 密钥
disabled 1为关闭,0位开启

工具使用

参考https://openwrt.org/docs/guide-user/network/wifi/wireless-tool/wireless.utilities

获取接口信息

iwinfo wlan0 info

获取扫描结果

iwinfo wlan0 scan

获取AP模式下STA客户端

iwinfo wlan0 assoclist

如何使用有线

默认有线作为LAN口使用

连接外网

uci set network.lan.proto=dhcp
uci commit network
/etc/init.d/network restart

网口热插拔事件

当插拔网线时,会有一个hotplug事件产生,将自动执行/etc/hotplug.d/phy/目录下的脚本。
参数:
ACTION:linkdown/linkup,linkdown表示网线断了,linkup表示网线插上
IFNAME:eth0/eth1,当网口板子只有eth0设备

如何使用4G

默认USB连接到4G模组AIR724

切换成USB接口

由于默认USB连接到4G模组AIR724,可以通过如下方法将USB当做外置接口使用,关闭4G。

uci set network.lte.usbmode=usb
uci set network.lte.disabled=1
uci commit network
/etc/init.d/lte restart

切换成4G

uci set network.lte.usbmode=lte
uci set network.lte.disabled=0
uci commit network
/etc/init.d/lte restart

参考

可参考openwrt-network