Ubuntu下共享Wifi给安卓

一、我的测试环境:

        1)计算机:Acer4750G

        2)系统:Acer4750G

        3)无线网卡:Qualcomm Atheros AR9287 Wireless Network Adapter

        4)驱动程序:ath9k , version: 3.11.0-17-generic

二、检查硬件是否满足要求:

        参看荒野无灯的博文:http://ihacklog.com/post/use-hostapd-to-setup-wireless-access-point-under-linux.html。这里要检查自己所用的无线网卡是否支持AP模式。 我的是PCI无线网卡:

$ lspci
03:00.0 Network controller: Qualcomm Atheros AR9287 Wireless Network Adapter (PCI-Express) (rev 01)
然后查看我的网卡的详细信息:
$ ifconfig -a
wlan0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  

$ ethtool -i wlan0
driver: ath9k
version: 3.11.0-17-generic
firmware-version: N/A
bus-info: 0000:03:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no
        Google一下有关于我的无线网卡的信息以及驱动描述,越看越糊涂。不过荒野无灯的那篇博文已经写得很清楚了。好在使用iw 查看“support interface mode”中有AP这一项也就安心了,确定可以用hostapd。
$ iw list
	Supported interface modes:
		 * IBSS
		 * managed
		 * AP
		 * AP/VLAN
		 * WDS
		 * monitor
		 * mesh point
		 * P2P-client
		 * P2P-GO
	software interface modes (can always be added):
		 * AP/VLAN
		 * monitor

三、安装软件与配置

        首先必装两个软件:hostapd和dnsmasq。只靠这两个软件,自己写配置文件就可以建个wifi热点。但是过程有点复杂。自己尝试了一下,由于网络知识是在不足,以失败告终。也有人推荐用 wifi-hostapd-ap 这款软件进行配置。如果想要自己手动配置可参看这里http://blog.csdn.net/q1302182594/article/details/8689603,学海有涯的博文。我最终还是采用了更傻瓜式的方式----ap-hotspot这个软件。要注意的是ap-hotspot依赖于hostapd和dnsmasq,如果没有安装这两个软件,在安装ap-hotspot时,apt-get会自动解决依赖关系,将这两个软件装上。同时启用ap-hotspot会对这两个软件进行配置,由于之前曾尝试自己写这两个软件的配置文件,尽管我把所有的改动都还原了,在使用ap-hotspot时还是开启失败。无奈之下将这三个软件都用purge卸载了,删除自己创建的配置文件,再重启,安装。这样就可以了。
安装过程
$ sudo apt-get install hostapd dnsmasq
$ sudo add-apt-repository ppa:nilarimogard/webupd8
$ sudo apt-get update
$ sudo apt-get install ap-hotspot
        安装以及如何使用ap-hotspot可以参看 http://www.webupd8.org/2013/06/how-to-set-up-wireless-hotspot-access.html。也可去launchpad.net上查看。
配置过程:
$ sudo ap-hotspot 
Usage:	ap-hotspot [argument]
	start          start wireless hotspot
	stop           stop wireless hotspot
	restart        restart wireless hotspot
	configure      configure hotspot
	debug          start with detailed messages
        首先通过以上的命令可以知道如何使用ap-hotspot。初次使用运行如下命令:
$ sudo ap-hotspot start
       会出现英文提示,大概的意思就是,首先它会检测目前使用哪个网卡连入Internet,然后检测可使用的无线网卡,然后输入热点的名字(ssid),如果直接回车会有一个默认的ssid。接着就是设置密码,同样的,如果直接回车会有一个默认的密码。如果不是第一次使用,可以用configure选项对配置进行更改。
启动成功之后,通知会弹出消息说无线已开启,但奇怪的是在图形界面下的internet连接管理中无法看到。好了,用Android手机搜索一下,成功连入,可以上网。

四、高级配置

       ap-hotspot优点就是简单易用,但是想要更多的设置和更好的设置还得自己去编辑一下配置文件。ap-hotspot默认是指的无线通道是1,我这里wifi热点比较多,干扰较大。所以想自己改一下Channel。首先要了解一下关于无线通道的知识,参看这里:无线wifi路由器的信道选择:http://blog.solrex.org/articles/wifi-channel-choosing.html。然后用软件扫描一下周围的wifi信道情况,我直接在Android上安装一个叫wifi分析仪的应用,直接根据它的信道评级就知道选哪个通道好。该App的Google Play上的链接在这里:https://play.google.com/store/apps/details?id=com.farproc.wifi.analyzer。

        接着找到hostapd的配置文件:/etc/hostapd-hotspot.conf,对其进行编辑。不仅可以更改通道,还可以在这里更改ssid、wifi密码等。详细的关于如何配置hostapd的资料参看此处:http://wireless.kernel.org/en/users/Documentation/hostapd。也可看Jieen的这篇http://blog.csdn.net/lqrensn/article/details/8154558。

        同样的,dnsmasq的配置文件也可以更改,路径在此,/etc/dnsmasq.conf。不过对于一般的使用没必要去更改这两个文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Atheros AR8131 网卡驱动下载地址:(包括windows 驱动 和 Linux驱动) http://partner.atheros.com/Drivers.aspx Atheros AR9285无线网卡驱动,由开源项目MadWifi支持 在sourceforge搜索MadWifi可以找到: http://sourceforge.net/projects/madwifi/ 最新的Atheros无线网卡驱动主页: http://madwifi-project.org/ 对于新版本linux kernel 2.6.25之后(现在都是这个以上的内核),要用新的current版本。 http://snapshots.madwifi-project.org/madwifi-0.9.4-current.tar.gz In case you use kernel 2.6.25 or newer, you need to get this snapshot of the madwifi-0.9.4 branch instead of the v0.9.4 release! That snapshot is basically v0.9.4 plus compilation fixes for recent kernels. Atheros无线网卡驱动介绍: http://wireless.kernel.org/en/users/Drivers/Atheros AR9285无线网卡驱动 http://wireless.kernel.org/en/users/Drivers/ath9k Any distribution shipping a kernel >= 2.6.27 will have ath9k present but the ath9k driver on 2.6.32 is the oldest one recommended, anything older than that is completely unsupported. Below is a list of the minimal distribution requirements to either use ath9k from 2.6.27 or from compat-wireless, which lets you install newer drivers on older kernels. Ubuntu Intrepid (8.10) Fedora Core 10 openSUSE 11.1 Mandriva Linux 2009.0 (formally known as Mandrake Linux) ARCH Linux Gentoo Linux Red Flag Linux 7.0 (based on Fedora 10) RHEL5 2.6.18 kernel being tested When it went in ath9k was announced to have been merged into Linux-2.6.27-rc3 by Linus on Tue, 12 Aug 2008 19:33:16 -0700 (PDT), and consisted of 58.8% of the entire rc3 patch. Early distributions which picked it up OpenWrt became the first distribution to pick up ath9k and contribute to it.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值