PuTTY和WinSCP是管理OpenWRT固件的路由器必備工具。node
WinSCP的優點在於支持多語言、可在圖形化界面下管理Linux系統裏的文件和存儲多個會話設置以方便多設備多用戶登陸。PuTTY的優點在於提供與Linux終端同樣的命令行控制界面。linux
因此,通常可先用WinSCP登陸,管理文件,在必要的時候,調出PuTTY輸入終端命令,實現優點互補。那既然在WinSCP中快速調用PuTTY輸入終端命令是常見的事,就得讓兩者更好的配合,方法以下:服務器
1.下載免安裝版的WinSCP,解壓至XXX\WinSCP目錄(XXX表示某一個目錄);
2.下載須要的語言包,解壓至XXX\WinSCP目錄;
3.下載免安裝版的PuTTY,解壓至XXX\PuTTY;
4.運行XXX\WinSCP\WinSCP.exe,出現「WinSCP登陸」窗口;
5.按下「Languages」按鈕,選擇語言;
6.勾選「高級選項」;
7.選擇樹狀列表中的「選項」項目;
8.按下「其它通用選項」的「選項」按鈕,彈出的「選項」窗口;
9.選擇「選項」窗口裏樹狀列表中的「集成-應用程序」;
10.把「PuTTY路徑」改成相對路徑的「..\PuTTY\putty.exe」(這一步是關鍵,路徑前面的「..」表示父目錄,即表明上面「XXX」目錄,改爲這樣的好處是之後只要把XXX目錄下的WinSCP和PuTTY兩個目錄一塊兒移動到其它任意一個目錄後,這個設置依然有效);
11.勾選「記住會話密碼並傳給PuTTY(SSH)」項目,點「肯定」按鈕返回「WinSCP登陸」窗口;
12.選擇樹狀列表中的「會話」項目;
13.在「文件協議」下拉列表框中選擇「SCP」;
14.在「主機名」文本框中輸入「192.168.99.1」(如意·雲路由默認的IP地址);
15.在「端口號」文本框中輸入「22」(OpenWRT SSH服務默認的端口);
16.在「用戶名」文本框中輸入「root」(OpenWRT默認的管理員帳戶名);
17.在「密碼」文本框中輸入管理員帳戶的密碼;
18.點「保存」按鈕,彈出「會話另存爲」窗口;
19.在「會話另存爲」文本框中輸入會話名稱,點「肯定」按鈕返回「WinSCP登陸」窗口;
20.在選擇樹狀列表中的「會話-存儲的會話」項目;
21.選擇會話名稱,點「登陸」按鈕,彈出「警告」窗口;
22.按「否」按鈕,彈出「WinSCP」主界面,左側是本地目錄,右側是路由器的Linux系統目錄;
23.能夠在本地目錄和路由器Linux系統目錄間拖拽文件完成文件複製傳輸,在路由器的Linux系統目錄的文件上按雙擊能夠打開文件,按「Ctrl+P」快捷鍵(或按「命令」主菜單-「在PuTTY中打開」),彈出「PuTTY Security Alert」窗口,按「否」鍵鈕,可直接打開PuTTY窗口並自動登陸路由器的Linux終端。markdown
1.1 Root無密碼時: 可用HFS構建HTTP文件服務器. 如:http://192.168.1.224/wr703n-eok.bin, 而後CMD命令窗口中輸入命令:
telnet 192.168.1.1
cd /tmp
wget http://192.168.1.224/wr703n-eok.bin
1.2 Root有密碼時: 先將固件用winscp上傳到/tmp/下或者用上面的wget命令, 而後用putty或者securecrt登錄路由器
2. mtd -r write /tmp/固件.bin firmware, 成功後會出現 rebooting…
注: dd下用 linux,openwrt下用 firmware網絡
static void usage(void)
{
fprintf(stderr, "Usage: mtd [<options> ...] <command></command> [<arguments> ...] <device>[:<device>...]\n\n"
"The device is in the format of mtdX (eg: mtd4) or its label.\n"
"mtd recognizes these commands:\n"
" unlock unlock the device\n"
" refresh refresh mtd partition\n"
" erase erase all data on device\n"
" write <imagefile>|- write <imagefile> (use - for stdin) to device\n"
" jffs2write <file> append <file> to the jffs2 partition on the device\n");
if (mtd_fixtrx) {
fprintf(stderr,
" fixtrx fix the checksum in a trx header on first boot\n");
}
fprintf(stderr,
"Following options are available:\n"
" -q quiet mode (once: no [w] on writing,\n"
" twice: no status messages)\n"
" -n write without first erasing the blocks\n"
" -r reboot after successful command\n"
" -f force write without trx checks\n"
" -e <device> erase <device> before executing the command\n"
" -d <name> directory for jffs2write, defaults to \"tmp\"\n"
" -j <name> integrate <file> into jffs2 data when writing an image\n");
if (mtd_fixtrx) {
fprintf(stderr,
" -o offset offset of the image header in the partition(for fixtrx)\n");
}
fprintf(stderr,
#ifdef FIS_SUPPORT
" -F <part>[:<size>[:<entrypoint>]][,<part>...]\n"
" alter the fis partition table to create new partitions replacing\n"
" the partitions provided as argument to the write command\n"
" (only valid together with the write command)\n"
#endif
"\n"
"Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
" mtd -r write linux.trx linux\n\n");
exit(1);
}</part></entrypoint></size></part></file></name></name></device></device></file></file></imagefile></imagefile></device></device></arguments></options>
Opkg 是一個輕量快速的套件管理系統,目前已成爲 Opensource 界嵌入式系統標準。
經常使用於路由、交換機等嵌入式設備中,用來管理軟件包的安裝升級與下載。經常使用命令以下:
opkg update 更新能夠獲取的軟件包列表
opkg upgrade 對已經安裝的軟件包升級
opkg install 安裝指定的軟件包
opkg instal /tmp/xxx.ipk
opkg install http://openwrt.8800.org:82/nwan.ipk
opkg install http://openwrt.8800.org/luci-app-nwan.ipk
opkg install –force-reinstall http://192.168.1.224/uhttpd_32_ar71xx.ipk
opkg remove 卸載已經安裝的指定的軟件包. opkg remove luci-i18n-chinese
opkg list
opkg list-installedapp
Force Options:
–force-depends Install/remove despite failed dependencies
–force-maintainer Overwrite preexisting config files
–force-reinstall Reinstall package(s)
–force-overwrite Overwrite files from other package(s)
–force-downgrade Allow opkg to downgrade packages
–force-space Disable free space checks
–force-postinstall Run postinstall scripts even in offline mode
–force-remove Remove package even if prerm script fails
–noaction No action – test only
–download-only No action – download only
–nodeps Do not follow dependencies
–force-removal-of-dependent-packages
Remove package and all dependencies
–autoremove Remove packages that were installed
automatically to satisfy dependencies
-t Specify tmp-dir.
–tmp-dir Specify tmp-dir.ide
通常咱們在openwrt下用opkg安裝軟件有兩種:
1. 連上網絡後從官方網站安裝 opkg update; opkg install XXX.ipk;
opkg install http://openwrt.8800.org/luci-app-nwan.ipk
2. PC上把軟件下載下來,傳到路由器tmp目錄安裝 opkg install /tmp/XXX.ipk工具
對於1來講,若是路由暫時上不了網,就沒法使用,方法2又有些麻煩. 這裏提供的方法是:
1. 修改/etc/opkg.conf, 把裏邊第一行那個網址改爲本地服務器放安裝包的服務目錄,
#src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
src/gz snapshots http://192.168.1.224/packages-r31296
2. 把相關的 packages 目錄下的文件都放在上步定義的目錄下(packages-r31296爲目錄名)
3. 在本機上用 HTS 開啓http服務, 添加上面的目錄
4. 如今能夠像方法1同樣使用升級了post
工做圖片以下:
網站