# how do I use ath9k as wireless router

## andrewwalker27

I'm trying to set up a D-link DWA-556 wireless N card as a wireless access point and I'm struggling a bit with it. I've enabled the ath9k drivers in the kernel and the card seems to work ok as I can see it on my Android phone but I can't connect to it.

I've been following various howtos on the subject but half of them contradict the others! 

Do I need the madwifi package or not? I've installed it but it says the available versions don't support ar5008 which this card apparently is. It also mentions the 'trunk' version does, but what does that mean? What does the madwifi package actually do, is it firmware?

Am I correct in thinking I need to set the board in 'master' mode to act as an access point? I've tried setting up bridging between wlan0 and eth1 so both my internal networks are on the same subnet but it just stops my eth1 working correctly! I've setup dhcp and dnsmasq, do I need dnsmasq at all?

I'm running the stable x86_64 version of Gentoo by the way.

----------

## bjlockie

madwifi is the driver provided by Atheros, ath9k is the open source driver.

http://wireless.kernel.org/en/users/Documentation/modes

It says you need a program called hostap.

----------

## andrewwalker27

That's where it starts to get confusing! I thought madwifi was open source, the only proprietary part is HAL according to the web page. If this is the case, how does ath9k get around the HAL issue? Do I also need madwifi installed to provide it?

----------

## joeklow

For ath9k, you need to hand apply the patch I mentioned here: https://forums.gentoo.org/viewtopic-t-861343.html

Then, put ar9xxx firmware to /lib/firmware and install hostapd.

/etc/hostapd/hostapd.conf

```

interface=wlan1

driver=nl80211

ssid=MyAP

hw_mode=g

#channel=7

wpa=2

wpa_passphrase=gentoo

```

Warning: can't guarantee that your AP will support more than one client, if it does - please respond to ath9k-devel list.

Please, vote there for the patch to come into gentoo-sources.

----------

## andrewwalker27

Thanks for the info but which firmware to use?

I assume it's one of these

http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=tree

but there are 3 different ar9xxx drivers there.

----------

## joeklow

It is ar5481,ar2133.

Check dmesg after inserting the card, f/w name should be there.

----------

## andrewwalker27

Yes, that's the right firmware but it's not available on that webpage as far as I can see. Where do I get it from? It's not on the driver CDROM and I can't find it on D-Links site

----------

## joeklow

http://wireless.kernel.org/en/users/Drivers/ath9k#supported_chipsets

 *Quote:*   

> AR5008: 
> 
> AR5418+AR5133 (>= 2.6.27) 
> 
> AR5416+AR5133 (>= 2.6.27) 
> ...

 

Hmm.. it seems that a firmware is built into driver. Can you cite dmesg output with firmware request?

----------

## andrewwalker27

I don't get a firmware request, I just get a reference to it. The lines in dmesg say

phy0: Atheros AR5418 MAC/BB Rev:2 AR2133 RF Rev:81 mem-0xffffc90012400000, irq=16

phy0: Selected rate control algorithm 'ath9k_rate_control'

Registered led device: ath9k-phy0::radio

Registered led device: ath9k-phy0::assoc

Registered led device: ath9k-phy0::tx

Registered led device: ath9k-phy0::rx

I'm using the in-kernel driver by the way.

----------

## andrewwalker27

Well it looks like firmware is unnecessary, the problem was something to do with my hostapd.conf script.

I nuked the old one and started again with no encryption and it worked. I then added the encryption and it still worked! I'm still not sure where I went wrong but it's all ok now.

I've now hit a new problem, network bridging.

I'd already got my eth1 wired network working, and now I know the wlan0 wireless network works I want to bridge them so they are on the same subnet.

I get the following error,

Starting br0

   Creating bridge br0

   Adding ports to br0

       eth1

       wlan0

can't add wlan0 to bridge br0: Operation not supported

My /etc/conf.d/net was as follows

config_eth0=( "dhcp" )

config_eth1=( "192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255" )

modules_wlan0=( "!iwconfig" "!wpa_supplicant" )

config_wlan0=( "192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255" )

mode_wlan0="master"

how do I bridge eth1 and wlan0 so they are both on the same subnet?

I tried changing config_eth1=( "null" ) and config_wlan0=( "null" ) and adding bridge_br0=( "eth1 wlan0" ) but then the problems start. How do I make sure the bridge takes into account the mode setting and modules setting for the wlan0 network?

Does bridging even work with this driver? I've checked bridging is enabled in the kernel and the eth1 network gets added ok, it's just wlan0 that complains.

Any ideas?

----------

