AndroidDev 板


LINE

小弟的手機是LG LTE 4G的手機,但跑CDMA2000的卡 所以手機內無線AP分享無法開啟 透過執行腳本的方法,可以順利的利用iwconfig跟腳本把手機3g分享變成wifi 但發現一個問題,只要執行過腳本,後來wifi就連不上了,必須重啟手機 以下是我的腳本 分享開始 --------------------------------------------------------------------- # tetherstart.sh # # Configure essid, channel, and transmit power # iwconfig wlan0 essid testapp iwconfig wlan0 channel 11 # iwconfig wlan0 txpower # iwconfig wlan0 commit # # Set IP for interface and bring it up # ifconfig wlan0 192.168.0.1 netmask 255.255.255.0 ifconfig wlan0 up # # Start hostapd to bring up the hotspot # hostapd -P /data/misc/wifi/hostapd.pid -e /data/misc/wifi/entropy.bin -B /data/misc/wifi/hostapd.conf # # Enable the routing fix # ip rule add to 192.168.0.0/24 lookup main priority 50 ip route flush cache # # Clean up iptables rules # iptables -N wireless-tether iptables -F wireless-tether iptables -t nat -F PREROUTING iptables -t nat -F POSTROUTING iptables -t nat -F # # Bring up NAT rules # iptables -A wireless-tether -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A wireless-tether -s 192.168.0.0/24 -j ACCEPT iptables -A wireless-tether -p 47 -j ACCEPT iptables -A wireless-tether -j DROP iptables -A FORWARD -m state --state INVALID -j DROP iptables -A FORWARD -j wireless-tether iptables -t nat -I POSTROUTING -s 192.168.0.0/24 -j MASQUERADE # # Turn on MSS Clamping # iptables -I FORWARD -s 192.168.0.0/24 -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu # # Enable IP forwarding # echo 1 > /proc/sys/net/ipv4/ip_forward # # Use dnsmasq for dhcp server # dnsmasq -i wlan0 --dhcp-authoritative --no-negcache --user=root --no-resolv --no-hosts --server=8.8.4.4 --server=8.8.8.8 --dhcp-range=192.168.0.100,192.168.0.110 --dhcp-leasefile=/data/misc/wifi/dnsmasq.leases --pid-file=/data/misc/wifi/dnsmasq.pid 停止分享 ---------------------------------------------------------------------------- # tetherstop.sh # # Disable forwarding and remove NAT rules. # echo 0 > /proc/sys/net/ipv4/ip_forward iptables -D FORWARD -j wireless-tether iptables -D FORWARD -m state --state INVALID -j DROP iptables -F wireless-tether iptables -X wireless-tether iptables -t nat -F PREROUTING iptables -t nat -F POSTROUTING iptables -t nat -F # # Kill all hotspot process killall dnsmasq killall hostapd # # Remove ip route rule to use main routing table for LAN network # ip rule del to 192.168.0.0/24 lookup main priority 50 ip route flush cache # # Remove old dnsmasq.leases and pid-files # rm /data/misc/wifi/dnsmasq.leases rm /data/misc/wifi/dnsmasq.pid rm /data/misc/wifi/hostapd.pid hostapd.conf 設定檔的內容如下 ------------------------------------------------------------------------ interface=wlan0 driver=nl80211 ctrl_interface=/data/misc/wifi/hostapd hw_mode=g beacon_int=100 dtim_period=2 #max_num_sta=5 rts_threshold=2347 fragm_threshold=2346 supported_rates=10 20 55 110 60 90 120 180 240 360 480 540 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wme_enabled=0 wme_ac_bk_cwmin=4 wme_ac_bk_cwmax=10 wme_ac_bk_aifs=7 wme_ac_bk_txop_limit=0 wme_ac_bk_acm=0 wme_ac_be_aifs=3 wme_ac_be_cwmin=4 wme_ac_be_cwmax=10 wme_ac_be_txop_limit=0 wme_ac_be_acm=0 wme_ac_vi_aifs=2 wme_ac_vi_cwmin=3 wme_ac_vi_cwmax=4 wme_ac_vi_txop_limit=94 wme_ac_vi_acm=0 wme_ac_vo_aifs=2 wme_ac_vo_cwmin=2 wme_ac_vo_cwmax=3 wme_ac_vo_txop_limit=47 wme_ac_vo_acm=0 #ap_max_inactivity=30 #wep_rekey_period=0 #eap_server=0 #own_ip_addr=127.0.0.1 #wpa_group_rekey=0 #wpa_gmk_rekey=0 #wpa_ptk_rekey=0 ssid=LG VS920 V9 WIFI channel=6 wpa_passphrase=diypda920 wpa_key_mgmt=WPA-PSK wpa=2 wpa_pairwise=CCMP rsn_pairwise=CCMP 雖然都可以正常的把手機的3g當成wifi分享出去,也可以結束分享 但結束後,wifi搜尋得到,也連接的上,可是不會分配取得ip 不知道是哪一環有問題,有高手能高抬貴手幫幫小弟嗎? --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.33.13.87 ※ 編輯: madjack 來自: 114.33.13.87 (12/05 00:27) ※ 編輯: madjack 來自: 114.33.13.87 (12/05 00:33)
1F:推 pushadon:之前在版子上有做過類似的東西 將3G網路 分給WIFI模組用 12/09 22:38
2F:→ pushadon:時代有點久遠 印象中還要多一個bridge 才能將牠們結合 12/09 22:40







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BabyMother站內搜尋

TOP