自宅では母屋と離れにそれぞれ Wi-Fi のアクセスポイントが設置してあって、うち一台は昔に購入した FON ルータだったりします。FON ルータを介しての Web の閲覧やインターネット サービスの使用など、モバイル機器側から LAN 側に接続して使用するには特に支障はありませんでした。しかし、FON は Wi-Fi ルータとして動作しているため、例えば AirDroid や WiFi File Transfer などのように、モバイル機器に向けて LAN クライアントから接続する必要があるようなケースでは、LAN 側からルータを超えられるよう設定が別途必要です。更に Wi-Fi 側の機器が DHCP 運用で IP が固定されていない場合などには、更に設定が面倒になります。
そこで、FON ルータを hack して FON ブリッジに改造してみます。ブリッジ接続であれば、LAN と同じネットワーク セグメントに接続されますから、先述の問題も気にしなくて構いません。また、DHCP サーバも現在 LAN 側で稼動しているものがそのまま使えます。既にルータが設置されている場合には、アクセス ポイントはブリッジの方が管理が楽だったりします。
通常の状態で FON ルータにアクセスする手段は Web インターフェイスしかなく、このままでは力不足でゴニョゴニョできません。そこで SSH 接続してコマンドを叩く必要があるのですが、SSH 接続を可能にするにはファームウェア バージョン 0.7.1 r1 が必要になります。
016E62667DA3BCFEFC100AB89CE94524E2B3B51605E41F0798C1269E6A8206F78510B8662E66CADB14A51DA343CF599CF27BB2F0B80A5CDBEDD830A011B47F3579FB34ABFCC97FB9ファームウェアが破損して起動しなくなる*1 ともありますが問題ないようです。
login as: root root@169.254.255.1's password: admin BusyBox v1.1.3 (2006.11.21-19:49+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. _______ _______ _______ | ____|| || _ | | ____|| - || | | | | | |_______||__| |__| |___| Fonera Firmware (Version 0.7.1 rev 1) ------------- * * Based on OpenWrt - http://openwrt.org * Powered by FON - http://www.fon.com ---------------------------------------------------
### 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
#. /tmp/.thinclient.sh cp /tmp/.thinclient.sh /tmp/thinclient-$(date '+%Y%m%d-%H%M')
Unknown の場合、[高度な設定]-[インターネット接続] で "Save" ボタンを押しておきます。Tips - FoNまとめwiki を参考にブリッジ化します。
# cd /etc # cp chilli.conf chilli.conf.ok
# http://fon-wiki.maniado.com/index.php?Tips#ffef6c7d uamallowed ssl.google-analytics.com,c26.statcounter.com,www.fonshop.jp,gringo.fon.com,mpsnare.iesnare.com,www.verisign.com,www.verisign.co.jp uamallowed labs.fon.com,213.134.44.0/23,static.fon.com,www.fonshop.com.tw,a4.g.akamai.net
ブリッジ設定のための初期化スクリプトで、パブリック Wi-Fi の MAC アドレスが必要になりますので調べておきます。
# iwconfig
...
ath0 IEEE 802.11g ESSID:"FON_AP"
Mode:Master Frequency:2.437 GHz Access Point: XX:XX:XX:XX:XX:XX
...
#!/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
# WAN 側インタフェースの IP アドレス設定:DHCP で取得する場合
# /sbin/udhcpc -i br0 -R
# WAN 側インタフェースの IP アドレス設定:固定 IP の場合
/sbin/ifconfig br0 192.168.1.1
/sbin/route add default gw 192.168.1.10
# alias for configuration
/sbin/ifconfig br0:1 169.254.255.1 up
# 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
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_AP"
ifconfig ath0 up
# restarting dnsmasq but without dhcp
dnsmasq
# restarting chilli
chilli -c /etc/chilli.conf.ok \
--dns1=208.67.222.222 \
--dns2=208.67.220.220 \
--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
起動スクリプトに実行権限を与えて再起動します。
# chmod 755 /etc/init.d/N15bridge # reboot
br0、br:1、eth0ath0、wifi0ath1