# wlan0 not connecting to router  - new installation [SOLVED]

## Tony0945

The router's logs show nothing.  

/var/log/messages excerpt:

```
Nov  5 09:16:26 maggi kernel: wlan0: authenticate with 00:24:01:70:8a:cf

Nov  5 09:16:26 maggi kernel: wlan0: send auth to 00:24:01:70:8a:cf (try 1/3)

Nov  5 09:16:26 maggi kernel: wlan0: authenticated

Nov  5 09:16:26 maggi kernel: wlan0: associate with 00:24:01:70:8a:cf (try 1/3)

Nov  5 09:16:26 maggi kernel: wlan0: RX AssocResp from 00:24:01:70:8a:cf (capab=0x431 status=0 aid=4)

Nov  5 09:16:26 maggi kernel: wlan0: associated

Nov  5 09:16:26 maggi kernel: wlan0: deauthenticating from 00:24:01:70:8a:cf by local choice (Reason: 3=DEAUTH_LEAVING)
```

# grep -v \# /etc/conf.d/net

```
 

modules_wlan0="wpa_supplicant"

wpa_supplicant_wlan0="-Dnl80211,wext"

config_wlan0="dhcp"

config_eth0="dhcp"

```

  (eth0 is connecting fine)

grep -v \# /etc/wpa_supplicant.conf 

```
 

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1

network={

  ssid="myssid"

  scan_ssid=1

  psk="mypassphrase"

  priority=2

}  
```

SSID & passphrase replaced. The originals ARE correct. If they weren't there should be an entry in the router log.

There is no rfkill device although support is in the kernel.Last edited by Tony0945 on Mon Nov 06, 2017 2:59 pm; edited 1 time in total

----------

## NeddySeagoon

Tony0945,

```
Nov  5 09:16:26 maggi kernel: wlan0: deauthenticating from 00:24:01:70:8a:cf by local choice (Reason: 3=DEAUTH_LEAVING)
```

That means you asked it to shut down, even if you didn't realise it.

The usual reason for this is several things fighting over wpa_supplicant.  You see the wifi cycling all the time.

Set up your wlan0 so it does not start automatically. Then you know you have exactly zero things driving wpa_supplicant.

You should be able to start wlan0 manually now and it will justwork.

Now add exactly one network control program to the default runlevel.

----------

## Tony0945

```
~ # /etc/init.d/net.wlan0 start

net.wlan0         | * Bringing up interface wlan0

net.wlan0         | *   Starting wpa_supplicant on wlan0 ...

net.wlan0         |Successfully initialized wpa_supplicant                [ ok ]

net.wlan0         | *   Starting wpa_cli on wlan0 ...                     [ ok ]

net.wlan0         | *   Backgrounding ... ...

net.wlan0         | * WARNING: net.wlan0 has started, but is inactive

```

```
 # ifconfig -a

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.0.171  netmask 255.255.255.0  broadcast 192.168.0.255

        ether 84:34:97:83:15:79  txqueuelen 1000  (Ethernet)

        RX packets 992  bytes 88618 (86.5 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 873  bytes 280966 (274.3 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

        ether 20:68:9d:8e:7d:e0  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

 Router should have assigned wlan0 address 192.168.0.170 but nothing in the router log. I don't think it asked the router for an address.

```
Nov  5 17:37:35 maggi sshd[3622]: Accepted keyboard-interactive/pam for root from 192.168.0.100 port 1459 ssh2

Nov  5 17:37:35 maggi sshd[3622]: pam_unix(sshd:session): session opened for user root by (uid=0)

Nov  5 17:40:01 maggi cron[3653]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons)

Nov  5 17:40:24 maggi wpa_supplicant[3802]: Libgcrypt warning: missing initialization - please fix the application

Nov  5 17:40:25 maggi /etc/init.d/net.wlan0[3671]: WARNING: net.wlan0 has started, but is inactive

```

 So something wrong with libcrypt? How to figure out what?

----------

## UberLord

 *Tony0945 wrote:*   

> 
> 
> ```
> wlan0: flags=4099<UP,BROADCAST,MULTICAST>
> ```
> ...

 

Nor will it until the RUNNING flag appears on the interface.

If that flag is absent, the kernel things the link is down.

In this case, it's not associated correctly with the AP.

 *Quote:*   

> So something wrong with libcrypt? How to figure out what?

 

Or something wrong with how wpa_supplicant expects to use it.

Good luck!

----------

## Tony0945

Started service with --debug flag:

```
net.wlan0         |+ opts='-Dnl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf -C /var/run/wpa_supplicant -W'

net.wlan0         |+ start-stop-daemon --start --exec /usr/sbin/wpa_supplicant --pidfile /var/run/wpa_supplicant-wlan0.pid -- -Dnl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf -C /var/run/wpa_supplicant -W -B -i wlan0 -P /var/run/wpa_supplicant-wlan0.pid

net.wlan0         |Successfully initialized wpa_supplicant

net.wlan0         |+ eend 0                                                                                                                                                            [ ok ]

net.wlan0         |+ '[' -z /usr/bin/wpa_cli ']'

net.wlan0         |+ local inact=false

net.wlan0         |+ service_inactive

net.wlan0         |+ mark_service_inactive

net.wlan0         |+ ebegin 'Starting wpa_cli on' wlan0

net.wlan0         | *   Starting wpa_cli on wlan0 ...

net.wlan0         |+ start-stop-daemon --start --exec /usr/bin/wpa_cli --pidfile /var/run/wpa_cli-wlan0.pid -- -a /etc/wpa_supplicant/wpa_cli.sh -p /var/run/wpa_supplicant -i wlan0 -P /var/run/wpa_cli-wlan0.pid -B

net.wlan0         |+ eend 0                                                                                                                                                            [ ok ]

net.wlan0         |+ ebegin 'Backgrounding ...'

net.wlan0         | *   Backgrounding ... ...

net.wlan0         |+ exit 1

net.wlan0         | * WARNING: net.wlan0 has started, but is inactive

```

/etc/conf.d/net :

```
modules_wlan0="wpa_supplicant"

wpa_supplicant_wlan0="-Dnl80211,wext"

config_wlan0="dhcp"

config_eth0="dhcp"
```

/etc/wpa_supplicant/wpa_supplicant.conf:

```
network={

        ssid="Road2hell"

        psk="notmyrealpassphrase"

        proto=RSN

        key_mgmt=WPA-PSK

        priority=5

}

```

Is the problem using my passphrase instead of my pass key?   My router has the key hidden with dots. I could regenerate a key but then I would have to rebuild the connection for everything else on the network wouldn't I?

EDIT: Ok, I discovered the program "wpa_passphrase" but wlan0 is still inactive. Is the case that eth0 and wlan0 cannot both be active even though they have separate MAC addresses?

EDIT2:

WHOA! After replacing wpa_supplicant.conf with the shorter version output from wpa_passphrase and restarting net.wlan0, I still get "started but not active", HOWEVER, the router now shows that MAC address under "wireless connections" as 192.168.0.170 and I can ping that address and ssh in.  Maybe those proto, key_mgmt and priority lines from the wiki were messing me up? And it's a mystery why openrc reports inactive when it is obviously working.

----------

## NeddySeagoon

Tony0945,

Having two interfaces on the same subnet is a really bad idea.

You might have two default routes too. Only one will ever be used. 

It can be made to work but its best avoided.

----------

## Tony0945

NeddySeagoon,  how can I fire up wireless only if wired failed?  Right now I have net.eth0 in boot level and net.wlan0 in default level. I disconnected the ethernet plug and rebooted. Sure enough net.eth0 failed and net.wlan0 came up. So that part works.

On my network, the router knows to assign separate ip addresses to the two different MAC addresses. This will not be so at the netbook's true home (my sister's house).

I think this can be done by not symlinking net.wlan0 to net.lo but copying it instead and altering the need line from " need localmount" to something like "need localmount && !net.eth0" but am unsure of the syntax. The intent is to block wan0 if eth0 is up. 

I see links how to do this with networkmanager and dhcpd but I use openrc (old version) netifrc and busybox.

History: This was a Windows 8 box. While in the hospital my sister cancelled Comcast (she's moving) and I tried to remove their software from her computer which runs slower than a turtle. Someone (a Comcast tech?) installed ConstantGuard on top of Norton System Protect and destroyed the admin interface in the process. In deep frustration from grayed out system stuff and a computer running slower than molasses, I ordered a new WD hard drive, removed the old hard drive in case she doesn't like the linux, and installed gentoo with refind and Mate on the new drive. It boots rather snappy now (for a one lung CPU) and has a much better looking interface than Openshell on Win8. T-bird and FF are rather slow but maybe it's because they are the bin distriubtions. It seems like a nightmare to try and build FF on this box. Palemoon-bin from overlay is faster, can't complain about it. And once I copied her T-Bird profile from Windows (was easy!), all her extensions and e-mail are there. T-bird is reasonably fast once it loads.  I didn't do emerge -e world, but hundreds of packages were built native in the course of installing Mate and OpenRC (downgraded from the horrible latest version), eudev (likewise downgraded) and updating gcc to 6.4.0 and rebuilding the toolchain. Native FF and T-bird mightbe faster but be a nightmare to build. I copied my config from the A8-7600 box (also radeon and UEFI) changed the firmware to the right files, updated the device drivers and compiled using native).  I think she will like the look and feel and Gentoo is more secure than Win8 even after I applied over 100 updates.

She is used to plugging in the ethnet cable because comcast's wireless is unreliable (from across the room!). I think it's because she was in a large apartment building and comcast uses their customer's boxes as a free wifi hotspot. She's moving to a house and AT*T Uverse so the wireless might be better. It's running well here in my house . I know I'll have to edit the ssid and passphrase at her new house.

----------

## UberLord

 *NeddySeagoon wrote:*   

> Tony0945,
> 
> Having two interfaces on the same subnet is a really bad idea.
> 
> You might have two default routes too. Only one will ever be used. 
> ...

 

Respectfully Neddy, I disagree  :Smile: 

heck, with dhcpcd-7 you can even share the same IPv4 address on the same subnet on different interfaces  :Smile: 

And this is a good idea.

For example, when my laptop is plugged in via a wire, I want to use that because it's faster.

Otherwise wireless is used.

Equally when I want to talk to my laptop, I don't care how it's connected, only that it is. And this is where IP address sharing comes in.

With dhcpcd-6, only the primary interface has the address - starting with dhcpcd-7 all interfaces can have the address and we use the magic of ARP to inform upstream nodes which interface to send to.

This allows seamless transition from wired -> wireless -> wired. No applications loose connectivity It Just Works.

But this does rely on using dhcpcd directly in a runlevel and not net.foo from netifrc.

----------

