您好,登錄后才能下訂單哦!
小編給大家分享一下OpenWRT如何啟用工作模式開(kāi)關(guān)和聯(lián)網(wǎng),希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
主要配置 rc.local 腳本,內(nèi)容如下:
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
原理是開(kāi)機(jī)自動(dòng)復(fù)制配置文件覆蓋到 /etc/config/ 下,配置文件不需要全部,只要 firewall、network 和 wireless 就行了。按工作模式命名,創(chuàng)建三個(gè)目錄:
mkdir /etc/config/ap mkdir /etc/config/repeater mkdir /etc/config/hotspot
后面,我們會(huì)把配置文件寫(xiě)好了,放在這些目錄里。下面以 ap 為例,此模式是網(wǎng)口做 WAN,無(wú)線做 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='寬帶賬號(hào)' 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/
再來(lái)說(shuō)一下 repeater,網(wǎng)口做 LAN,無(wú)線做一個(gè) AP Client 和一個(gè) AP。注意,以下命令以初始化的配置文件為基礎(chǔ),請(qǐng)事先備份、還原,不要在配置過(guò)前面的 ap 模式后直接繼續(xù)配置,可能會(huì)有問(wèn)題。
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='現(xiàn)有 WiFi 名字' uci set wireless.@wifi-iface[-1].device='radio0' uci set wireless.@wifi-iface[-1].mode='sta' uci set wireless.@wifi-iface[-1].bssid='現(xiàn)有無(wú)線路由器的 MAC 地址' uci set wireless.@wifi-iface[-1].encryption='psk2+ccmp' uci set wireless.@wifi-iface[-1].key='現(xiàn)有 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/
看完了這篇文章,相信你對(duì)“OpenWRT如何啟用工作模式開(kāi)關(guān)和聯(lián)網(wǎng)”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。