2010年12月14日火曜日

SC-02B で インフラストラクチャモードでテザリング(3)

※ 重要
・無保証です。
・高額課金、文鎮化、root取得にともなうSC-02Bの保証の無効化などの各種トラブルはテザリングしたユーザの自己責任で対応お願いします。
・spモードでは規約上テザリングは禁止されています。

テザリング開始、テザリング終了のシェルスクリプトを作ってみました。

テザリング開始 (/sdcard/tether/bin/tether_start)
#!/system/bin/sh
ifconfig eth0 0.0.0.0
ifconfig wl0.1 192.168.2.1 netmask 255.255.255.0
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
sysctl -w net.ipv4.ip_forward=1
killall dnsmasq
dnsmasq -i wl0.1 --resolv-file=/sdcard/tether/conf/resolv.conf --conf-file=/sdcard/tether/conf/dnsmasq.conf

テザリング終了 (/sdcard/tether/bin/tether_stop)
#!/system/bin/sh
killall dnsmasq
sysctl -w net.ipv4.ip_forward=0
iptables -t nat -F POSTROUTING
ifconfig wl0.1 0.0.0.0

あらかじめdnsmasq.confとresolv.confを用意しておきます。
また /sdcard/tether/var というディレクトリも用意します。

dnsmasq.conf (/sdcard/tether/conf/dnsmasq.conf)
dhcp-authoritative
dhcp-range=192.168.2.100,192.168.2.105,12h
dhcp-leasefile=/sdcard/tether/var/dnsmasq.leases
pid-file=/sdcard/tether/var/dnsmasq.pid
user=root
no-negcache

resolv.conf (/sdcard/tether/conf/resolv.conf)
nameserver 220.159.212.200
nameserver 220.159.212.201

テザリング開始、テザリング終了は以下の方法で行っています。

テザリング開始
1. Mobile AP のチェックボックスをチェックし「Onにしています...」の表示を確認する
2. root で sh /sdcard/tether/bin/tether_start を実行

テザリング終了
1. root で sh /sdcard/tether/bin/tether_stop を実行
2. Mobile AP のチェックボックスをチェック外す

tetehr_start tether_stop 実行には ScriptMe などの
root指定実行可能なshellscript 実行アプリを使用するのもいいかも知れません

0 件のコメント: