Difference between revisions of "Software access point"

From ArchWiki
Jump to: navigation, search
m (Wifi Link Layer: Fix daemon style)
(28 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{Out of date}}
+
[[ru:Software Access Point]]
[[Category:Communication and network (English)]]
+
[[Category:Wireless Networking]]
[[Category:HOWTOs (English)]]
+
  
A software access point is used when you want your computer to act as an access point for the local wireless network. It saves you the trouble of getting a separate wireless router.
+
A software access point is used when you want your computer to act as an wifi access point for the local wireless network. It saves you the trouble of getting a separate wireless router.
  
=Things you need=
+
== Requirements ==
 +
* A nl80211 compatible wireless device (e.g. ath9k)
 +
== Overview ==
  
You will need: <ul><li>prism2/2.5/3 pure pci wireless card or nl80211 compatible cards (e.g. ath9k)
+
Setting up an access point comprises two main parts:
<li>wireless-tools, hostapd and bridge-utils from pacman</ul>
+
* Setting up the '''wifi link layer''', so that wireless clients can associate to your computer's "software access point" and send/receive IP packets from/to your computer; this is what the hostapd package will do for you
 +
* Setting up the '''network configuration''' on you computer, so that your computer will properly relay IP packets from/to its own Internet connection from/to wireless clients.
  
=Steps to implement=
+
== Wifi Link Layer ==
  
the config file of hostapd /etc/hostapd/hostapd.conf will help you to put your wireless device into master mode and willing to accept connection from other computers with encrypted password.
+
The actual Wifi link is established via the {{Pkg|hostapd}} package. That package is compatible with WPA2.
  
here is an example from http://www.su-root.eu/computing/turn-your-linux-computer-in-a-wireless-access-point-using-hostapd
+
[[pacman|Install]] the {{Pkg|hostapd}} package from the [[Official Repositories|official repositories]].
  
<BR>
+
Create the config file of hostapd {{ic|/etc/hostapd/hostapd.conf}}.
interface=wlan0<BR>
+
bridge=br0<BR>
+
driver=nl80211<BR>
+
logger_stdout=-1<BR>
+
logger_stdout_level=2<BR>
+
ssid=test<BR>
+
hw_mode=g<BR>
+
auth_algs=3<BR>
+
max_num_sta=5<BR>
+
wpa=2<BR>
+
wpa_passphrase=tryyourbest<BR>
+
wpa_key_mgmt=WPA-PSK<BR>
+
wpa_pairwise=TKIP CCMP<BR>
+
rsn_pairwise=CCMP<BR>
+
+
<BR>
+
before hostapd does its job, eth0, wlan0 and br0 must be up and do not have any address. we can put the following lines in /etc/rc.conf
+
  
<BR>
+
Adjust the options as necessary. Especially, change the {{ic|ssid}} and the {{ic|wpa_passphrase}}.
eth0="eth0 up"<BR>
+
{{hc|/etc/hostapd/hostapd.conf|<nowiki>
wlan0="wlan0 up"<BR>
+
ssid=YourWifiName
br0="br0 192.168.0.2 netmask 255.255.255.0 up"<BR>
+
wpa_passphrase=Somepassphrase
INTERFACES=(lo eth0 wlan0 br0)<BR>
+
interface=wlan0
 +
bridge=br0
 +
auth_algs=3
 +
channel=7
 +
driver=nl80211
 +
hw_mode=g
 +
logger_stdout=-1
 +
logger_stdout_level=2
 +
max_num_sta=5
 +
rsn_pairwise=CCMP
 +
wpa=2
 +
wpa_key_mgmt=WPA-PSK
 +
wpa_pairwise=TKIP CCMP
 +
</nowiki>}}
  
<BR>
+
For automatically starting hostapd, [[Daemon|enable]] the {{ic|hostapd.service}}.
in the /etc/conf.d/bridge file, uncomment the lines (change eth1 to wlan0)
+
  
<BR>
+
== Network configuration ==
bridge_br0="eth0 wlan0"<BR>
+
There are two basic ways for implementing this:
BRIDGE_INTERFACES=(br0)<BR>
+
# '''bridge''': create a network ''bridge'' on your computer (wireless clients will appear to access the same network interface and the same subnet that's used by your computer)
 +
# '''NAT''': with IP forwarding/masquerading and DHCP service (wireless clients will use a dedicated subnet, data from/to that subnet is NAT-ted -- similar to a normal WiFi router that's connected to your DSL or cable modem)
  
<BR>
+
The bridge approach is more simple, but it requires that any service that's needed by your wireless clients (like, DHCP) is available on your computers external interface. That means it will not work if you have a dialup connection (e.g., via PPPoE or a 3G modem) or if you're using a cable modem that will supply exactly one IP address to you via DHCP.
we are ready to go, just reboot the machine and use another computer to see if you can find the "test" wireless connection.
+
<BR>
+
  
*untested* if your computer stops at the sign of "waiting for IP address" etc, that may be it can not find a dhcp server. so you need to set up one.
+
The NAT aproach is more versatile, as it clearly separates wifi clients from your computer and it's completely transparent to the outside world. It will work with any kind of network connection, and (if needed) you can introduce traffic policies using the usual iptables approach.
  
<BR>
+
Of course, is possible to '''combine both things'''. For that, studying both articles would be necessary. (Example: Like having a bridge that contains both an ethernet device and the wireless device with an static ip, offering DHCP and setting NAT configured to relay the traffic to an additional network device - that can be ppp or eth)
 +
=== Bridge Setup ===
 +
See [[Bridge with netcfg]] for details.
  
*UPDATE* The hostap-driver in pacman works, too. Thanks Xentac!
+
Note that, you '''should not''' add the wireless device (like {{ic|wlan0}}) to the bridge; hostapd will add it on its own.
  
*ANOTHER UPDATE* Hostap-driver is in the 2.6.15 kernel.  Also, DCHP requests are passed to the wired connection through wireless, so dhcpd is not needed for this.
+
=== NAT Setup ===
  
* Update (2010-12-17) : updated packages requirement
+
See [[Internet Share]] for details.
  
* Update (2010-12-22) : updated config files for rc.conf, hostapd.conf and bridge.
+
On that article, the device connected to the lan is {{ic|net0}}. That device would be in this case your wireless device (which probably is {{ic|wlan0}}).
 +
 
 +
== Troubleshooting ==
 +
===WLAN is very slow===
 +
This could be caused by low entropy. Consider installing [[haveged]].
 +
 
 +
== See also ==
 +
 
 +
* [http://wireless.kernel.org/RTFM-AP hostapd Linux documentation page]
 +
* [[Router]]
 +
* [http://nims11.wordpress.com/2012/04/27/hostapd-the-linux-way-to-create-virtual-wifi-access-point/ Hostapd : The Linux Way to create Virtual Wifi Access Point]

Revision as of 00:33, 22 December 2012


A software access point is used when you want your computer to act as an wifi access point for the local wireless network. It saves you the trouble of getting a separate wireless router.

Requirements

  • A nl80211 compatible wireless device (e.g. ath9k)

Overview

Setting up an access point comprises two main parts:

  • Setting up the wifi link layer, so that wireless clients can associate to your computer's "software access point" and send/receive IP packets from/to your computer; this is what the hostapd package will do for you
  • Setting up the network configuration on you computer, so that your computer will properly relay IP packets from/to its own Internet connection from/to wireless clients.

Wifi Link Layer

The actual Wifi link is established via the hostapd package. That package is compatible with WPA2.

Install the hostapd package from the official repositories.

Create the config file of hostapd /etc/hostapd/hostapd.conf.

Adjust the options as necessary. Especially, change the ssid and the wpa_passphrase.

/etc/hostapd/hostapd.conf
ssid=YourWifiName
wpa_passphrase=Somepassphrase
interface=wlan0
bridge=br0
auth_algs=3
channel=7
driver=nl80211
hw_mode=g
logger_stdout=-1
logger_stdout_level=2
max_num_sta=5
rsn_pairwise=CCMP
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP

For automatically starting hostapd, enable the hostapd.service.

Network configuration

There are two basic ways for implementing this:

  1. bridge: create a network bridge on your computer (wireless clients will appear to access the same network interface and the same subnet that's used by your computer)
  2. NAT: with IP forwarding/masquerading and DHCP service (wireless clients will use a dedicated subnet, data from/to that subnet is NAT-ted -- similar to a normal WiFi router that's connected to your DSL or cable modem)

The bridge approach is more simple, but it requires that any service that's needed by your wireless clients (like, DHCP) is available on your computers external interface. That means it will not work if you have a dialup connection (e.g., via PPPoE or a 3G modem) or if you're using a cable modem that will supply exactly one IP address to you via DHCP.

The NAT aproach is more versatile, as it clearly separates wifi clients from your computer and it's completely transparent to the outside world. It will work with any kind of network connection, and (if needed) you can introduce traffic policies using the usual iptables approach.

Of course, is possible to combine both things. For that, studying both articles would be necessary. (Example: Like having a bridge that contains both an ethernet device and the wireless device with an static ip, offering DHCP and setting NAT configured to relay the traffic to an additional network device - that can be ppp or eth)

Bridge Setup

See Bridge with netcfg for details.

Note that, you should not add the wireless device (like wlan0) to the bridge; hostapd will add it on its own.

NAT Setup

See Internet Share for details.

On that article, the device connected to the lan is net0. That device would be in this case your wireless device (which probably is wlan0).

Troubleshooting

WLAN is very slow

This could be caused by low entropy. Consider installing haveged.

See also