# Wireless usb adapter Dlink (aka ralink) wont connect

## theamazingplant2

I have an Dlink wireless adapter, and it will not connect to the my local network. it is a dlink DWA 140, and i am new to gentoo, so i may not be quite as good as you guys with some of the things that i may have to do.

well, here is my story: 

I started using gentoo about 3 days ago. i have had quite a few mess ups on the compiling of it since then. however, this time, i am quite sure that i compiled the kernel with the support for ALL of the Ralink wireless usb adapters.

anyway, if i run iwconfig it now sees it as wlan0. if i do iwlist wlan0 scan, it will show networks. the problem(s) are that i am not able to connect to any of these from the command line, and that the gui (wpa_supplicant, as i use wpa ) does not even see wlan0 as being there. so, what am i doing wrong, and what do i need to install? i have lubuntu on a different partition, and i can install some things as needed by chrooting into gentoo. so, any suggestions? i love gentoo so far and it is definitely a distro that i am sticking with, so long as i can get my internet.

----------

## Arkhelion

Hi,

First of all, welcome to Gentoo Linux!

Then about your issue.

Did you check on that page?

According to this page, you need  these kernel options (don't forget the last one)

```
Device Drivers --->

    [*] Network device support --->

         [*] Wireless LAN  --->

             <*> Ralink driver support  --->

                <*> Ralink rt27xx/rt28xx/rt30xx (USB) support

                [*] rt2800usb - Include support for unknown (USB) devices
```

And you need to:

```
# emerge sys-kernel/linux-firmware
```

The rest of the page is just about testing it actually worked. My first guess would be to check you have emerged linux-firmware.

----------

## theamazingplant2

Hello, Arkhelion. Thanks for replying! 

 I have already emerged the sys-kernel/linuxfirmware. i have also built the kernel support into the kernel (with a * by it) in the kernel configuration menu. I just can not get the network monitor in lxde or the wpa_supplicant tool to see the network. however, i am able to see the wlan0 in the ifconfig -a command, and i am also able to see networks available using the iwlist wlan0 scan command. any clue whats going on here, and if so, how i can fix it? thanks in advance for any help i get.

----------

## BillWho

theamazingplant2,

What does your /etc/conf.d/net file look like. 

Also did you symlink net.wlan0 -> net.lo   :Question: 

----------

## wrc1944

Here's my first thoughts:

Is the ralink usb driver really loading?  Check with lsmod.

What does the /etc/wpa_supplicant.conf file look like?  Might need some tweaking.

Are there any left over settings from other previous failed attempts to connect with wicd or NetworkManager that might try to load and cause a  conflict.

What's in your default run levels?  Check with rc-update show.

Are there any dbus error messages?

I'm using wpa_supplicant_gui on another distro (just figured it out last week, as that distro (binary) hadn't updated their kernel and driver needed for my specific adapte, and I didn't want to build my own kernels on that one).

On Gentoo I''ve been use NM or Wicd.  Should be the essentially the same deal, so I can help if you're still having trouble.

----------

## theamazingplant2

Script started on Thu Apr 12 16:51:25 2012

localhost ~ # cd /etc/conf.d

localhost conf.d # ls

bootmisc     git-daemon  localmount  pydoc-2.7  staticroute     xdm

consolefont  hostname    modules     pydoc-3.2  typescript

crypto-loop  hwclock     net         rsyncd     udev

dmesg        keymaps     network     slapd      urandom

fsck         killprocs   pciparm     sshd       wpa_supplicant

localhost conf.d # cd net

bash: cd: net: Not a directory

localhost conf.d # cat net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /usr/share/doc/openrc*/net.example* and save your configuration

# in /etc/conf.d/net (this file :]!).

localhost conf.d # symlink net.wlan0 net.l0

bash: symlink: command not found

localhost conf.d # ^Glsmod

Module                  Size  Used by

hid_logitech_dj         8821  0 

localhost conf.d # cat /etc/wpa_supplicant.conf

network={

        ssid="guesthak1"

   #psk="2011160099a"

        psk=2b891f7b2a8107104912da903c4cc6f83d72fda7e9eee3ae1e6278d20c629d5e

}

localhost conf.d # rc-update show

             bootmisc | boot                         

                devfs |                       sysinit

                dmesg |                       sysinit

                 fsck | boot                         

             hostname | boot                         

              hwclock | boot                         

              keymaps | boot                         

            killprocs |              shutdown        

                local |      default                 

           localmount | boot                         

              modules | boot                         

             mount-ro |              shutdown        

                 mtab | boot                         

               net.lo | boot                         

            net.wlan0 |      default                 

             netmount |      default                 

               procfs | boot                         

:

* A LITTLE NOTICE: since my version of gentoo does not have the proper utilitys for copying and pasting, i had to use typescript to get this set up to record what i did in the terminal, so please excuse me if i am posting a little bit TOO much. i hope this helps.* 

thanks in advance for all the help, you guys are my only hope!

----------

## wrc1944

The symlink net.wlan0 -> net.lo should be in /etc/init.d, so if you don't have that, do this:

cd /etc/init.d

ln -s net.lo wlan0

Your rc-update looks OK for net.lo and wlan0, but no dbus at default run level is curious???

Does the correct ralink driver show up loaded in lsmod?  That's mandatory.  All these types of drivers (among others) usually work better compiled as modules instead of directly into the kernel, and are auto detected and loaded at boot.

Is there any reason you don't want to use NetworkManager or wicd, or is this a completely new Gentoo install, without an X graphical desktop yet?  They work well, and there are detailed Gentoo documentation Guides for each.

----------

## BillWho

theamazingplant2,

I don't see anything in /etc/conf.d/net - that's part of the problem. This is my wireless section:

```
modules="wpa_supplicant"

wpa_supplicant_wlan0="-Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf"

wpa_timeout_wlan0=60

config_wlan0="192.168.1.103/24 brd 192.168.1.255"

routes_wlan0="default via 192.168.1.1"

```

I use static ip addresses, but you can substitute dhcp

Here's my wpa_supplicant file:

```
ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

update_config=1

network={

   ssid="wireless"

   psk="itsasecret"

   proto=RSN

   key_mgmt=WPA-PSK

   pairwise=TKIP

   auth_alg=OPEN

   priority=5

   id_str="gentoo"

}

```

You should be able to assemble pieces into yours,

If you still have a problem connecting try:

```
wpa_supplicant -dd -iwlan0 -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf
```

in a terminal. The -dd is for verbose debugging messages.

Good luck   :Wink: 

----------

## theamazingplant2

sorry if i didnt make this clear, but the lsmod showed up as this in my last post:

smod 

Module Size Used by 

hid_logitech_dj 8821 0

I do not think that that is the Ralink driver. If it is not, and i built it into the kernel ( when i built the kernel i had put a * sign in it to make it build directly into the kernel), then how do i get it to load? I can cd to lib/modules/mykernelname/* and see various drivers, like rt3070 ( one of the ralink ones i built into the kernel), so they are obviously there, they just dont seem to load, as they are not showing up in lsmod.

in response to the part about them working better as modules then as build directly in the kernel, i thought i was supposed to do it that way, is there any problem with that? as in, will this need a recompilation of my kernel?

while this is a new install, it does have an X server, as well as lxde. i have network manager, at least im pretty sure i managed to emerge it right ( im still new to gentoo, and im not totally confident in what im doing, so if i sound like i am doing something totally wrong,well, i probably am.)

----------

## theamazingplant2

thanks for the info Billwho, how do i fix the /etc/conf.d/net? as in, what parts of what you have should i copy and paste into mine?

i will try doing the command to connect to a wireless using wpa_supplicant in a little bit, and post the results ( note that it takes a little bit, as i have to use typescript to record those and then transfer them over to a different partition to view them and paste them here. 

thanks for all the help guys, its much appreciated!

----------

## BillWho

theamazingplant2,

 *Quote:*   

> when i built the kernel i had put a * sign in it to make it build directly into the kernel

 

If you used '*' that's fine, but it won't show with lsmod   :Sad: 

To check for it you can do this; I'm assuming it's a usb adapter:

```
gentoo ~ # lsusb

Bus 001 Device 003: ID 0b05:1784 ASUSTek Computer, Inc. USB-N13 802.11n Network Adapter [Ralink RT3072]

```

To identify the bus, then

```
gentoo ~ # lsusb -t

/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M

/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M

/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/8p, 480M

    |__ Port 7: Dev 3, If 0, Class=vend., Driver=rt2800usb, 480M

```

Notice Driver=rt2800usb dangling off Bus 01.Port 1: Dev 1. A driver should show even if it's compiled in the kernel.

As far as the 'net' contents, you can copy and paste the entire thing for now. Just make sure your router is on the same network segment (192.168.1) and no other computer is using 192.168.1.103 for an address.

If you can, try getting systemrescue and chrooting to your gentoo installation. It would be much easier to work with and, since it has firefox,  you'll be able to get back here.

Good luck   :Wink: 

----------

## wrc1944

BillWho knows his stuff for wpa_supplicant on gentoo, so if you elect to use it go with his advice.  There's also a Gentoo guide worth a look.

If it were me, and I could chroot into my gentoo like you said you could, and you already have an lxde desktop , I'd emerge firefox and NetworkManager or Wicd, and follow the Gentoo guides for them.  Much easier procedure.

Basically, with them, you remove must the /etc/init.d wlan0 symlink and remove all /etc/conf.d/net settings, and place either NM at default run level, or wicd at boot run level, and dbus at default run level. Then at boot you open the NM (or wicd) gui, and enter your info.

For future kernels (or recompile your current one), use modules, as this allows you to remove or load them manually, if the need arises. Plus, some items don't seem to  work well when compiled into the kernel.

----------

## theamazingplant2

i have an existing lubuntu installation that i am able to chroot into gentoo using, so i do not see the need to get a systemrescue cd. 

as for compiling the kernel that way next time, i will be sure to do that. thanks for the advice.

so i did the command lsusb, and i got the error: command not found.

i have tried running the command with both root and standard privileges ( by logging in and out as root) and it does not show up. what should i do? and if this does indeed require a kernel recompile, is there any way to save me the time of compiling Xorg again? if so , what? I am a student and am not able to spend all of my time compiling stuff, as i have work to do, but i love gentoo already, and would love to get it working. i will do the copy and pasting of the /etc/conf.d/net thing ASAP, but as i said i'm a student so that might be a hour or two. 

thanks, theamazingplant2

----------

## wrc1944

FWIW, I booted to my Arch Linux partition to check how I set up wpa_supplicant (when wicd or NM refused to work with my r8712u realtek driver), and once I figured out what to do, it was pretty simple.

I installed wpa_gui, and then waded through the huge wpa_supplicant.example file to figure out what I needed for my own /etc/wpa_supplicant.conf .  In my case it was only:

```
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=network

update_config=1

network={

   ssid="linked-WRC"

   psk="57xd$"H9JMD9sr~sttVruO2l^S:Bx_Nhya"ZPVc]'ak[}\#q.Me?_N&E=!^Jn%>"

   proto=RSN

   key_mgmt=WPA-PSK

   pairwise=CCMP

   auth_alg=OPEN

}
```

Then to make it load and connect at boot, I put in /etc/rc.local: 

```
wpa_supplicant -Dwext -i wlan0 -c/etc/wpa_supplicant.conf -B

dhcpcd wlan0 
```

Added my user to the network group. Worked perfectly.  Dbus is also loading as the second item in the Arch Linux DAEMONS= line in /etc/rc.conf, so in Gentoo you would need to do 

```
rc-update add dbus default

```

Gentoo's equivalent for running commands at boot is /etc/conf.d/local-start, or something like that- need to check on that- I'm not in Gentoo right now.

EDIT:  OK- here it is: http://www.gentoo.org/doc/en/openrc-migration.xml

 *Quote:*   

>  local.start and local.stop
> 
> With OpenRC, /etc/conf.d/local.start and local.stop are deprecated. During the migration to OpenRC, the files are moved to /etc/local.d and gain the suffix .start or .stop. OpenRC then executes those in alphabetic order. 

   So, I guess those two lines I put in Arch's /etc/rc.local could go in Gentoo's /etc/local.d/local.start

----------

## BillWho

wrc1944, -> correction theamazingplant2

I wasn't aware you had another linux distro installed - that's the best way to do it    :Very Happy: 

You can do most of what you need to do to configure and complete the installation via the chroot. Just be aware that all your devices are inherited from lubuntu so there will be times when you'll need run natively.

Install the following apps:

```
emerge -av sys-apps/usbutils sys-apps/pciutils app-portage/gentoolkit
```

lsusb is in the package sys-apps/usbutils. You'll most likely need the others sooner or later.

I see wrc1944 has provided some additional info so I'll stop here for now   :Wink: 

----------

## theamazingplant2

I owe a big thanks to everyone that replied, as i now have internet on my gentoo, and am in fact writing this post from my gentoo! 

Just to clarify what i did so as to help anyone else out with the same problem,

first, i went to my wpasupplicant file and copied and pasted the first  2 lines:" ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=network

update_config=1" and then did the wpa_passphrase command and put the output from that into my file also, following the syntax given by wrc1944.

next, i put it in the local start file.

next, i simply started up wpa_supplicant gui, and sure enough, it saw wlan0! it was able to scan for networks, and add them as one, and then connect to said network! 

however, this did not end it all. afterwards, (admittingly, this kind of had me stuck for a little bit, even though its so obvious) i did dhpcd command ( or something like that, cant quite remember the exact command unless i open up a terminal) and it worked! it assigned me my ip and next thing you know, im online.

again, a big thanks to everyone that helped! you guys have a great forum , and a AMAZING OS!

----------

