[問題] 有高手能解決手機熱點腳本的相關問題嗎?

看板AndroidDev作者 (酷酷的河馬)時間12年前 (2013/12/05 00:26), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
小弟的手機是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)

12/09 22:38, , 1F
之前在版子上有做過類似的東西 將3G網路 分給WIFI模組用
12/09 22:38, 1F

12/09 22:40, , 2F
時代有點久遠 印象中還要多一個bridge 才能將牠們結合
12/09 22:40, 2F
文章代碼(AID): #1IdrUm8a (AndroidDev)