# hostapd access point loop

## mayhew

I am setting up a Realtek RTL8188cus usb wifi device as an access point for my tower.

i referenced this page ( http://wiki.gentoo.org/wiki/Hostapd ) when setting it up so im using hostapd, and dnsmasq.

starting /etc/init.d/net.<interface> displays (* hostapd: waiting for net<interface>)and a bracketed count down

trying to start /etc/init.d/hostapd times out with (* net<interface>: waiting for hostapd) and the timer

and starting /etc/init.d/dnsmasq causes both starting with (* net<interface>: waiting for hostapd) and the timer

any advice would be helpfull and i can post anything you need to see. 

Thanks

----------

## Aiken

When I run hostapd I create a bridge. I have eth0 and wlan0 bridged so the wifi clients are on the same network as everything else. Some may want routing between eth0 and wlan0. That howto looks orientated towards routing. I chose bridged. With bridging all wifi networks have access to my main dhcp server. With routing it seemed I would have had 3 (sometimes 4) dhcp servers or trying to route dhcp messages from 1 subnet to another.

The only settings in /etc/conf.d/net I have are for the bridge. Nothing for wlan0 as hostapd sets it up and not openrc

```

config_eth0="null"

bridge_br0="eth0"

config_br0="dhcp"

```

In /etc/conf.d/hostapd I have INTERFACES="br0" as hostapd in my configuration depends on br0 being configured before it starts. I do not have wlan0 here as (at least on my setup) there is nothing to be done to wlan0 before hostapd starts. 

In /etc/init.d/ the only net.whatever symlink I have is net.br0. Both net.br0 and hostapd are in the default runlevel. The only difference I am seeing between my hostapd.conf and the examples in that howto are I have bridge=br0 which tells hostapd to add wlan0 to the bridge. If you go the routing way you won't want bridge= set.

----------

## mayhew

Im just trying to setup a wireless access point not a bridge to the internet. 

i hope to use it to transfer files and ssh into my system as needed.

----------

## Aiken

Any chance you have INTERFACES set in /etc/conf.d/hostapd? I have a simple non bridging ap with wlan1 on a spare laptop

More less from that howto /etc/conf.d/net

```

modules="!iwconfig !wpa_supplicant"

config_wlan1="192.168.42.1/24"

rc_net_wlan1_need="hostapd"

```

With INTERFACES="" in /etc/conf.d/hostapd, a '/etc/init.d/net.wlan1 start' starts hostapd then sets the ip on wlan1. Both are up and running. If I set INTERFACES="wlan1" in /etc/conf.d/hostapd I end up with a dependency loop. Wlan1 depends on hostapd as per /etc/conf.d/net and hostapd depends on wlan1 as per /etc/conf.d/hostapd and get a count down timer.

Clearing INTERFACES opens the dependency loop. I just connected to this ap with a static ip from my phone. Setting INTERFACES in /etc/conf.d/hostapd when it does not have to be set can cause problems.

----------

## mayhew

thank you aiken, i had an interface listed in hostapd.conf making progress. the loop has ended. but now my system wont pass ip addresses to devices (android phone) 

now starting /etc/init.d/hostapd brings up <interface> without ip address and 

       starting /etc/init.d/net.<interface> starts hostapd and wpa_supplicant brings up <interface> without ip adress

       starting /etc/init.d/dnsmasq starts hostapd and wpa_supplicant brings up <interface> but fails starting dnsmasq without 

             informing me (no message like "error")

and none allow me to see the ssid 

i only see the connection when running as root #hostapd /etc/hostapd/hostapd.conf but ip addresses don't get shared. my android device hangs on geting the ip address than the connection times out.

----------

## Aiken

I used modules= instead of rc_net_wlan0_modules= to stop iwconfig and wpa_supplicant from running. Once those 2 programs stopped interfering wlan1 came up with the correct address. For that test I did not bother with a dhcp server. When connecting from my phone to test I set a static ip.

----------

## olivierweb

Hi,

I'm sperting the same dependency loop after following the wiki page http://wiki.gentoo.org/wiki/Hostapd without resolving it despite your comments.

These are my files, where am I wrong?

# cat /etc/conf.d/net

```

rc_net_wlan0_modules="!iwconfig !wpa_supplicant" # by default wireless interfaces are assumed to be clients, not APs

config_wlan0="192.168.42.1/24"                   # the AP's IP and network

rc_net_wlan0_need="hostapd"                      # ensures the interface is [re]configured after hostapd [re]starts

```

# cat /etc/conf.d/hostapd 

```

INTERFACES="wlan0"

CONFIGS="/etc/hostapd/hostapd.conf"

OPTIONS=""

```

# cat /etc/hostapd/hostapd.conf

```

interface=wlan0       # the interface used by the AP

# g simply means 2.4GHz band

hw_mode=g

channel=10            # the channel to use

ieee80211d=1          # limit the frequencies used to those allowed in the country

country_code=FR       # the country code

ieee80211n=1          # 802.11n support

wmm_enabled=1         # QoS support

# the name of the AP

ssid=somename

auth_algs=1           # 1=wpa, 2=wep, 3=both

wpa=2                 # WPA2 only

wpa_key_mgmt=WPA-PSK  

rsn_pairwise=CCMP

wpa_passphrase=somepassword

```

# /etc/init.d/net.wlan0 start

```

 * hostapd: waiting for net.wlan0 (50 seconds)

 * hostapd: waiting for net.wlan0 (41 seconds)

...

 * hostapd: timed out waiting for net.wlan0

 * ERROR: cannot start hostapd as net.wlan0 would not start

 * ERROR: cannot start net.wlan0 as hostapd would not start

```

Thanks for your help.

----------

