# intel wireless-n 2230 and wpa_supplicant [solved]

## Spanik

I'm trying to get wifi on my laptop running. So far I have done the following:

lspci:

```
03:00.0 Network controller: Intel Corporation Centrino Wireless-N 2230 (rev c4)
```

In the kernel I compiled in:

  - loading of firmware

  - networking support -> wireless -> cfg80211

  - networking support -> wireless -> Generic IEEE802.11 networking stack

  - networking support -> WIMAX wireless broadband support

  - networking support -> RF switch subsystem support

  - network devices support -> wireless lan -> intel wireless wifi next gen - wireless-n/advanced-n/ultimate n (iwlwifi)

   - network devices support -> wireless lan -> intel wireless wifi next gen - wireless-n/advanced-n/ultimate n (iwlwifi) -> iwlwifi experimental p2p support

Next I downloaded the firmware for the wireless-n 2230 and put that in /lib/firmware

Because I use WPA-PSK on the wireless router I then followed with "emerge wpa_supplicant", this included Wicd network manager. Then created the following /etc/wpa_supplicant/wpa_supplicant.conf (I used the correct ssid and psk  :Very Happy: ) ) plain copied from the wiki:

```
# The below line not be changed otherwise we refuse to work

ctrl_interface=/var/run/wpa_supplicant

# Ensure that only root can read the WPA configuration

ctrl_interface_group=0

# Let wpa_supplicant take care of scanning and AP selection

ap_scan=1

# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers

network={

  ssid="my_ssid"

  psk="my_psk"

  # The higher the priority the sooner we are matched

  priority=5

}
```

Then there is /etc/conf.d/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 :]!).

config_enp12s0="dhcp"

modules="wpa_supplicant"

wpa_supplicant_wlp3s0="-Diwlwifi"

config_wlp3s0="dhcp"
```

Created the link net.wlp3s0 and added this to runlevel default.

When I boot the pc I see the following:

dmesg:

```
[    6.799157] Intel(R) Wireless WiFi driver for Linux, in-tree:

[    6.799159] Copyright(c) 2003-2012 Intel Corporation

[    6.800250] iwlwifi 0000:03:00.0: irq 46 for MSI/MSI-X

[    6.808061] iwlwifi 0000:03:00.0: loaded firmware version 18.168.6.1

[    6.823844] iwlwifi 0000:03:00.0: CONFIG_IWLWIFI_DEBUG disabled

[    6.823848] iwlwifi 0000:03:00.0: CONFIG_IWLWIFI_DEBUGFS disabled

[    6.823851] iwlwifi 0000:03:00.0: CONFIG_IWLWIFI_DEVICE_TRACING disabled

[    6.823854] iwlwifi 0000:03:00.0: CONFIG_IWLWIFI_DEVICE_TESTMODE disabled

[    6.823856] iwlwifi 0000:03:00.0: CONFIG_IWLWIFI_P2P enabled

[    6.823859] iwlwifi 0000:03:00.0: Detected Intel(R) Centrino(R) Wireless-N 2230 BGN, REV=0xC8

[    6.824121] iwlwifi 0000:03:00.0: L1 Enabled; Disabling L0S

[    6.824402] udevadm (1352) used greatest stack depth: 4240 bytes left

[    6.848048] systemd-udevd[1334]: renamed network interface eth0 to enp12s0

[    6.848084] ieee80211 phy0: Selected rate control algorithm 'iwl-agn-rs'

[    6.904703] keymap (1396) used greatest stack depth: 3976 bytes left

[    7.019702] systemd-udevd[1336]: renamed network interface wlan0 to wlp3s0
```

I assume after this that the hardware has its firmware correctly programmed and should be working?

rc.log however gives:

```
  * Starting WPA Supplicant Daemon ...

ioctl[SIOCSIWPMKSA]: Invalid argument

ioctl[SIOCSIWMODE]: Invalid argument

ioctl[SIOCGIWRANGE]: Invalid argument

ioctl[SIOCGIWMODE]: Invalid argument

ioctl[SIOCSIWAP]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWPMKSA]: Invalid argument

 [ ok ]

 * Starting DHCP Client Daemon ...

 [ ok ]

 * Bringing up interface enp12s0

 *   dhcp ...

 *     Running dhcpcd ...

dhcpcd[2190]: sending commands to master dhcpcd process

 [ ok ]

 *     received address 

 [ ok ]

 * Bringing up interface wlp3s0

 *   Starting wpa_supplicant on wlp3s0 ...

Unsupported driver 'iwlwifi'.

 *   start-stop-daemon: failed to start `/usr/sbin/wpa_supplicant'

 [ !! ]

 * ERROR: net.wlp3s0 failed to start

 * ERROR: cannot start netmount as net.wlp3s0 would not start
```

rc-status --all:

```
Runlevel: default

 wpa_supplicant                                                                                                                                                                      [  started  ]

 dhcpcd                                                                                                                                                                              [  started  ]

 dbus                                                                                                                                                                                [  started  ]

 net.enp12s0                                                                                                                                                                         [  started  ]

 net.wlp3s0                                                                                                                                                                          [  stopped  ]

 netmount                                                                                                                                                                            [  stopped  ]

 consolekit                                                                                                                                                                          [  started  ]

 local                                                                                                                                                                               [  started  ]

Runlevel: shutdown

```

Now where does it run wrong? I have been looking around on the net but I cannot see the problem when I compare with what is done there.

----------

## Logicien

Change in /etc/conf.d/net 

```
wpa_supplicant_wlp3s0="-Diwlwifi" 
```

for

```
wpa_supplicant_wlp3s0="-Dnl80211"
```

----------

## Spanik

Changed /etc/conf.d/net to

```
# 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 :]!).

config_enp12s0="dhcp"

modules="wpa_supplicant"

wpa_supplicant_wlp3s0="-Dnl80211"

config_wlp3s0="dhcp"
```

It is NL80211 and not N180211?

rc.log now gives:

```
 * Starting WPA Supplicant Daemon ...

ioctl[SIOCSIWPMKSA]: Invalid argument

ioctl[SIOCSIWMODE]: Invalid argument

ioctl[SIOCGIWRANGE]: Invalid argument

ioctl[SIOCGIWMODE]: Invalid argument

ioctl[SIOCSIWAP]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWENCODEEXT]: Invalid argument

ioctl[SIOCSIWPMKSA]: Invalid argument

 [ ok ]

 * Starting DHCP Client Daemon ...

 [ ok ]

 * Bringing up interface enp12s0

 *   dhcp ...

 *     Running dhcpcd ...

dhcpcd[2191]: sending commands to master dhcpcd process

 [ ok ]

 *     received address 

 [ ok ]

 * Bringing up interface wlp3s0

 *   Starting wpa_supplicant on wlp3s0 ...

ctrl_iface exists and seems to be in use - cannot override it

Delete '/var/run/wpa_supplicant/wlp3s0' manually if it is not used anymore

Failed to initialize control interface '/var/run/wpa_supplicant'.

You may have another wpa_supplicant process already running or the file was

left by an unclean termination of wpa_supplicant in which case you will need

to manually remove this file before starting wpa_supplicant again.

 *   start-stop-daemon: failed to start `/usr/sbin/wpa_supplicant'

 [ !! ]

 * ERROR: net.wlp3s0 failed to start

 * ERROR: cannot start netmount as net.wlp3s0 would not start

 * Starting local

 [ ok ]
```

I removed the /var/run/wpa_supplicant/wlp3s0 file and rebooted but that made no difference.

----------

## Logicien

Yes it is an L, but the l in lower case. So, theres's an invalid argument somewhere. Do NetworkManager and/or Wicd are started too? Because Wpa_supplicant complain about an other instance of itself who is already started.

Try to stop all network script and verify that wpa_supplicant and dhcp daemon are not active for the wlp3s0 interface with the command ps or htop. If so kill them.

Manually try to get your wlp3s0 up an configure as the root user:

```
wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -D nl80211 -dd -f /var/log/wpa.log -i wlp3s0 -t
```

Check after a moment if the interface is associated with the access point:

```
iwconfig wlp3s0
```

If not, have a look to /var/log/wpa.log. Only if the association with the access point have succeed:

```
dhcpcd wlp3s0
```

When you have a problem with the Gentoo network daemon, it is good to be sure that you can succeed to make up and running an interface manually before trying to automated it with the daemon.

My /etc/wpa_supplicant/wpa_supplicant.conf

```
ap_scan=1

country=CA # change for your country

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=0

eapol_version=1

fast_reauth=1

update_config=1

network={

        #psk="comment"

        psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        ssid="name of the access point"

}
```

I set the access point that way:

```
wpa_passphrase <ssid> [passphrase] >> /etc/wpa_supplicant/wpa_supplicant.conf
```

----------

## Spanik

Don't understand it anymore.

I removed dhcpcd and wpa_supplicant from runlevel default to start without any network-related stuff running. When I now boot I have the following with rc-status:

```
Runlevel: default

 dbus                                                                                                                                                                                [  started  ]

 net.enp12s0                                                                                                                                                                         [  started  ]

 net.wlp3s0                                                                                                                                                                          [  started  ]

 netmount                                                                                                                                                                            [  started  ]

 consolekit                                                                                                                                                                          [  started  ]

 local                                                                                                                                                                               [  started  ]

Dynamic Runlevel: hotplugged

Dynamic Runlevel: needed

Dynamic Runlevel: manual
```

Remark that net.wlp3s0 is up and running!!!

Taking a look at rc.log:

```
 * Bringing up interface enp12s0

 *   dhcp ...

 *     Running dhcpcd ...

dhcpcd[2122]: version 5.6.4 starting

dhcpcd[2122]: enp12s0: waiting for carrier

dhcpcd[2122]: enp12s0: carrier acquired

dhcpcd[2122]: enp12s0: sending IPv6 Router Solicitation

dhcpcd[2122]: enp12s0: sendmsg: Cannot assign requested address

dhcpcd[2122]: enp12s0: rebinding lease of 192.168.2.6

dhcpcd[2122]: enp12s0: acknowledged 192.168.2.6 from 192.168.2.1 `tc'

dhcpcd[2122]: enp12s0: checking for 192.168.2.6

dhcpcd[2122]: enp12s0: sending IPv6 Router Solicitation

dhcpcd[2122]: enp12s0: leased 192.168.2.6 for 259200 seconds

dhcpcd[2122]: forked to background, child pid 2160

 [ ok ]

 *     received address 192.168.2.6/24

 [ ok ]

 * Bringing up interface wlp3s0

 *   Starting wpa_supplicant on wlp3s0 ...

 [ ok ]

 *   Starting wpa_cli on wlp3s0 ...

 [ ok ]

 *   Backgrounding ... ...

 * WARNING: net.wlp3s0 has started, but is inactive

 * WARNING: netmount is scheduled to start when net.wlp3s0 has started

 * Starting local

 [ ok ]
```

Why does it runs now? The only difference is that I have powered down the pc for the night instead of just restarting or init 6.

If I run ps auxw I get:

```
...

root      2160  0.0  0.0   8560   360 ?        Ss   21:04   0:00 dhcpcd -m 2 enp12s0

root      2281  0.0  0.0  35632  1528 ?        Ss   21:04   0:00 /usr/sbin/wpa_supplicant -Dnl80211 -c /etc/wpa_supplicant/wpa_supplicant.conf -W -B -i wlp3s0 -P /var/run/wpa_supplicant-wlp3s0.p

root      2288  0.0  0.0  11012   336 ?        Ss   21:04   0:00 /usr/bin/wpa_cli -a /etc/wpa_supplicant/wpa_cli.sh -p /var/run/wpa_supplicant -i wlp3s0 -P /var/run/wpa_cli-wlp3s0.pid -B

...

root      2751  0.1  0.2 225684 22876 ?        S    21:05   0:00 /usr/bin/python2 -O /usr/share/wicd/gtk/wicd-client.py --tray

...
```

So even while I removed dhcpcd frm runlevel default it is up and running with the wired interface. Wpa_supplicant and wicd are also running.

What is even worse is that if I now open the gui of wpa_supplicant I see that is has found the wireless connection. And if I ask to connect it does connect to the wireless. If I ask it to scan it finds other wireless networks as well.

Only thing right now is that it doesn't do dhcp with the wireless router. So I dont have an IP address that works on the network and no working connection.

But I do not understand it. I removed dhcpcd and it is still running. But only with the wired connection, not with the wireless, while that is also defined in /etc//conf.d/net. Likewise I removed wpa_supplicant only to find it running (even better, working). I never did something for wicd except emerging it and running a few times inside kde to see what it would do/find. But wicd is still not finding more than the wired connection, no wireless connection there.

----------

## Spanik

Tested a bit more. Conclusion and questions so far:

- with dhcpcd and wpa_supplicant removed from runlevel default wireless works. 

- I get a message that wicd cannot run and should be resterted. I didn't restart and didn't use it (AFAIK). Can I remove it?

- I took the pc to a place where it can see wireless networks it hasn't seen before. A scan works fine. And I can connect to it and receive an ip address. 

- it looks as if when the pc boots attached to a wired network, the wireless cannot do dhcp. Is this correct?

- who starts dhcpcd if it is removed from runlevel default? Is this started when /etc/conf.d/net is called?

- netmount doesn't start as it is waiting for both network interfaces (wired and wireless) to be running. Is there a way to tell it to start when one of them is up?

----------

## Logicien

dhcpcd and wpa_supplicant boot scripts are generic. wpa_supplicant try find a local wireless card and try to associate it to an access point according to /etc/wpa_supplicant/wpa_supplicant.conf. dhcpcd try to get a valid configuration to all local network cards (wired and wireless) from dhcp servers. NetworkManager and Wicd do the same on their sides.

If you have a symoblic link from /etc/init.d/net.lo to /etc/init.d/net.wlp3s0 and net.wlp3s0 is in the boot process, it will be configure according to the contain of the file /etc/conf.d/net. Because you have configure wlp3s0 to call wpa_supplicant and dhcpcd from there, they are started. The same principle apply to the wire one enp12s0.

So you do not need dhcpcd, wpa_supplicant, networkmanager and wicd boot scripts. Delete them with rc-update and just keep net.enp12s0 and net.wlp3s0 in the boot process and your wired and wireless cards will be configure. It is important to use only one network configuration method to advoid problems.

About the netmount script, you can tell it to wait for the network to be up before starting with the options in /etc/conf.d/netmount and/or with /etc/rc.conf. Remark that you must have some remote network to mount in /etc/fstab for the netmount script do something.

----------

## Spanik

Ok, thank you for explaining what happens. I'm afraid I don't know enough to get all that correctly. Most of the time I follow wiki's or other installation docs. 

Information like you just explained is often missing. You can find info at noob level and info at expert level but rarely in between.

Anyway, I can connect to wireless wetworks without much trouble. The wired connection also works. And I now know that there is no reason to have netmount working. (no idea why that should start)

----------

