Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] How to get wifi connection at boot with systemd?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
urcindalo
l33t
l33t


Joined: 08 Feb 2005
Posts: 601
Location: Almeria, Spain

PostPosted: Wed Oct 16, 2019 5:21 pm    Post subject: [solved] How to get wifi connection at boot with systemd? Reply with quote

Hi and thanks for reading this. I'm sure this has had to be asked before, but I couldn't find any related thread.

I run a stable box with systemd, and after boot I login into KDE and then it automatically connects to my WiFi network. However, I'd like to get online through my wifi connection before logging into KDE, just in case I have to restart my box remotely.

After boot, but before login into KDE, I see this:
Code:
 $ systemctl status NetworkManager
■ NetworkManager.service - Network Manager
   Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-10-16 18:53:42 CEST; 1min 24s ago
     Docs: man:NetworkManager(8)
 Main PID: 420 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           └─420 /usr/sbin/NetworkManager --no-daemon

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7028] sup-iface[0x555978046000,wlan0]: wps: type pbc start...
oct 16 18:53:51 Urci NetworkManager[420]: <warn>  [1571244831.7034] device (wlan0): no secrets: No agents were available for this request.
oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7035] device (wlan0): state change: need-auth -> failed (reason 'no-secrets', sys-iface-state: 'managed')
oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7039] manager: NetworkManager state is now DISCONNECTED
oct 16 18:53:51 Urci NetworkManager[420]: <warn>  [1571244831.7042] device (wlan0): Activation: failed for connection 'Urcindalo_Plus'
oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7044] device (wlan0): state change: failed -> disconnected (reason 'none', sys-iface-state: 'managed')
oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7101] device (wlan0): set-hw-addr: set MAC address to F2:D9:22:F3:A6:59 (scanning)
oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7250] device (wlan0): supplicant interface state: disabled -> inactive
oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7255] device (p2p-dev-wlan0): supplicant management interface state: disabled -> inactive
oct 16 18:53:55 Urci NetworkManager[420]: <info>  [1571244835.4393] manager: startup complete


As you can see, it tries to connect to my WiFi network but fails.
I guess it is a matter of NetworkManager not finding the password. Am I right?

After I login into KDE, NetworkManager connects and:
Code:
$ systemctl status NetworkManager
● NetworkManager.service - Network Manager
   Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-10-16 18:53:42 CEST; 4min 7s ago
     Docs: man:NetworkManager(8)
 Main PID: 420 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           ├─ 420 /usr/sbin/NetworkManager --no-daemon
           └─2372 /sbin/dhcpcd -B -K -L -A -G -c /usr/libexec/nm-dhcp-helper -4 -h Urci wlan0

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4811] dhcp4 (wlan0):   nameserver '80.58.61.254'
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4811] dhcp4 (wlan0): state changed expire -> bound
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4825] device (wlan0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4834] device (wlan0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4836] device (wlan0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed>
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4842] manager: NetworkManager state is now CONNECTED_LOCAL
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.6809] manager: NetworkManager state is now CONNECTED_SITE
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.6811] policy: set 'Urcindalo_Plus' (wlan0) as default for IPv4 routing and DNS
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.9821] device (wlan0): Activation: successful, device activated.
oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.9826] manager: NetworkManager state is now CONNECTED_GLOBAL


So, what could I do so that Wifi connects at boot, before logging into KDE?


Last edited by urcindalo on Fri Oct 18, 2019 7:10 am; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7414
Location: almost Mile High in the USA

PostPosted: Wed Oct 16, 2019 9:13 pm    Post subject: Reply with quote

For NetworkManager, go into nm-applet and edit connections. Then in the General options, mark the connections that are acceptable for connecting upon boot both as "Connect Automatically" and "All users may connect to this network" (apparently root counts as a user on boot that NetworkManager will honor as any other user. This will also copy the authentication keys into the system for any user, including root, to use.)

It should now try to connect when NetworkManager starts, at least this seems to work on both my OpenRC and systemd NetworkManager boxes.

I've not needed to edit any of the NetworkManager saved files to hack in the authentication keys.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
urcindalo
l33t
l33t


Joined: 08 Feb 2005
Posts: 601
Location: Almeria, Spain

PostPosted: Wed Oct 16, 2019 9:20 pm    Post subject: Reply with quote

eccerr0r wrote:
For NetworkManager, go into nm-applet and edit connections. Then in the General options, mark the connections that are acceptable for connecting upon boot both as "Connect Automatically" and "All users may connect to this network" (apparently root counts as a user on boot that NetworkManager will honor as any other user. This will also copy the authentication keys into the system for any user, including root, to use.)


Thanks for your help. Both options were already marked.
There's a priority selection, currently at 0, just next to "Connect Automatically". Should I change this? What do control the possible values?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7414
Location: almost Mile High in the USA

PostPosted: Wed Oct 16, 2019 10:10 pm    Post subject: Reply with quote

Zero is fine for the priority. This is for if you have multiple possible wifi hotspots, it will choose based on priority if more than one can be authenticated.

Something's not synced up for you it seems. You might want to try disable each of the options, save it, and reenable them. Sometimes there's some state that doesn't get saved properly.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
GrandeGrabois
n00b
n00b


Joined: 16 Oct 2019
Posts: 12

PostPosted: Thu Oct 17, 2019 5:09 pm    Post subject: Reply with quote

Just a wild guess, but maybe you could try setting this connection directly with nmcli from the terminal. Perhaps there is something about KDE storing passwords via KWallet that makes it unaccessible during boot
Back to top
View user's profile Send private message
urcindalo
l33t
l33t


Joined: 08 Feb 2005
Posts: 601
Location: Almeria, Spain

PostPosted: Fri Oct 18, 2019 7:09 am    Post subject: Reply with quote

Thanks everyone for your suggestions.

eccerr0r wrote:
Something's not synced up for you it seems. You might want to try disable each of the options, save it, and reenable them. Sometimes there's some state that doesn't get saved properly.


I tried this, to no avail.

GrandeGrabois wrote:
Just a wild guess, but maybe you could try setting this connection directly with nmcli from the terminal. Perhaps there is something about KDE storing passwords via KWallet that makes it unaccessible during boot


I had already tried this, before posting here.

However, I've solved it. To make a long story short, my .nmconnection file in /etc/NetworkManager/system-connections lacked the password info and the NetworkManager KDE widget was not storing it in that file. To have the password stored, I tried several ways (I didn't edit the file manually since I couldn't find the correct syntax). In the end, it seems that running nm-connection-editor as root made the trick, altough it constantly was telling me that dconf couldn't write the file. However, when I looked at /etc/NetworkManager/system-connections/MyWiFi.nmconnection, there it was:
Code:
[wifi-security]
key-mgmt=wpa-psk
psk=YoUrPaSsWoRd#1234


So, I guess it all lreduces to include the above lines in the corresponding .nmconnection file.
I hope this helps other people.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum