zoukankan      html  css  js  c++  java
  • Android教程:wifi热点问题

    http://www.linuxidc.com/Linux/2012-05/60718.htm

    现在很多移动设备都提供wifi hostpot功能,使用方便,也省下了原来无线路由器的成本。wifi和wifi hotspot功能是互斥的,即在同一时间里,你只能用其中一种功能。在Android较新版本(2.2之后)中已经实现,本文实现在命令行模式下完成wifi hotspot功能的启动,并简单介绍其中涉及到的相关工具。

     
    0、确保eth0可以访问网络
     
    1、修改framework/base/core/res/res/values/config.xml
    1. <!-- List of regexpressions describing the interface (if any) that represent tetherable 
      Wifi interfaces. If the device doesn't want to support tethering over Wifi this 
      should be empty. An example would be "softap.*" --> 
      <string-array translatable="false" name="config_tether_wifi_regexs"> 
      <item>"wlap0"</item> 
      </string-array> 
      <!-- Dhcp range (min, max) to use for tethering purposes --> 
      <string-array translatable="false" name="config_tether_dhcp_range"> 
      </string-array> 
      <!-- Regex array of allowable upstream ifaces for tethering - for example if you want 
      tethering on a new interface called "foo2" add <item>"foo\d"</item> to the array --> 
      <string-array translatable="false" name="config_tether_upstream_regexs"> 
      <item>"eth0"</item> 
      <item>"ppp0"</item> 
      <item>"wlan0"</item> 
      </string-array> 
     
    2、加载wifi驱动(我这使用的是atheros)
    insmod /system/wifi/ar6000.ko ifname=wlap0
    若成功的话,则第3、4、5步自动执行。
     
    3、设置IP地址
    /system/bin/ifconfig wlap0 192.168.100.1 netmask 255.255.255.0
     
    4、iptables设置
    echo 1 > /proc/sys/net/ipv4/ip_forward
    /system/bin/iptables -A FORWARD -i wlap0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT 
    /system/bin/iptables -A FORWARD -i wlap0 -o eth0 -j ACCEPT 
    /system/bin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
     
    5、dnsmasq设置
    /system/bin/dnsmasq --no-daemon --no-resolv --no-poll --dhcp-range=192.168.100.100,192.168.100.200,100h
    当然也可以把相关配置写成文件再执行dnsmasq --conf-file=/*/dnsmasq.conf
     
    6、启动hostapd
    /system/bin/hostapd_wps -dd /data/misc/wifi/hostapd.conf
     
    出现的问题
    1、执行上述命令后,客户端去连接的时候获取不到IP地址,重新启动hostapd就OK?
    可以采用如下方法修正
    /sytem/bin/ndc softap set eth0 wlap0 djstava open
    /system/bin/ndc softap start
    /system/bin/ndc/softap startap
  • 相关阅读:
    软件工程第二次结对作业
    实验 6:OpenDaylight 实验——OpenDaylight 及 Postman 实现流表下发
    实验 5:OpenFlow 协议分析和 OpenDaylight 安装
    实验 4:Open vSwitch 实验——Mininet 中使用 OVS 命令
    软件工程第一次作业
    实验 3:Mininet实验——测量路径的损耗率
    软件工程个人总结
    2020 SDN第七次上机实验
    软件工程实践第4次作业-结对编程之实验室程序实现
    2020 SDN第六次上机实验
  • 原文地址:https://www.cnblogs.com/leaven/p/3520440.html
Copyright © 2011-2022 走看看