• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : [已OK]請問tether-wifi的問題 复制链接 | 浏览器收藏 | 打印
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
贡献值: 0 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
楼主  发表于: 2011-11-16 18:33

 [已OK]請問tether-wifi的問題

一如之前的一系列我所問的問題,我想使用wifi-tether(bridge)功能
但是從
1.iptables:重編kernelOK,但是insmod wifi module,系統重新開機(bridge與iptables/netfilter相衝)
2.移植bridge-util :編譯錯誤,無法完成brctl
3.移植busybox:移植成功,但是brctl,需要kernel支持的,重編kernelOK,但是insmod wifi module,系統重新開機
  (重新編譯kernel,,開啟bridge功能,並把 iptables/netfilter全部關閉)
4.開啟/res/res/values/config.xml,但僅有選單沒有功能:X
5.安裝wifi-tether:但需要iptables的,所以情形又同1.

我目前採用方法1. 確定可以分派IP(用iptables nat方式分享ethernet的訊號給wlan0)

1.重新編譯kernel,把 iptables/netfilter選項開啟

-> Networking support
   -> Networking options
        -> Network packet filtering framework(Netfilter)
            -> Network packet filtering debugging
         -> Advaned netfilter configuration
                Core Netfilter Configuration
                -> Netfilter NFQUEUE over NFNETLINK interface
                -> Netfilter connection tracking support
                -> Netbios name service protocal support(new)
                -> Netfilter Xtables support (required for ip_tables)
                   -> multiport Multiple port match support
                   -> owner match support
                   -> state match support
                 IP: Netfilter Configuration
                  -> IPv4 connection tracking support (require for NAT)
                  ->    proc/sysctl compatibility with old connection tracking
                  -> IP tables support (required for filtering/masq/NAT)
                  -> Packet filtering
                  ->  REJECT target support
                  -> Full NAT
                   -> MASQUERADE target support
                   -> REDIRECT target support

2.編譯ar6000.ko
3.hostapd及dnsmasq
4.撰寫/data/misc/wifi/hostapd.conf 、 /etc/resolv.conf

     /data/misc/wifi/hostapd.conf

       interface=wlan0
       ctrl_interface=wlan0
       ssid=AR6003AP
       channel=1
       max_num_sta=8
       beacon_int=100
       dtim_period=1
       #hw_mode=g
       #bridge=br0
       #driver=nl80211
       #dtim_period=1
       #rts_threshold=2347
       #fragm_threshold=2346
       #macaddr_acl=0
       #auth_algs=3
       #ieee80211n=0
       #ignore_broadcast_ssid=0
       wpa=2
       wpa_passphrase=12345678
       wpa_key_mgmt=WPA-PSK
       wpa_pairwise=TKIP CCMP

     /etc/resolv.conf

       #nameserver 8.8.8.8
       #nameserver 4.4.4.4
       nameserver 218.30.19.50
       nameserver 61.134.1.5


busybox ifconfig eh0 up  //帶起eth0 接口
netcfg eth0 dhcp   //獲取dhcp IP
busybox route -n  //看路由表
insmod /system/wifi/ar6000.ko  //insmod wifi module
busybox ifconfig wlan0 192.168.11.1 up  //帶起 wlan0 接口,並直接給靜態IP
/system/bin/hostapd -B /data/misc/wifi/hostapd.conf  //啟動hostapd 加密功能

sysctl -w net.ipv4.ip_forward=1 //啟動ip_forward功能
iptables --table nat --flush //清除nat tables
iptables --delete-chain
iptables --table nat --delete-chain  
iptables --append FORWARD --in-interface wlan0 -o eth0 -j ACCEPT                            
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

dnsmasq -z -i wlan0 -F 192.168.11.100,192.168.11.200,12h  //啟動dnsmasq功能


圖片是我自己畫的,我是用iptables nat方式分享ethernet的訊號給wlan0)
[ 此帖被kazaya在2011-12-19 18:24重新编辑 ]
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
贡献值: 0 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
1楼  发表于: 2011-11-18 15:38
目前已經解決iptables與insmod wifi module相衝問題...
原因在於802.1d ethernet bridging 勾選之後
重build kernel..
再insmod wifi module 會造成系統重新開機...

以下為我iptables 在kernel 勾選的項目:

-> Networking support
   -> Networking options
        -> Network packet filtering framework(Netfilter)
            -> Network packet filtering debugging
         -> Advaned netfilter configuration
                Core Netfilter Configuration
                -> Netfilter NFQUEUE over NFNETLINK interface
                -> Netfilter connection tracking support
                -> Netbios name service protocal support(new)
                -> Netfilter Xtables support (required for ip_tables)
                   -> multiport Multiple port match support
                   -> owner match support
                   -> state match support
                 IP: Netfilter Configuration
                  -> IPv4 connection tracking support (require for NAT)
                  ->    proc/sysctl compatibility with old connection tracking
                  -> IP tables support (required for filtering/masq/NAT)
                  -> Packet filtering
                  ->  REJECT target support
                  -> Full NAT
                   -> MASQUERADE target support
                   -> REDIRECT target support

另外,我去商借 ZTE MF633 3G網卡,發現並不在支持範圍內....是不是有方法解決?.....
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
贡献值: 0 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
2楼  发表于: 2011-11-21 18:54
請問一下,
如果我想將Mini6410用ethernet,分享wifi的訊號
eth0 192.168.10.221
wlan0 192.168.0.1
DNS:192.168.10.1
Gateway:192.168.10.1

iptables 應該如何撰寫.....

我用以下命令,發現
sysctl -w net.ipv4.ip_forward=1
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --append FORWARD --in-interface wlan0 -o eth0 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

iptables -t nat -A OUTPUT -o wlan0 -j ACCEPT --to-destination 192.168.10.1

都不能route
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
贡献值: 0 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
3楼  发表于: 2011-11-22 18:39
好像brctl與iptables不能共存???
最後,我用busybox brctl+hostapd完成 bridge

1.重新移植busybox
2.adb push busybox到mini6410
3.重新編譯kernel,把 iptables/netfilter全部關閉
4.編譯ar6000.ko
5.hostapd及dnsmasq
6.撰寫/data/misc/wifi/hostapd.conf 、/etc/dnsmasq.conf、 /etc/resolv.conf



命令流程:

insmod /system/wifi/ar6000.ko
ifconfig wlan0 up
iwconfig wlan0 mode master
iwconfig wlan0 channel 1
iwconfig wlan0 essid AR6003AP
iwconfig wlan0 commit

busybox ifconfig eth0 0.0.0.0
busybox ifconfig wlan0 0.0.0.0
brctl addbr br0
brctl show
busybox brctl addif br0 eth0
busybox brctl addif br0 wlan0
busybox ifconfig br0 up
netcfg br0 dhcp
brctl stp br0 on

setprop net.dns1 127.0.0.1
setprop net.dns2 127.0.0.1

/system/bin/hostapd -B /data/misc/wifi/hostapd.conf
/system/bin/dnsmasq -d

但是dnsmasq 的功能 就不知道為何不能作用??

如果後面有dhcp seriver 派發IP,連線AR6003的SoftAP就可以上網。
此外,如果是USB應該也可以適用

以下討論是別人實作
http://blog.mycila.com/2010/06/reverse-usb-tethering-with-android-22.html
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
贡献值: 0 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
4楼  发表于: 2011-11-28 13:48
找到問題所在了...原來是我的dnsmasq.conf 寫錯了.....

interface=wlan0
listen-address=127.0.0.1
#bind-interfaces
except-interface=lo
#expand-hosts
#domain=example.com
dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-option=1,255.255.255.0 #subnet mask
dhcp-option=28,192.168.0.255 #broadcast
dhcp-option=3,192.168.10.221 #default gateway(可以上網那個介面)
dhcp-option=6,168.95.1.1 #DNS
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2011-11-28 14:12
恭喜问题解决,谢谢分享你的经验。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 11108
精华: 0
发帖: 55
金钱: 280 两
威望: 56 点
贡献值: 0 点
综合积分: 110 分
注册时间: 2009-11-27
最后登录: 2018-02-08
6楼  发表于: 2011-12-02 22:05
问个比较弱的问题,wifi部分为什么要编成模块
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
贡献值: 0 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
7楼  发表于: 2011-12-05 10:27
引用第6楼hnmsky于2011-12-02 22:05发表的  :
问个比较弱的问题,wifi部分为什么要编成模块


http://huangqinqin.iteye.com/blog/1108697
因為我不只是測試一種device,編譯成模塊比較好置換
级别: 新手上路
UID: 78951
精华: 0
发帖: 1
金钱: 5 两
威望: 1 点
贡献值: 0 点
综合积分: 2 分
注册时间: 2012-09-27
最后登录: 2012-09-28
8楼  发表于: 2012-09-27 18:47

 回 7楼(kazaya) 的帖子

請問樓主妳使用的hostapd版本是?
我目前hostapd0.7.3 及 hostapd0.6.8 無法build成功
hostapd0.6.10 可以build成功但在版子上無法使用
不好意思打擾了^^
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
贡献值: 0 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
9楼  发表于: 2012-10-02 22:40

 Re:回 7楼(kazaya) 的帖子

引用第8楼cool.ghost于2012-09-27 18:47发表的 回 7楼(kazaya) 的帖子 :
請問樓主妳使用的hostapd版本是?
我目前hostapd0.7.3 及 hostapd0.6.8 無法build成功
hostapd0.6.10 可以build成功但在版子上無法使用
不好意思打擾了^^


不好意思,我的hospapd 是綁定 ar6003 driver的,我自己移植的hostapd是沒有辦法work,
您可能要看hostapd自己移植的,需要開啟那些module及library

最近把android-4.x 附的wpa_supplicant_8 中的hostapd改成arm-linux,還沒有空試,不然你可以試試這個版本是否可以正常?.....
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go