opkg update
opkg install luci
/etc/init.d/uhttpd enable
/etc/init.d/uhttpd start
在瀏覽器訪問路由器的網關地址即可看到luci界面了,就可以在瀏覽器直觀的配置路由器了。為了配置多ssid,我們可以在openwrt上開啟vlan來模擬多個虛擬子網如vlan1和vlan2
config switch eth1
option reset 1
option enable_vlan 1
config switch_vlan
option vlan 1
option device eth1
option ports '0 1 2 5t'
config switch_vlan
option vlan 2
option device eth1
option ports '3 5t'
兩個vlan網絡接口分別為eth1.0和eth1.1,0、1、2口為一個子網,3口單獨一個子網。現在把eth1.0和eth1.1兩個網絡接口組成一個網橋lan:
config interface lan
option type bridge
option ifname 'eth1.0 eth1.1'
option proto none
lan默認不設置ip,如果想遠程訪問OpenWrt,則必須按情況設置static或dhcp。
關閉防火墻,因為網橋用不著:
/etc/init.d/firewall disable
重啟網絡后可以用ifconfig看到很多網絡接口,只要監聽br-lan就行了:
br-lan Link encap:Ethernet HWaddr ××××××××××××××××××
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1 Link encap:Ethernet HWaddr \*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\**
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:14
eth1.0 Link encap:Ethernet HWaddr \*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\*
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1.1 Link encap:Ethernet HWaddr \*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\*
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
在OpenWrt里安裝Tcpdump:
opkg install tcpdump
運行Tcpdump監聽POP郵箱密碼:
tcpdump -X -i br-lan port 110
/udisk/tcpdump -XvvennSs 0 -i br-lan tcp[20:2]=0x4745 or tcp[20:2]=0x4854 -w ./udisk/test.cap
將結果dump到本地,0x4745 為"GET"前兩個字母"GE",0x4854 為"HTTP"前兩個字母"HT"。
注意:tcpdump 對截獲的數據并沒有進行徹底解碼,數據包內的大部分內容是使用十六進制的形式直接打印輸出的。顯然這不利于分析網絡故障,通常的解決辦法是先使用帶-w參數的tcpdump 截獲數據并保存到文件中,然后再使用其他程序(如Wireshark)進行解碼分析。當然也應該定義過濾規則,以避免捕獲的數據包填滿整個硬盤。
下圖是test.cap在wireshark中的展現。