« [亂摘] 本週亂摘之搶先報 | Home | [本週亂摘] 本週亂亂亂摘 »
La Fonera初體驗
大約是在1月中的時候,我收到了我的La Fonera(FON的專用路由器)。對於已經使用WiFi快3年的我來說,安裝真的非常簡單,大約5分鐘就搞定了。倒是後來要上到Fon的網站登錄La Fonera的地圖資料,還費力得多。因為與FON合作的Google Map並沒有台灣的街道地址資料,所以只能靠滑鼠拖拉點選,找自己的家找到眼睛都快脫窗了。幸好我家還滿好認的。
![]()
雖然裝好了,卻沒有用的慾望,因為La Fonera沒有提供「橋接」模式,所以接在WiFi後面的電腦無法跟有線端的電腦取得同一class的IP,這樣在我家裡的環境用起來,真的非常綁手綁腳。
所以我拜了咕狗大神,請大神指點迷津,看有沒有辦法變出「橋接」模式來。果然,因為La Fonera裡面的韌體是來自Open-WRT,是embaded Linux的一種,所以可以玩的花樣就多了。以下的資訊適用韌體0.7.1r1版,如果La Fonera已經自動更新到r2了,請hard-reset回去。
- 首先要開啟La Fonera的ssh。登入La Fonera,輸入管理密碼。把底下兩個檔存好,依次扔到瀏覽器去執行。其中「192.168.10.1」是初始設定的La Fonera位址。
step1.html<html>
<head>
</head>
<body>
<center>
<form method="post" action="http://192.168.10.1/cgi-bin/webif/connection.sh" enctype="multipart/form-data">
<input name="username" value="$(/usr/sbin/iptables -I INPUT 1 -p tcp –dport 22 -j ACCEPT)" size="68" >
<input type="submit" name="submit" value="Submit" onClick="{this.form.wifimode.value=’";‘ + this.form.wifimode.value +’;"’}" />
</form>
</body>
</html>step2.html
<html>
<head>
</head>
<body>
<center>
<form method="post" action="http://192.168.10.1/cgi-bin/webif/connection.sh" enctype="multipart/form-data">
<input name="username" value="$(/etc/init.d/dropbear)" size="68" >
<input type="submit" name="submit" value="Submit" onClick="{this.form.wifimode.value=’";‘ + this.form.wifimode.value +’;"’}" />
</form>
</body>
</html>如果Web管理畫面沒有出現什麼錯誤訊息的話,ssh port應該已經順利被暫時開啟。
- 接著以root帳號登入La Fonera的ssh server,先執行以下指令:
% mv /etc/init.d/dropbear /etc/init.d/S50dropbear
編輯/etc/firewall.user,找到有「–dport 22」字串的那兩行,把註解拿掉,永久開啟ssh port:
### Open port to WAN
## -- This allows port 22 to be answered by (dropbear on) the router
iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j ACCEPT
iptables -A input_rule -i $WAN -p tcp --dport 22 -j ACCEPT - 修改/bin/thinclient,讓La Fonera不會再自動更新。把最後一行註解起來就行了。
#. /tmp/.thinclient.sh
如果想知道FON那邊提供了什麼更新檔,可以再最後補上一行:
cp /tmp/.thinclient.sh /tmp/thinclient-$(date '+%Y%m%d-%H%M') - 然後是重頭戲 — 把La Fonera由NAT改為橋接模式。到/tmp下去建立一個新檔N15bridge,內容如下:
#!/bin/ash
echo "Setting up LAN bridge"
# Kill DHCP server+ client
/usr/bin/killall dnsmasq
/usr/bin/killall -9 udhcpc
# create bridge interface
/usr/sbin/brctl addbr br0
/usr/sbin/brctl stp br0 off
/usr/sbin/brctl setfd br0 0
# shutdown/remove IPs from the old interfaces
/sbin/ifconfig eth0:1 down
/sbin/ifconfig eth0 0.0.0.0
/sbin/ifconfig ath1 0.0.0.0
# bring up the bridge interface
/sbin/ifconfig br0 up
# add the old interfaces to the bridge
/usr/sbin/brctl addif br0 ath1
/usr/sbin/brctl addif br0 eth0
# Set IP for the bridge
#/sbin/udhcpc -i br0 -R # get new IP via dhcp
/sbin/ifconfig br0 192.168.10.123 # static IP
/sbin/route add default gw 192.168.10.1
# set firewall rules
iptables -A INPUT -i br0 -j ACCEPT
iptables -A OUTPUT -o br0 -j ACCEPT
# add bridge to hostapd.conf and restart hostapd (allows to use WPA)
[ `grep -c bridge=br0 /tmp/hostapd.conf` = "0" ] && echo bridge=br0 >> /tmp/hostapd.conf
/usr/bin/killall killall hostapd
/usr/sbin/hostapd -B /tmp/hostapd.conf
# stopping chillispot
/etc/init.d/N50chillispot stop
# bringing ath0 (hotspot interface) down
/sbin/ifdown hotspot
# bringing it manually up
wlanconfig ath0 create wlandev wifi0 wlanmode ap
iwconfig ath0 essid "FON_MoonSoap"
ifconfig ath0 up
# restarting dnsmasq but without dhcp
dnsmasq
# restarting chilli
chilli --dns1=192.168.10.123 --dns2=192.168.10.123 --radiusnasid=xx-xx-xx-xx-xx-xx --dhcpif ath0
# configuring iptables
iptables -R NET_ACCESS 6 -i br0 -j ACCEPT
iptables -R NET_ACCESS 7 -o br0 -j ACCEPT
iptables -t nat -R POSTROUTING 2 -o br0 -j MASQUERADE其中「192.168.10.123」就是La Fonera的IP,「xx-xx-xx-xx-xx-xx」則要換成公用WiFi(ath0介面,可以ifconfig指令查得)的MAC位址。
把它加上執行屬性,執行它。靜待30秒後,重新連上La Fonera的私用SSID,如果拿到的IP跟原本LAN的網段一致,那就成功了。
- 把N15bridge檔複製到/etc/init.d下,這樣La Fonera斷電後重開機也會回到橋接模式。
貼標籤:碎碎唸




No comments
Jump to comment form | comments rss | trackback uri