OpenWrt 命令行配置Wi-Fi AP和USB网卡

#!/bin/sh

echo "network configuration..."

# 启动AP网卡和USB网卡
ifconfig wlan0 up
ifconfig eth1 up

# 更改br0-lan网卡的地址
uci set network.lan.ipaddr=10.10.10.1

# 配置AP
uci set wireless.@wifi-device[0].disabled=0
uci set wireless.@wifi-device[0].txpower=17
uci set wireless.@wifi-device[0].channel=6
uci set wireless.@wifi-iface[0].mode=ap
uci set wireless.@wifi-iface[0].ssid=OpenWrt_1234
uci set wireless.@wifi-iface[0].network=lan
uci set wireless.@wifi-iface[0].encryption=psk2
uci set wireless.@wifi-iface[0].key=99887766

# 配置USB网卡,设置防火墙
uci set network.usb_wan=interface
uci set network.usb_wan.proto=dhcp
uci set network.usb_wan.device=eth1
uci set firewall.@zone[1].network="$(uci get firewall.@zone[1].network) usb_wan"

# 保存配置并生效
uci commit
/etc/init.d/network restart

posted @ 2021-11-04 14:39  duapple  阅读(297)  评论(0编辑  收藏  举报  来源