# Wireless PCI adapter

## eruditas

Hello every1. I am using gentoo as a router, wired. But there is a need to buy a wireless PCI adapter, becouse my roommates want to have their laptops connected. As we are students, we only think abuot low cost adapters. I found one cheap, but I don't know how does it work with gentoo.

Here is the link http://www.smc.com/index.cfm?event=viewProduct&localeCode=EN_USA&cid=9&scid=48&pid=1589

I searched a bit, and found out, that it's using SMCWPCI-N 98-012084-638EU 32-bit PCI IEEE 802.11b/g/n-draft 300 Mbps 2.4 GHz Atheros AR5416 + AR2133 chipset. it's very tricky with those prism, atheros and so on drivers. I get lost. I don't know even if it will act as a HostAP. Anyone maybe has this card and will tell me if it's good, or will offer a good alternative.

Thanx for answers, guys.

P.S. Also I would like to know will I be able to bridge that wifi card into my already made bridge beetween eth1, eth2 and eth3, becouse I have already set up my dhcpd, bind and other services for that bridge.

----------

## Kompi

I don't have that card but according to this http://wireless.kernel.org/en/users/Drivers/ath9k (under supported chipsets) ath9k shoud support your chip. 

AP mode should work too with ath9k.

----------

## eruditas

There is a big difference between "should work" and "will work". Thank you for you answer, but I'm looking forward fore more info.  :Wink: 

----------

## eruditas

So, I bought this PCI wireless card, but when I try to install it seems to be a problem.

lspci -v

```

02:04.0 Ethernet controller: Atheros Communications Inc. Device ff1d (rev 01)

Subsystem: Atheros Communications Inc. Device ee1c

Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 12

Memory at f2000000 (32-bit, non-prefetchable) [size=64K]

Capabilities: [40] #80 [0000]

Capabilities: [80] #00 [0000]

```

I followed this, this and this guide combination, but no luck.

So, what I did is compiled ath5k and ath9k drivers as modules (don't know which chipset this card has): 

```
modprobe ath5k
```

and

```
modprobe ath9k
```

But when I type:

```
iwconfig
```

or

```
ifconfig -a
```

I cannot see the interface. What I did wrong? This is my first time doing something in linux with wireless. If you need more info, just tell me. Also maybe this will help.

----------

## eruditas

Heh, something strange happened. I put my wireless card in a different PCI slot and here it is:

lspci -v

```

02:0c.0 Network controller: Atheros Communications Inc. AR5416 802.11abgn Wireless PCI Adapter (rev 01)

        Subsystem: Device 1976:200b

        Flags: bus master, 66MHz, medium devsel, latency 168, IRQ 16

        Memory at f2000000 (32-bit, non-prefetchable) [size=64K]

        Capabilities: [40] #80 [0000]

        Kernel driver in use: ath9k

        Kernel modules: ath9k

```

iwconfig

```

lo        no wireless extensions.

eth2      no wireless extensions.

eth0      no wireless extensions.

eth1      no wireless extensions.

eth3      no wireless extensions.

wmaster0  no wireless extensions.

wlan1     IEEE 802.11bgn  ESSID:""

          Mode:Managed  Frequency:2.412 GHz  Access Point: Not-Associated

          Tx-Power=20 dBm

          Retry min limit:7   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:off

          Link Quality:0  Signal level:0  Noise level:0

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

tunl0     no wireless extensions.

br0       no wireless extensions.

```

Now I need some help, because I don't get these tricky manuals. I think madwifi is a way to go, but why did these wmaster0 and wlan1 interfaces appeared simultaniosly? Which one of them should I use to make my own router?

----------

## Kompi

As wmaster0 and wlan1 has been created, the driver seems to work for your card.

The madwifi driver creates wmasterX and one wlanX device by default. This is because it supports creating multiple virtual wlan-devices for a card (you may for example create one virtual device as "Managed" device thats binds to an access point and one that is an access point itself , so you can forward network access.) 

Wmaster0 is your card, the wlan devices you want to use to build your router is wlan1.

Read more about that here: http://madwifi-project.org/wiki/UserDocs/MultipleInterfaces

So if you want to create your own router follow the guides in the madwifi docs:

http://madwifi-project.org/wiki/UserDocs

There you find a description to build an AccessPoint: 

http://madwifi-project.org/wiki/UserDocs/ath5kAccessPoint

I hope thats enough to get the job done.

----------

## eruditas

Thanks for the answer. 

I have one straight question. In the manual it is written that I should use compat-wireless. But they are not in portage. And I prefer built-in drivers, not as a module. I know it's worse, but I'm used like this. So what is your advice? Should I use compat-wireless (I don't even know what it does) ?

----------

## Mousee

 *eruditas wrote:*   

> Thanks for the answer. 
> 
> I have one straight question. In the manual it is written that I should use compat-wireless. But they are not in portage. And I prefer built-in drivers, not as a module. I know it's worse, but I'm used like this. So what is your advice? Should I use compat-wireless (I don't even know what it does) ?

 

If your card works with the kernel drivers, then there's really no reason to use modular drivers. I have an Atheros card as well, the AR5413, and it works perfectly as both a client (used for aircrack) and an AP (aka wireless router) - and that's using only the kernel drivers and the madwifi-ng-tools package. I've read that some Atheros cards have issues with the built-in kernel drivers, so if you experience such issues, then I would definitely recommend locating some drivers you can build as modules. Otherwise you should be fine  :Smile: 

----------

## eruditas

 *Mousee wrote:*   

>  I have an Atheros card as well, the AR5413, and it works perfectly as both a client (used for aircrack) and an AP (aka wireless router) - and that's using only the kernel drivers and the madwifi-ng-tools package.

 

Wow, that's great. I red a little info, and it says that I should edit /etc/hostapd/hostapd.conf and /etc/conf.d/net. So I did as follows:

/etc/hostapd/hostapd.conf:

```

interface=wlan1

bridge=br0

# Driver interface type (hostap/wired/madwifi/prism54/test/none/nl80211/bsd/hostap/none);

driver=nl80211

logger_syslog=-1

logger_syslog_level=2

logger_stdout=-1

logger_stdout_level=2

dump_file=/tmp/hostapd.dump

ctrl_interface=/var/run/hostapd

ctrl_interface_group=0

ssid=darwin

hw_mode=g

channel=11

beacon_int=100

dtim_period=2

max_num_sta=255

rts_threshold=2347

fragm_threshold=2346

macaddr_acl=1

accept_mac_file=/etc/hostapd/hostapd.accept

auth_algs=3

ignore_broadcast_ssid=0

wme_enabled=0 #default 1

ieee80211n=1

ht_capab=[HT40-][SHORT-GI-40][DSSS_CCK-40]

eapol_key_index_workaround=0

eap_server=0

own_ip_addr=127.0.0.1

wpa=bit1

wpa_passphrase=********

wpa_key_mgmt=WPA-PSK WPA-EAP

wpa_pairwise=TKIP CCMP

```

and /etc/conf.d/net

```

mac_eth0="GE:NT:00:R0:CK:S1"

config_eth0=( "dhcp" )

dhcp_eth0=( "nodns nontp nonis" )

bridge_br0="eth1 eth2 eth3 wlan1"

config_br0=( "192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0" )

config_eth1=( "null" )

config_eth2=( "null" )

config_eth3=( "null" )

config_wlan1=( "null" )

channel_wlan1="1"

mode_wlan1="master"

essid_wlan1="darwin"

modules_wlan1=( "!iwconfig" "!wpa_supplicant" )

```

But all i got after reboot is stopped dhcpd service. I had to start it manually and then restart the named service, so I could get my wired internet. 

I'm sure I made a mistake somewhere... But my knowledge is too little

----------

## eruditas

Heh. I found somewhere that i should use /etc/init.d/hostapd start and here it is.

And there is a problem again. After reboot dhcpd fails to start. But I can start it manually via /etc/init.d/dhcpd start. Then I restart named, net.br0 and hostapd and wireless AP works again. 

So why dhcpd fails to start?

----------

## eruditas

I tried to do everything backwards. I removed hostapd from default runlevel, but dhcpd failed to start again. Then I removed wlan1 from the bridge ant commented out the lines in which was wlan1. Everything booted up correctly. 

If I try to:

```

darwin eruditas # wlanconfig wlan1 destroy

wlanconfig: ioctl: Operation not supported

```

So it does not work with neither of gentoo solution, or madwifi project solution. I'm out of ideas.

/var/log/messages says:

```

Sep  5 15:32:33 darwin dhcpd: Wrote 0 deleted host decls to leases file.

Sep  5 15:32:33 darwin dhcpd: Wrote 0 new dynamic host decls to leases file.

Sep  5 15:32:33 darwin dhcpd: Wrote 3 leases to leases file.

Sep  5 15:32:33 darwin dhcpd: 

Sep  5 15:32:33 darwin dhcpd: No subnet declaration for br0 (0.0.0.0).

Sep  5 15:32:33 darwin dhcpd: ** Ignoring requests on br0.  If this is not what

Sep  5 15:32:33 darwin dhcpd:    you want, please write a subnet declaration

Sep  5 15:32:33 darwin dhcpd:    in your dhcpd.conf file for the network segment

Sep  5 15:32:33 darwin dhcpd:    to which interface br0 is attached. **

Sep  5 15:32:33 darwin dhcpd: 

Sep  5 15:32:33 darwin dhcpd: 

Sep  5 15:32:33 darwin dhcpd: Not configured to listen on any interfaces!

```

How it's not configured? Doesn't the line

```
config_br0=( "192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0" )
```

says it is? don't get it...

----------

## rufnut

Your getting there.

```

darwin eruditas # wlanconfig wlan1 destroy

wlanconfig: ioctl: Operation not supported

```

You wont be able to do this if you are using ath9k, 

it's a different driver altogether from madwifi.

with regard to naming , you may want to check:

/etc/udev/rules.d/*persistent.net.rules as you may have some preset 

device names in there.

for device names with ath9k try "iw" eg:

iw dev wlan1 info

thats the new tool I think you are looking for.

Oh and make sure you have no remaining drivers of madwifi left around.

Otherwise you will have to blacklist them.

 :Smile: 

----------

## eruditas

```
darwin eruditas # iw dev wlan1 info

bash: iw: command not found

```

Hmm... 

I made my wlan1 device not bridged into br0, but as a single one with different subnet. And it works!

But why it doesn't work when it's bridged into br0? It still remains a mistery to me.

----------

## rufnut

Should have told you.

You have to install the package IW first

try : emerge iw 

then :

iw dev wlan1 info

about the bridge, I am not sure? 

I have not tried bridging just yet.

 :Smile: 

----------

## eruditas

So the thread still remains open  :Smile: 

----------

