# Starting WiFi i/f  messed up

## philip

After a number of updates to my WiFi set up and the latest emerge -uDN @world starting my Wifi seems messed up

I use

```
* Kernel Version 4.4.6-gentoo

* KDE Plasma Version 5.8.3

* kde-plasma/plasma-nm
```

My problem is that my wifi connection is not automatically re-connected when I boot my laptop, as it used to do some time ago. Currently I need to manually click the wifi network i/f in the plasma-nm applet "Networks".

I have noticed that I get warnings and errors in the init sequence at boot up:

```
* Starting NetworkManager ...

 [ ok ]

...

* Marking NetworkManager as inactive. It will automatically be marked

 * as started after a network connection has been established.

 * WARNING: NetworkManager has started, but is inactive
```

and further down:

```
* Bringing up interface wlp3s0

 *   Starting wpa_supplicant on wlp3s0 ...

 [ ok ]

 *   Starting wpa_cli on wlp3s0 ...

Failed to connect to non-global ctrl_ifname: wlp3s0  error: No such file or directory

 *   start-stop-daemon: failed to start `/usr/bin/wpa_cli'

 [ !! ]

 * ERROR: net.wlp3s0 failed to start
```

My /etc/conf.d/net :

```
# Prefer wpa_supplicant over wireless tools

modules="wpa_supplicant"

#Generated by NetworkManager

###### Global Configuration ######

wpa_supplicant_wlp3s0="-Dnl80211 -d -f /var/log/wpa_supplicant.log"

###### Connection Configuration ######

#----------------------------------

fallback_enp0s25="192.168.123.146/24"

fallback_routes_enp0s25="default via 192.168.123.1"

ifplugd_enp0s25="--no-beep"

auto_enp0s25="true"

config_enp0s25="

192.168.1.250/24                                                                                 

192.168.1.250/24                                                                                 

"                                                                                                

enable_ipv6_enp0s25="false"                                                                      

modules_enp0s25="plug dhcpcd"

```

My  /etc/wpa_supplicant/wpa_supplicant.conf :

```
# cat /etc/wpa_supplicant/wpa_supplicant.conf 

# The below line can not be changed otherwise wpa_supplicant refuses to work

ctrl_interface=/var/run/wpa_supplicant GROUP=wheel

# Make this file writeable for wpa_gui / wpa_cli

update_config=1

#

ap_scan=1

network={

        ssid="<my-SSID>"

        psk="<my-passphrase>"

        scan_ssid=1

        proto=WPA2

        key_mgmt=WPA-PSK

        pairwise=CCMP TKIP

        group=CCMP TKIP

#       auth_alg=OPEN

        priority=5

}
```

----------

## eccerr0r

If you use NetworkManager, /etc/conf.d/net isn't actually used, and wpa_supplicant config is handled by NetworkManager.   You should not have the link in /etc/init.d/net.wlXXXX -> net.lo  as you'll not be using this, and rc-update delete net.wlXXXX from startup.

For NetworkManager you'll need to make sure in the applet or nmtui or whatever that you have a connection that's marked as "automatically connect" and "available to all users".

If you don't want to use NetworkManager you should disable it.

----------

## philip

This, at least made one difference:

System tray Networks -> Configure Network Connection -> Chosing <name-of-SSID> -> Connection name -> Ticking "All users may connect to thois network" .

Now my WiFi is automatically connected after boot.   It is a bit strange, since I previously used the "Advanced..." option and put my username in the right pane as the one user that: "Users allowed to activate the connection". This option should work, but obvioulsy do not. 

I removed /etc/conf.d/net which confirms it is not needed, 

I still have the error messages in the boot sequence though.

About 

```
# ls -al /etc/init.d/net*

lrwxrwxrwx 1 root root     6 maj  1  2014 /etc/init.d/net.enp0s25 -> net.lo

-rwxr-xr-x 1 root root 18514 dec 27 02:09 /etc/init.d/net.lo

-rwxr-xr-x 1 root root  2049 dec 27 02:09 /etc/init.d/netmount

-rwxr-xr-x 1 root root  2043 dec 27 02:09 /etc/init.d/net-online

lrwxrwxrwx 1 root root    18 jun 23  2014 /etc/init.d/net.wlp3s0 -> /etc/init.d/net.lo
```

Why have the links /etc/init.d/net.enp0s25 -> net.lo and /etc/init.d/net.wlp3s0 -> /etc/init.d/net.lo been created? I have not done it manually, I am sure.Can they be safely removed?

I am also a bit confused if NetworkManager really is needed or not. It seems plasma-nm depend on networkmanager

```
# equery d networkmanager

 * These packages depend on networkmanager:

dev-qt/qtnetwork-5.6.2 (networkmanager ? net-misc/networkmanager)

gnome-extra/nm-applet-1.4.0 (>=net-misc/networkmanager-1.3[introspection?,modemmanager?,teamd?])

kde-frameworks/networkmanager-qt-5.26.0-r2 (>=net-misc/networkmanager-1.4.0-r1[consolekit,teamd=])

                                           (>=net-misc/networkmanager-1.4.0-r1[systemd,teamd=])

kde-plasma/plasma-nm-5.8.3 (>=net-misc/networkmanager-0.9.10.0[teamd=])

net-im/telepathy-mission-control-5.16.4 (networkmanager ? >=net-misc/networkmanager-1)

net-libs/libproxy-0.4.13-r1 (networkmanager ? net-misc/networkmanager)

net-misc/networkmanager-openvpn-1.2.4 (>=net-misc/networkmanager-1.2.0)

www-client/firefox-45.6.0 (kernel_linux ? net-misc/networkmanager)
```

----------

## eccerr0r

NetworkManager is a service that lets users to manipulate network settings.  Typically networks is a root-only task.  With today's laptops and mobile devices, it gets kind of silly having to su to root every time you migrate to another network, and nm-applet and networkmanager lets you do it seamlessly and via a GUI.  No, NetworkManager is not "necessary" but you'll lose out on the convenience on machines that you switch networks often.  If you want to run nm-applet, which is the GUI, yes you do need the underlying networkmanager.

Yes you need "all users" because during boot time, nobody is logged in, and the system is not allowed to connect to the network...at least that's the theory behind why allowing all users is necessary.

I think /etc/conf.d/net should be a skeleton file, having it there does not affect the system.

I don't know why you have the /etc/init.d/net.enp0s25 and net.wlp3s0 files.  Those links are typically user generated and I don't know of any scripts that would automatically populate them.  They are OK to remove, though you should disable them from openrc first:

# rc-update del net.wlp3s0

# rc-update del net.enp0s25

After running these you shouldn't see the errors anymore without removing the links.

----------

## philip

Thanks a lot for exhaustive feedback and tips. 

I definitely need the convenience Networkmanager brings, since I travel extensively and wish to be able to connect to a vast number of WiFi networks in hotels, conference rooms and offices.

The  /etc/init.d/net.enp0s25 and net.wlp3s0 files are still a mystery. It may be that I followed this reference when I configured my Wireless (see the lines just before the "Gentoo configuration" heading): 

http://gentoo-en.vfose.ru/wiki/Wireless/Configuration

If I do # rc-update show and # rc-status before I attempt to remove the /etc/init.d/net.enp0s25 and net.wlp3s0 symlinks I get:

# rc-update show

```
       NetworkManager |      default                           

                acpid |      default                           

            alsasound | boot                                   

               binfmt | boot                                   

             bootmisc | boot                                   

           consolekit |      default                                                                                 

                cupsd |      default                           

                 dbus |      default                           

                devfs |                                 sysinit

                dmesg |                                 sysinit

                 fsck | boot                                   

             hostname | boot                                   

              hwclock | boot                                   

              keymaps | boot                                   

            killprocs |                        shutdown        

    kmod-static-nodes |                                 sysinit

                local |      default nonetwork                 

           localmount | boot                                   

             loopback | boot                                   

              modules | boot                                   

             mount-ro |                        shutdown        

                 mtab | boot                                   

             netmount |      default                           

                 ntpd |      default                           

               procfs | boot                                   

                 root | boot                                   

            savecache |                        shutdown        

                 sshd |      default                           

                 swap | boot                                   

               sysctl | boot                                   

                sysfs |                                 sysinit

            syslog-ng |      default                           

         termencoding | boot                                   

         tmpfiles.dev |                                 sysinit

       tmpfiles.setup | boot                                   

                 udev |                                 sysinit

              urandom | boot                                   

                  xdm |      default    
```

# rc-status

```
Runlevel: default

 dbus                                                                         [  started  ]

 syslog-ng                                                                    [  started  ]

 acpid                                                                        [  started  ]

 NetworkManager                                                               [  started  ]

 ntpd                                                                         [  started  ]

 cupsd                                                                        [  started  ]

 netmount                                                                     [  started  ]

 consolekit                                                                   [  started  ]

 xdm                                                                          [  started  ]

 sshd                                                                         [  started  ]

 local                                                                        [  started  ]

Dynamic Runlevel: hotplugged

 net.wlp3s0                                                                   [  stopped  ]

 net.enp0s25                                                                  [ inactive  ]

Dynamic Runlevel: needed/wanted

 modules-load                                                                 [  started  ]

 xdm-setup                                                                    [  started  ]

```

and when I do # rc-update del net.wlp3s0 and # rc-update del net.enp0s25 I get:

```

# rc-update del net.wlp3s0

 * rc-update: service `net.wlp3s0' is not in the runlevel `default'

# rc-update del net.enp0s25 

 * rc-update: service `net.enp0s25' is not in the runlevel `default'

```

net.wlp3s0    and net.enp0s25  seem to be in a Dynamic Runlevel: hotplugged. Do I have my rc.conf wrongly configured? I see in /etc/rc.conf

```
# This allows all services to be hotplugged

rc_hotplug="*"
```

Is this causing parts of my problem?

Now removing the symlinks.

```
rm -iv /etc/init.d/net.enp0s25

rm: remove symbolic link '/etc/init.d/net.enp0s25'? y

removed '/etc/init.d/net.enp0s25'

phils_x1 philip # rm -iv /etc/init.d/net.wlp3s0 

rm: remove symbolic link '/etc/init.d/net.wlp3s0'? y

removed '/etc/init.d/net.wlp3s0'
```

Reboot and: Error messages and Warnings are gone in the startup sequence! And WiFi reconnects automatically to a previously visited network. Nice. 

#rc-status now says:

```
Runlevel: default

 dbus                                                                                  [  started  ]

 syslog-ng                                                                             [  started  ]

 acpid                                                                                 [  started  ]

 NetworkManager                                                                        [  started  ]

 ntpd                                                                                  [  stopped  ]

 cupsd                                                                                 [  started  ]

 netmount                                                                              [  started  ]

 consolekit                                                                            [  started  ]

 xdm                                                                                   [  started  ]

 sshd                                                                                  [  stopped  ]

 local                                                                                 [  stopped  ]

Dynamic Runlevel: hotplugged

Dynamic Runlevel: needed/wanted

 modules-load                                                                          [  started  ]

 xdm-setup                                                                             [  started  ]

Dynamic Runlevel: manual
```

and

# rc-update show

```
       NetworkManager |      default                           

                acpid |      default                           

            alsasound | boot                                   

               binfmt | boot                                   

             bootmisc | boot                                   

           consolekit |      default                           

                cupsd |      default                           

                 dbus |      default                           

                devfs |                                 sysinit

                dmesg |                                 sysinit

                 fsck | boot                                   

             hostname | boot                                   

              hwclock | boot                                   

              keymaps | boot                                   

            killprocs |                        shutdown        

    kmod-static-nodes |                                 sysinit

                local |      default nonetwork                 

           localmount | boot                                   

             loopback | boot                                   

              modules | boot                                   

             mount-ro |                        shutdown        

                 mtab | boot                                   

             netmount |      default                           

                 ntpd |      default                           

               procfs | boot                                   

                 root | boot                                   

            savecache |                        shutdown        

                 sshd |      default                           

                 swap | boot                                   

               sysctl | boot                                   

                sysfs |                                 sysinit

            syslog-ng |      default                           

         termencoding | boot                                   

         tmpfiles.dev |                                 sysinit

       tmpfiles.setup | boot                                   

                 udev |                                 sysinit

              urandom | boot                                   

                  xdm |      default
```

Now a last question:

Can I have several network{  } entries in wpa_supplicant, for example one that "takes care" of WPA enabled access points and one that auto-connects to any unsecured network?  Like so

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

ap_scan=1

update_config=1

network={

        ssid="YourSSID"

        psk="your-secret-key"

        scan_ssid=1

        proto=RSN

        key_mgmt=WPA-PSK

        group=CCMP TKIP

        pairwise=CCMP TKIP

        priority=5

}

network={

        key_mgmt=NONE

        priority=-999

}
```

Or is only one entry of network{ } allowed?

And finally a comment:

It is unfortunate that there are a number of different references with instructions for the WiFi configuration:

https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Networking

https://wiki.gentoo.org/wiki/Handbook:AMD64/Networking/Wireless

https://wiki.gentoo.org/wiki/Wifi

https://wiki.gentoo.org/wiki/NetworkManager

https://wiki.gentoo.org/wiki/Network_management

https://wiki.gentoo.org/wiki/Wpa_supplicant

https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD

and that they are not all consistent. It would be good if the ones that are less valid would be romoved.

----------

## eccerr0r

Actually, NetworkManager handles your wpa_supplicant for you - you don't need to muck with wpa_supplicant config files at all.   But when not using NM, yes, wpa_supplicant does support multiple networks by adding multiple entries.

Hmm.  I have not experimented much with automatic configuration.  For me, most things are done manually.  I might have to run a fresh stage 3, as the behavior you're seeing doesn't seem to exist in my older installations.  Yes, rc_hotplug="*" is probably causing the problem you're seeing.  You should try rc_hotplug="!net*" to disable network autoconfig.

And yes, the documentation can be confusing if you're not sure what the options are - and it sort of requires you to use both if you eventually want to use NM.  My take on how to install Gentoo:

1. During initial bootstrap/install, you have to follow the original OpenRC "manual" configuration with wpa_supplicant config if you don't have Ethernet to download the Stage 3 install.

2.  However once you get into the chroot you have to take a step back and make a decision:

a) If your machine is fairly static, doesn't move much - or you like su root and mucking with the wifi config that way - you can continue to use the "manual" configuration and repeat the steps done in step 1.

b) if you want dynamic configuration via GUI you have a choice (but not really that much of one)...

If you're using a simple windowmanager you could optionally use wicd and configure you network as in step a.

If you're using a desktop environment that supports nm-applet you would install NetworkManager.

Since you're in a chroot you're using the net config in step 1, and would continue to do the install with the already configured network, as you need to download packages.

3.  When you're done with the chroot and boot onto your real root disk, now NetworkManager or OpenRC manual config will take effect.  Chances are, OpenRC should start up fine.  NetworkManager will require you to boot into the GUI and make configuration (or use the nmcli tool) so that your network comes up.

----------

## necktwi

I'm facing similar problem with RTL8188CUS.

```
# rc-service net.wlp0s29f7u4 start

* Bringing up interface wlp0s29f7u4

*   Starting wpa_supplicant on wlp0s29f7u4

Successfully initialized wpa_supplicant

*   Starting wpa_cli on wlp0s29f7u4

Failed to connect to non-global ctrl_ifname: wlp0s29f7u4 error: No such file or directory

*   start-stop-daemon: failed to start `/usr/bin/wpa_cli`

*   ERROR: net.wlp0s29f7u4 failed to start

```

/etc/wpa_supplicant/wpa_supplicant.conf

```
country=GB

ctrl_interface=/var/run/wpa_supplicant GROUP=wheel

update_config=1

network={

   ssid="mywifi"

   psk="wifipsk"

   scan_ssid=1

   proto=RSN

   key_mgmt=WPA-PSK

   pairwise=CCMP TKIP

   group=CCMP TKIP

   priority=1

}

```

/etc/conf.d/net

```
modules_wlp0s29f7u4="wpa_supplicant"

config_wlp0s29f7u4="dhcp"
```

----------

## charles17

 *necktwi wrote:*   

> I'm facing similar problem with RTL8188CUS.
> 
> ```
> # rc-service net.wlp0s29f7u4 start
> 
> ...

 

Are you having wlp0s29f7u4 at all in your output of ls -al /sys/class/net?

----------

## necktwi

yes, I do have /sys/class/net/wlp0s29f7u4.

----------

