uci 設置網絡命令

轉載有道:http://blog.csdn.net/jk110333/article/details/19479747

OPENWRT使用命令行設置無線和有線網絡
 
在我們將路由器固件刷成開源的基於Linux內核的openwrt系統後,由於openwrt默認未安裝WEB管理界面,所以我們需要先通過SSH或者telnet對路由器進行網絡設置,設置完成後可通過openwrt的軟件包管理opkg安裝web設置界面Luci。 
設置lan ip(即訪問路由的ip) 
Shell代碼  
uci set network.lan.ipaddr=[lan ip]  
 
使用pppoe設置 
Shell代碼  
uci set network.wan.proto=pppoe    //設置wan口類型爲pppoe  
uci set network.wan.username=[上網帳戶]  
uci set network.wan.password=[上網密碼]    //這兩行設置pppoe用戶名和密碼  
 
如果要掛在上級路由下面,就需要進行下面的設置 
Shell代碼  
uci set network.wan.proto=none    //關掉wan  
uci set network.lan.gateway=[上級路由ip]    //網關指向上級路由  
uci set network.lan.dns=[上級路由ip]    //dns指向上級路由  
uci set dhcp.lan.ignore=1    //關掉lan的dhcp  
 
最後對無線網絡進行配置 
Shell代碼  
uci set wireless.@wifi-device[0].disabled=0    //打開無線  
uci set wireless.@wifi-device[0].txpower=17    //設置功率爲17dbm 太高會燒無線模塊  
uci set wireless.@wifi-device[0].channel=6    //設置無線信道爲6  
uci set wireless.@wifi-iface[0].mode=ap    //設置無線模式爲ap  
uci set wireless.@wifi-iface[0].ssid=[自己設置SSID]    //設置無線SSID  
uci set wireless.@wifi-iface[0].network=lan    //無線鏈接到lan上  
uci set wireless.@wifi-iface[0].encryption=psk2    //設置加密WPA2-PSK  
uci set wireless.@wifi-iface[0].key=[密碼]    //設置無線密碼  
 
提交應用配置 
Shell代碼  
uci commit    //應用  
/etc/init.d/network restart    //重啓網絡服務  
 
 
安裝luci管理界面 
Shell代碼  
opkg update // 更新軟件列表  
opkg list-installed // 查看已安裝軟件  
opkg install luci // 安裝LUCI  
opkg install luci-i18n-chinese // 支持中文  
 
即可完成LUCI的安裝。 
輸入以下命令開啓支持web服務的uhttpd,並設置其爲自啓動: 
Shell代碼  
/etc/init.d/uhttpd enable # 開機自啓動  
/etc/init.d/uhttpd start # 啓動uhttpd 
發佈了26 篇原創文章 · 獲贊 39 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章