您好,登錄后才能下訂單哦!
小編給大家分享一下OpenWRT如何啟用工作模式開關和聯網,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
主要配置 rc.local 腳本,內容如下:
read_gpio() { (echo $1 > /sys/class/gpio/export) >& /dev/null (echo "in" > /sys/class/gpio/gpio$1/direction) >& /dev/null return `cat /sys/class/gpio/gpio$1/value`; } read_gpio 19; v=$?; read_gpio 20; v=$v$?; read_gpio 21; v=$v$?; read_gpio 22; v=$v$?; read_gpio 23; v=$v$?; case "$v" in 10001) v="ap";; 11001) v="repeater";; 01001) v="hotspot";; 11000) v="4th";; *) v="error";; esac cp /etc/config/$v/* /etc/config/ logger working mode: $v exit 0
原理是開機自動復制配置文件覆蓋到 /etc/config/ 下,配置文件不需要全部,只要 firewall、network 和 wireless 就行了。按工作模式命名,創建三個目錄:
mkdir /etc/config/ap mkdir /etc/config/repeater mkdir /etc/config/hotspot
后面,我們會把配置文件寫好了,放在這些目錄里。下面以 ap 為例,此模式是網口做 WAN,無線做 LAN,WAN 以 ADSL 接入為例,其它情況自行變通:
uci set wireless.@wifi-device[0].disabled=0; uci set wireless.@wifi-iface[0].ssid='umu618.com'; uci set wireless.@wifi-iface[0].encryption='psk2+ccmp'; uci set wireless.@wifi-iface[0].key='WiFi 密碼'; uci commit wireless; wifi uci delete network.lan.ifname uci delete network.lan.type uci add network interface uci rename network.@interface[-1]='wan' uci set network.@interface[-1].ifname='eth2' uci set network.@interface[-1]._orig_ifname='eth2' uci set network.@interface[-1]._orig_bridge='false' uci set network.@interface[-1].proto='pppoe' uci set network.@interface[-1].username='寬帶賬號' uci set network.@interface[-1].password='寬帶密碼' uci commit network cp /etc/config/firewall /etc/config/ap/ cp /etc/config/network /etc/config/ap/ cp /etc/config/wireless /etc/config/ap/
再來說一下 repeater,網口做 LAN,無線做一個 AP Client 和一個 AP。注意,以下命令以初始化的配置文件為基礎,請事先備份、還原,不要在配置過前面的 ap 模式后直接繼續配置,可能會有問題。
uci add network interface uci rename network.@interface[-1]='wwan' uci set network.@interface[-1].proto='dhcp' uci commit network uci set wireless.@wifi-device[0].disabled=0; uci set wireless.@wifi-iface[0].ssid='umu618.com'; uci set wireless.@wifi-iface[0].encryption='psk2+ccmp'; uci set wireless.@wifi-iface[0].key='WiFi 密碼'; uci add wireless wifi-iface uci set wireless.@wifi-iface[-1].network='wwan' uci set wireless.@wifi-iface[-1].ssid='現有 WiFi 名字' uci set wireless.@wifi-iface[-1].device='radio0' uci set wireless.@wifi-iface[-1].mode='sta' uci set wireless.@wifi-iface[-1].bssid='現有無線路由器的 MAC 地址' uci set wireless.@wifi-iface[-1].encryption='psk2+ccmp' uci set wireless.@wifi-iface[-1].key='現有 WiFi 密碼' uci commit wireless; wifi uci get firewall.@zone[1].network uci show firewall.@zone[1] uci set firewall.@zone[1].network='wan wan6 wwan' uci commit firewall /etc/init.d/firewall restart cp /etc/config/firewall /etc/config/repeater/ cp /etc/config/network /etc/config/repeater/ cp /etc/config/wireless /etc/config/repeater/
看完了這篇文章,相信你對“OpenWRT如何啟用工作模式開關和聯網”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。