# atheros hostapd - openrc configuration

## djinnZ

I am unable to understand how to set up my computer as "bridged AP". My NICs arewlan0

```
02:07.0 Ethernet controller: Atheros Communications Inc. AR5212/AR5213 Wireless Network Adapter (rev 01)
```

eth1

```
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168 PCI Express Gigabit Ethernet controller (rev 06)
```

eth0

```
02:05.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)
```

Hostapd work fine with the atheros and i have no problem but now i will bridge wlan0 and eth1.

The "manual" sequence 

```
ifconfig eth1 up

ifconfig wlan0 up

brctl addbr br0

brctl addif br0 eth1

hostapd -B /etc/hostapd/hostapd.conf

brctl addif br0 wlan0

ifconfig br0 ...
```

work fine.

```
ifconfig eth1 up

ifconfig wlan0 up

brctl addbr br0

brctl addif br0 eth1

iw wlan0 set 4addr on

brctl addif br0 wlan0

hostapd -B /etc/hostapd/hostapd.conf

ifconfig br0 ...
```

also work but using iw is dirty trick and must be run as root so is not useful in a wlan0_preup function.

This is the relevant part of the configuration files: */etc/conf.d/net wrote:*   

> modules="iproute2"
> 
> # eth0  - wan interface
> 
> config_eth0="172.30.0.14/28"
> ...

  */etc/conf.d/hostapd wrote:*   

> INTERFACES="wlan0"

  */etc/hostapd/hostapd.conf wrote:*   

> interface=wlan0
> 
> bridge=br0
> 
> driver=nl80211
> ...

 

If i start by the console the initscripts there are no problems and the sequence is

```
/etc/init.d/net.eth0 start

/etc/init.d/hostapd start

/etc/init.d/net.br0 start
```

 but at restart openrc will use the ordernet.eth0net.eth1net.wlan0net.br0hostapdand net.br0, of course, fail to start.

Adding to default runlevel only hostapd and set  */etc/conf.d/hostapd wrote:*   

> INTERFACES="wlan0 eth1 br0"

  will also fail.

So my question is : what is the correct way to set up the damned openrc to start the bridge after hostapd and not before? Is an openrc bug or not?

I am not sure than the network section is the better choice bevause the problem is only related to openrc configuration.

edit: i have forget to write 

```
rc_net_br0_after="hostapd"

rc_hostapd_before="net.br0"
```

is an useful workaround but i will change the configuration at the runlevel change (in some case i need to use wlan0 to connect to gateway in place of eth0 and this is badly documented).

----------

