以fedora14为例安装hostapd,将Linux笔记本部署为一台高性能无限路由器,顺便说一句,我的fedora14安装在一台10英寸的上网本上。
以fedora14为例安装hostapd,将Linux笔记本部署为一台高性能无限路由器,顺便说一句,我的fedora14安装在一台10英寸的上网本上。
有无线网卡、有线网卡的笔记本一台
安装Linux操作系统,我使用的是fedora14
检查确认笔记本网卡支持master模式
首先要安装一个iw:yum install iw -y
然后执行命令:iw list
在命令执行结果中如果看到了下面的内容,就说明这张网卡是支持用于ap做路由的
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* mesh point
安装hostapd
通过 yum install hostapd -y 安装,如果是其它红帽系列的可以安装epel的源,或者找一下hostapd的rpm,下载对应自己发行版的进行安装。其它Linux可以通过源码安装。
修改配置文件
# vim /etc/hostapd/hostapd.conf
修改成如下状态
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_passphrase=ap_password
driver=nl80211
interface=wlan0
hw_mode=g
channel=9
ssid=ap_name
注意修改涉及到的ssid和密码
安装和配置dhcp
# yum install dhcpd -y
# vim /etc/dhcp/dhcpd.conf
将此文件改成如下:
option domain-name-servers 211.161.45.222,10.141.146.10;
default-lease-time 3600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.7.0 netmask 255.255.255.0 {
range 192.168.7.77 192.168.7.99;
option broadcast-address 192.168.7.255;
option routers 192.168.7.7;
}
注意将第一行的nameserver添加成你isp提供的dns,这样解析的速度会快一些,不知道的话就改成谷歌的8.8.8.8好了。subnet 里面设置的是分配给连接无线路由的设备的ip段,可以根据自己需求进行调整,这里给了192.168.7.77-99
需要注意的是,option routers要写成这台机器的wlan0的ip,这个是手动设置的
# ifconfig wlan0 192.168.7.7
配置SNAT
Linux可以很方便的通过iptables配置SNAT服务器,命令如下:
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -s 192.168.4.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.4.0/24 -j ACCEPT
其中第一条表示将通过本机的转发数据包从eth0(外网)这个网卡发出去,另外两条表示只转发192.168.4.0/24这个网段过来的数据包,这个网段正好是wlan0其它设备连上本机以后分配的网段。
还需要在打开内核的ip转发功能:
# vim /etc/sysctl.conf
添加或修改这样一段:
net.ipv4.conf.default.rp_filter = 1
然后执行命令
# sysctl -p
启动相关服务
/etc/init.d/dhcpd start
/etc/init.d/hostapd start
http://blog.chinaunix.net/uid-26547792-id-3152196.html
linux无线网卡 2012-03-28 18:14:55
分类: LINUX
|
注:为什么不随便将它解压到一个位置并保留缺省的拥有者?
原因是上面的做法会把驱动模块的源代码保留在系统上 —— 在你放置它们的位置 —— 好让你可以随时按需要创建驱动程序(譬如:你将内核升了级 —— 因为驱动模块永远根据某个内核来编译),还有,就是你可以用无特权的用户来编译! |
http://blog.bokhorst.biz/3395/computers-and-internet/asrock-ion-330ht-as-wireless-access-point/
If you know how to do it, most things are simple. Figuring out how to make my Asrock ION 330HT-BD (running Ubuntu Karmic) a wireless access point took me a couple of hours. For my own reference and maybe to save you some time I wrote down all steps.
auto eth0 iface eth0 inet dhcp auto wlan0 iface wlan0 inet static address 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255
博主的淘宝店铺:http://ideatrust.taobao.com/
或者大家可以搜索店铺:黑苹果软硬件解决方案旗舰店
黑苹果爱好者为了是自己的黑苹果系统在Mac os X下能够完美wifi无线上网,大家在PCbeta Forum里有对Atheros系列多种型号进行讨论的帖子,然而到底哪种型号是真正完美的最佳的可用的方案,大家仍停留在经验讨论中,没有一个帖子能够给出最好且让大家信服的方案来。另外,仍有大部分的朋友仍在用版本号来推算Atheros系列网卡性能的高低,这基本上可以算是一种很错误的理念。下面我将为大家带来Atheros可支持Mac os X各种型号的比较分析。
现在论坛里讨论的Atheros系列网卡基本的版本号9280往后的,而且经笔者翻阅资料发现,可支持且性能稍好且能够支持Mac os X的网卡也正是大家讨论的这些型号(见表1)。
表1 Atheros主要支持MacosX网卡技术参数[1]
Chipset |
Chips used |
Interface |
PHY modes |
MOMI status[3] |
AR9280(Merlin) | PCIe |
abgn |
2×2:2 |
|
AR9281(Merlin) | PCIe |
bgn |
1×2:2 |
|
AR9283(Merlin) | PCIe |
bgn |
2×2:2 |
|
AR9285 (Kite) | PCIe |
bgn |
1×1:1 |
|
AR9287 (Kite) | PCIe |
bgn |
2×2:2 |
|
AR9002WB-1NGCD | AR9285 (Kite) + AR3011(bluetooth) |
PCIe |
bgn |
1×1:1 |
AR9002WB-2NG | AR9287 (Kiwi) + AR3011 (bluetooth) |
PCIe |
bgn |
2×2:2 |
AR93 AR928780 | PCIe |
abgn |
3×3:3 |
通过分析此表不难发现AR9280、AR9002WB-2NG、AR9380最先胜出的,这三个中间AR9380新能最优,频段同时支持abgn,支持3-stream 11n MIMO,最高支持450mbps;而AR9280是频段也同时支持abgn,支持2-stream 11n MIMO,最高支持300mbps;AR9002WB-2NG为蓝牙和无线二合一设计,无线频段仅支持bgn,少a频段支持,支持2-stream 11n MIMO,最高支持300mbps。
接下来呢,无线收发性能优胜从大到小依次为AR9287>AR9283> AR9281 >AR9285。其中所有的卡频段支持都bgn,AR9287、AR9283 MOMI属性是一样的,代表数据吞吐量一样,但是大家应该注意到AR9287的开发代号为Kiwi,而其余型号的代号皆为Merlin,(这里可以这样理解,开发时间上AR9287是晚于AR9283的,按照技术进步的优势,一定程度上可以认为AR9287性能高于AR9283,但是这并无从考证。因为一款产品的推出是跟市场需求有关而不是技术水平,诸如诺基亚是技术力量很强的企业,但售价为200元低性能功能手机一直占领着市场是同一道理。)在数据吞吐量MIMO属性,AR9287/ AR9283为收发数据最高均为300mbps,AR9281为收300mbps发150mbps,AR9285收发都为150mbps。
综上,在不考虑蓝牙的情况下,上述网卡性能从优到劣的次序为:AR9380>AR9280/AR9283/AR9287/> AR9281 >AR9285。
因此,如果你想实现wifi+bluetooth方案的话,建议你使用AR9002WB-1NGCD,虽然此方案wifi性能最低,但是由于bluetooth的存在,这是一个相对较好的wifi+bluetooth[2]。虽然还有高性能的AR9002WB-2NG方案,但是由于AR9287到目前为止驱动仍然非常困难,所以现在仍然不建议选此方案。
那么,上述网卡中到底哪个才能真正实现免驱呢,因为AR9280/ AR9281/AR9283这三个卡,虽然系能高低不一,但是他们具有相同的开发代号,应该会采用相同的芯片,所以理论上来讲,这三个卡都可以实现完美免驱。在笔者翻阅大家实际使用经验帖子,也再次证明了这三个卡应该都能完美免驱。
(这里大家需要注意的是,即使AR9280/ AR9281/AR9283采用的是同样的芯片,但也有可能无法驱动。原因有很多,总结有两点,一是你所使用的环境,软件的问题;而是卡本身的问题,这个三个卡使用了同样的芯片,为什么性能高低不一呢,这应该是厂商做的一硬件限制而使它们出现性能高低之分,以及应用的不同机器、使用地区等等,也是因为这些限制导致了采用的是同样的芯片,但也有可能无法驱动。)
所以大家在购买AR928x的网卡过程中,卖家实际在真实MAC环境下测试过才是真正好用,因为这里可以推荐购买的型号就有AR9280/ AR9281/AR9283,大家可以按照新能高低选择自己所需要的型号。这里再这三个性能做比较:AR9280/AR9283收发均为300mbps,AR9281为收300mbps,发150Mbps 。三者性能从能高到底AR9280=AR9283 >AR9281。(因为数据接收能够达到300mbps,即使发为150Mbps已经完全不影响到我们的正常使用)
最后说AR9380这些卡中性能最高,三天线设计,最高450mbps收发,而且为mac air 笔记本原生采用卡,但缺点是价格有点太高,基本在150元左右,但如果有这经济实力是推荐。
注:AR9380/AR9280都有原生的去全高和半高的。之前我在论坛看到大家都以为AR9380/AR9280只有全高卡,经笔者翻阅资料发现事实不是这样的,全高AR9380/AR9280多为Atheros官方和苹果oem卡,半高的多为采用同样芯片的oem卡(这些oem卡应用很广,笔者发现光AR9280芯片的半高卡,在ACER、HP、Dell、Lenovo等大的电脑厂商的笔记本上都存在过,因此你的机器如果是半高卡,这些采用AR9280芯片的OEM卡是你最好的选择)。
::关于MOMI status的解读见文后的英文资料[3],这里我就不做翻译了,大家可以自行参看。::
笔者相关文章推荐:
PC黑苹果系统构建无线模块最佳解决方案,http://www.ideatrust.net/2013/03/13/the-pc-black-apple-building-wireless-module-solutions
黑苹果系统系统下硬件驱动通用解决方案,
http://www.ideatrust.net/2013/03/12/black-apple-system-system-hardware-drivers-universal-solution
笔记本刷白名单评测建议方案,http://www.ideatrust.net/2013/03/18/notebook-to-whitewashed-list-evaluation-proposal
参考文献
[1] Atheros,http://www.wikidevi.com/wiki/Atheros
[1] 购买AR5B195或者笔记本AR3011蓝牙MAC无法驱动的请看, http://bbs.pcbeta.com/viewthread-1153759-1-1.html
[3]见参考资料
参考资料
Proprietary MIMO technology can be found in some Wireless-G devices. Both the access point and the adapter must support the same technology as MIMO is not standardized in 802.11g. Often, two radios are used to double the bandwidth to 108Mbps.
MIMO is a part of the 802.11n specification. Different notations may be used to describe the MIMO capabilities of a given device.
TxR:S
T: Number of transmit radio chains
R: Number of receive radio chains
S: Number of spatial data streams
1×1:1 – 150Mbps transmitting and receiving
1×2:2 – 150Mbps transmitting, 300Mbps receiving
2×2:2 – 300Mbps transmitting and receiving
2×3:2 – 300Mbps transmitting and receiving
3×3:2 – 300Mbps transmitting and receiving
3×3:3 – 450Mbps transmitting and receiving
更新:
20130329 部分表述和更详尽的性能比较更新;可用于黑苹果无线网卡推荐推荐范围更新;
http://linuxwireless.org/en/users/Drivers/ath9k/
Go back –> Atheros Linux wireless drivers
ath9k is a completely FOSS wireless driver for all Atheros IEEE 802.11n PCI/PCI-Express and AHB WLAN based chipsets.
Contents
You should subscribe to this page so you can get e-mail updates on changes and news for ath9k automatically. You'll get an e-mail as soon as this page gets updated.
Our mailing list for this driver is:
https://lists.ath9k.org/mailman/listinfo/ath9k-devel
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.
RHEL5 using 2.6.32 ath9k backported to 2.6.18
If you want to get the latest ath9k driver you have several options:
compat-wireless stable releases of ath9k - ath9k as it is in newer stable kernels releases backported for older kernels
compat-wireless daily linux-next.git snapshots of ath9k - ath9k as it is present in the development tree for 802.11 backported for older kernels
To read more about the wireless-testing and development on ath9k you can read our our git-guide and the development process, please be also sure to read the bug fix propagation, our documentation on reporting bugs, and how we handle adding additional critical fix patches to ath9k.
It should be noted that some Linux distributions already use the stable compat-wireless releases as packages in their Linux distribution. Examples are ChromeOS, Ubuntu, Gentoo and Openwrt. Openwrt in particular uses compat-wireless snapshots based on wireless-testing, and the releases are updated regularly after some evaluation by OpenWrt's developers and the community. If you are using the any of the compat-wireless releases, you can enable only to compile and install ath9k by issuing the following commands.
Please note that for AP mode of operation the Minstrel rate control algorithm performs much better than the Atheros rate control algorithm and a separate driver-select option is provided below to enable you to use Minstrel for AP.
# If you are using ath9k as STA device: ./scripts/driver-select ath9k # If you are using ath9k as an AP: ./scripts/driver-select ath9k_ap
make sudo make install }}}
To enable ath9k, you must first enable mac80211 through make menuconfig when compiling your kernel. If you do not know what this means then please learn to compile kernels or rely on your Linux distribution's kernel. Below are the options you need to enable ath9k through make menuconfig.
Networking ---> Wireless --->Improved wireless configuration API Generic IEEE 802.11 Networking Stack (mac80211)
You can then enable ath9k in the kernel configuration under
Device Drivers ---> [*] Network device support ---> Wireless LAN --->Atheros 802.11n wireless cards support
ath9k supports 2-wire and 3-wire Bluetooth coexistence, for details see the ath9k btcoex page.
SB = single-band 2.4GHz DB = dual-band 2.4GHz or 5GHz
Legacy:
AR2427 (>= 2.6.32.16, no 802.11n hardware support, its bonded out) 1x1 SB PCIe
AR5008:
AR5418+AR5133 (>= 2.6.27) AR5418 = DB 11n PCIe, AR5133 = 3x3 DB 11n
AR5416+AR5133 (>= 2.6.27) AR5416 = DB 11n PCI
AR5416+AR2133 (>= 2.6.27) AR2133 = 3x3 SB 11n
AR9001:
AR9160 (>= 2.6.27) DB 11n
AR9102 (>= 2.6.30, AHB) 2x2 SB 11n
AR9103 (>= 2.6.30, AHB) 3x3 SB 11n
AR9002:
AR9220 (>= 2.6.27, an AR9280 card over PCI) 2x2 DB 11n PCI
AR9280 (>= 2.6.27) 2x2 DB 11n PCIe
AR9281 (>= 2.6.27) 2x2 SB 11n PCIe
AR9285 (>= 2.6.29) 1x1 SB 11n PCIe
AR9287 (>= 2.6.32) 2x2 SB 11n PCIe
AR9003:
AR9380 (>= 2.6.36) 3x3 DB 11n PCIe
AR9382 (>= 2.6.36) 2x2 DB 11n PCIe
AR9004:
AR9485 (>= 2.6.39) 1x1 SB 11n PCIe
AR9462 (>= 3.2) 2x2 DB 11n PCIe
See the ath9k device list.
All of these modes of operation are supported and should work on all ath9k cards.
Station Mode
AP Mode
IBSS Mode
Monitor Mode
Mesh point with HT support, as well as RSN
WDS (as of >= 2.6.37)
P2P GO/CLIENT
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.
OpenWrt became the first distribution to pick up ath9k and contribute to it.
Below are stats on contributions between Qualcomm Atheros and the community on ath9k.
For more information please see:
ath9k module size and its dependents
power consumption - power consumption details with ath9k
ath9k btcoex support
ath9k bugs
ath9k TODO page
ath9k debugging
products with supported ath9k cards
ath9k_hw module - documentation about the ath9k_hw module
ath.ko module - used for shared code between Atheros devices
Solaris ath9k port - arn
I am having a Broadcom 4312 driver in my dell inspiron 1545 will your setup will work in my PC, Kindly give your suggestion.
To start with, you should do the first step of the how-to to discover your exact adapter type. After that you’ll have to check if your adapter is supported by the Linux wireless drivers and if so, select the correct driver (see build/install).
I have a slightly different setup:
A separate firewall/DHCP server.
A Zotac IONITX-P-E (just like John above).
I would like to use the Zotac (also) as a transparent access point (no masquerading).
Is it possible?
What should I change?
You could try to relay DCHP requests, but I’ve no idea about how to do the routing without a separate sub-net.
In fact, I have a similar setup. DSL router + firewall + DHCP server and an internal (wired) 192.168.1.x network. My first approach was to create one big internal network (wired and wireless in the same network, sharing the same DHCP server, behind the same firewall).
I didn’t get this to work and went for 2 separate networks. Perhaps it will work with DHCP relay, my old AP, a Linksys WAP54G does basically the same. I think it’s better to create an extra network, eg. 192.168.0.x for wireless. You can easily achieve this with dnsmasq.
I’m not sure how this situation should work on one big network: a wired device, let’s say 192.168.1.2 wants to connect to a wireless device, let’s say 192.168.1.4. How does it “know” it has to send it’s request to 192.168.1.3, the wired interface of the AP?
Hi Marcel,
Thanks, this gave me a nice jump start. I have a Zotac IONITX-P-E, with the same wireless card.
To enable 802.11n, in hostapd.conf you should also set:
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40-][HT40+][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40]
For other cards, use ‘iw list’ to check your cards HT capabilities (ht_capab).
THanks Marcel,
This has got my Asrock running nicely on Ubuntu 9.10 Kernel 2.6.31-20.
The only thing I had to do differently was that I had to use iptables rather the route to configure my wireless lan to the internet ie.
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
This nicely redirects all traffic from the wireless network through to the wired network.
Hi Marcel,
Nice blog! I have done basically the same thing and found this posting very informative. I’m using a Dell Mini 9 running Ubuntu 9.10. It is acting as a NAT router/firewall (UFW with NAT rules), DHCP server (dhcp3-server) and AP (hostapd with Atheros AR928x based card). My question is related to the performance of your AP. While my AP configuration seems to work for the most part, my clients drop their connection regularly. Based on syslog this seems to be due to some kind of deauthentication/authentication issue. The only way to get the clients to reconnect is to manually restart hostapd.
I’m curious to know if you have seen this behavior on your AP as well. If you have, how have you resolved the issue?
Thanks!
Actually I haven’t used the access point very much, because it appeared to be unstable when I use NFS (the PC/Ubuntu stops responding completely; this doesn’t happen when I use the wired connection) and the wireless range was limited (the Asrock has no external antenna).
I didn’t see your deauthentication/authentication problem. Maybe it has to do with encryption. I used WPA2 only.