# gettng a working wireless access point

## javeree

I have a PC with a prism54 based WLAN. until today, I was able to create a WEP based access point using the prism54 module as follows:

emerge -atv wireless-tools

 *Quote:*   

> lsmod | grep prism
> 
> prism54                40316  0
> 
> firmware_class          4444  3 nouveau,speedtch,prism54

 

 *Quote:*   

> cat /etc/conf.d/net.wlan | egrep -v "^$" | egrep -v '^#'
> 
> essid_wlan="MySSID"
> 
> mode_wlan="Master"
> ...

 

 *Quote:*   

> /etc/init.d/net.wlan start

 

I now learned that prism54 is deprecated and should be used with p54pci instead. I also want to upgrade this access point to use WPA instead.

So I compiles p54pci, and can load it (after emerge =prism54-firmware-2.13)

 *Quote:*   

> modprobe p54pci
> 
> cfg80211: Calling CRDA to update world regulatory domain
> 
> p54pci 0000:02:00.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
> ...

 

However, this does not give me access point functionality. I understand that the drivers are fundamentaly different, and that where prism54 has all the radio logic inside, the p54pci driver is a 'dumb' driver, that needs external user space applications to do the communications.

Most information I found however is about getting the PC to work as a client. I think this is what wpa_supplicant is for.

When I want to create a WPA access point, I believe wpa_supplicant is NOT needed, but hostap must be emerged instead.

After that however, I am quite lost:

Do I have to configure the AP now in some hostapd.conf, or in /etc/conf.d/net.wlan ? Do I have to start hostapd separately, or is it called somehow from net.wlan ? ...

In short can someone explain the basic steps needed to create --for gentoo-- a working access point with WPA ?

----------

## chiefbag

Firstly you need to check that the card you are using is capable of "master mode"  Some are not capable of this and would therefore not be suitable for use as an AP. 

If it's suitable then you at least need to setup a route between the wifi card and your LAN NIC. 

Have a look at the below links which should point you in the right direction. 

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=4

http://www.gentoo.org/doc/en/home-router-howto.xml

https://help.ubuntu.com/community/WifiDocs/WirelessAccessPoint

----------

## javeree

Thanks for replying, but I found very little needed info in the links you provided:

1. I know my card works in master mode: It does so with the prism54 driver in WEP

2. The first link talks about wpa_supplicant and wireless-tools, that according to my knowledge only serve to by a client of an access point. Not for being an access point for others.

3. The second link is about router setup, which also already works in my previous setup. 

4. The last link brought me something interesting, but it is ubuntu-specific

/etc/network/interfaces must contain 

 *Quote:*   

> #Wireless Setup:
> 
> auto ath0
> 
> iface ath0 inet manual
> ...

 

But how should this be translated to gentoos net.wlan and hostapd ?

----------

## chiefbag

Not sure about the specifics of the config, but as regards to where it lives in the Gentoo environ. it would defiantly be under /etc/conf.d/

Where the net file would be the default file when you call the init file

You can of course spec this easily by copying the net. init file and modify this there by bypassing the general net protocol which will use the list from /etc/udev/rules.d/70-persistent-rules.net as a list for .eth0,eth1 etc

----------

## cwr

I use an ath9k card, which works with hostapd (which is started by init like

any other daemon, btw.)  However, I don't know if your card can be

configured with hostapd; if it can, it should just be a question of adding

net.wlan0  and running hostapd.  I think that's basically all I did, but I

don't have the machine by me to check.

Will

----------

## javeree

@cwr

would you care to share your condf.d/net and hostapd.conf files (when you have access to your PC again) -- sensitive info removed of course  :Smile: 

----------

## javeree

I tried the following steps:

in /etc/conf.d/net:

 *Quote:*   

> modules_wlan=( "!iwconfig !wpa_supplicant" )
> 
> config_wlan=( "192.168.9.1 netmask 255.255.255.0" )
> 
> essid_wlan="test"
> ...

 

in /etc/hostapd/hostapd.conf

 *Quote:*   

> interface=wlan
> 
> driver=nl80211
> 
> logger_syslog=-1
> ...

 

I start /etc/init.d/net.wlan

 * Starting wlan

 *   Running preup function                                               [ ok ]

 *   Starting netplug on wlan ...                                         [ ok ]

 *     Backgrounding ...

ifconfig

wlan      Link encap:Ethernet  HWaddr 00:60:b3:94:1a:dd  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

/etc/init.d/hostapd start

 * WARNING:  hostapd is scheduled to start when net.wlan has started.

=> Nothing happens: 

net.wlan doesn't create and interface 192.168.9.1 and hostapd sits there waiting for it.

----------

## cwr

Does net.wlan0 (linked to net.lo) exist?

Will

----------

## cwr

Sorry for the delay; for some reason my local system has problems with

the gentoo forums, though not gentoo.org, and I can't stay on line

long enough to post a useful response.

Anyhow, the server setup I use is below; it uses WEP, since that's all the

client has, and I haven't gone into the routing setup, which is another

problem entirely.

Hostapd is started at the default run level; you should see some comments

in /var/log/messages to that effect.  I found that for some obscure reason

I couldn't reset the CRDA from the default, China, to GB unless the ath9k

module was loaded separately and not built in to the kernel, although the

wireless part worked fine as a built-in.

p54pci is supported by hostapd, according to the website, but CRDA isn't

yet supported, so I guess you'll be stuck with the default world regime.

p54pci also needs mac80211 in the kernel, but you've got that.  Otherwise,

looking at your recent post, things seem fine.

I'd check the wireless card out by running Kismet first, just to confirm

you've got a good hardware setup, and then set up for hostapd and reboot.

Will

# Relevant lines of /etc/conf.d/net

config_wlan0=("193.237.32.225 netmask 255.255.255.224 broadcast 193,237.32.255)

essid_wlan0="COINS"

mode_wlan0="ad-hoc" # hostapd flips mode to Master

channel_wlan0="10"

# Active lines of /etc/hostapd/hostapd.conf

interface=wlan0

driver=nl80211

logger_syslog=-1

logger_syslog_level=2

logger_stdout=-1

logger_stdout_level=4

dump_file=/tmp/hostapd.dump

ctrl_interface=/var/run/hostapd

ctrl_interface_group=0

ssid=COINS

country_code=GB

hw_mode=g

channel=10

beacon_int=100

dtim_period=2

max_num_sta=255

rts_threshold=2347

fragm_threshold=2346

macaddr_acl=0

auth_algs=3

ignore_broadcast_ssid=0

wme_enabled=1

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

wep_default_key=0

wep_key0=e27eb43aa8

ap_max_inactivity=150

eap_message=hello

eapol_key_index_workaround=0

eap_server=0

own_ip_addr=127.0.0.1

passive_scan_mode=1

----------

## Paczesiowa

try disabling wme_enabled=1, my laptops couldn't connect to such ap, disabling it fixed the problem.

----------

## javeree

At least I already know there is no hardware or driver or hostapd setting error:

when I run 

 *Quote:*   

> /usr/sbin/hostapd -B /etc/hostapd/hostap.conf

 

then the network comes up (ifconfig shows the wlan interface to get an IP address), and another laptop sees the SSID, and can connect through it.

This is a huge leap forward. Until now, with the prism54 driver and wireless-tools, I was only able to run a WEP network.

So the question now only comes down to: why does the above work and /etc/init.d/hostapd not:

 *Quote:*   

> /etc/init.d/hostapd start
> 
> * WARNING: hostapd is scheduled to start when net.wlan has started.
> 
> 

 

=> Nothing happens:

net.wlan doesn't create and interface 192.168.9.1 and hostapd sits there waiting for it.

@cwr,

net.wlan (linked to net.lo) does exist.

----------

## cwr

I had a similar problem when setting up ethernet bridging, which in the end

was some sort of race condition in the init sequence.  I had to add the final

setup commands to /etc/conf.d/local.start, so that they ran when everything

had calmed down.

The other thing that might be worth checking is that dhcp, or something, is

setting an address on the wlan interface; hostapd may need that before it

will look at the device.

Will

----------

## javeree

You may or may not be right about a race condition. At the moment things seem to work ok, aftre I did a change:

modules_wlan=( "!iwconfig" "!wpa_supplicant" "!plug" )

In my original configuration file it was 

modules_wlan=( "!iwconfig !wpa_supplicant" )

It can be either the quoting that was wrong, and it still tried to use iwconfig or wpa_supplicant in parallel to hostapd, or maybe the presence of netplug prevented the interface from comming up.

...

Or I am at the moment just being lucky that the race ends in my favour. I guess I will have to wait and see for a while now

----------

