NetworkManager will not autoconnect to wireless if it is unavailable at creation time

cim

As part of an automated build process for Ubuntu 16.04 servers, I use nmcli to create network profiles, including wireless. This is on headless systems without window manager FWIW.

I have noticed that when I create a profile and activate it, if the access point (AP) is not there at activation it will never auto-connect, regardless if it is available subsequently.

I've tried to narrow down the cause of the problem and believe it might be something to do with dbus registration.

Profile creation:

sudo nmcli con add con-name "aNetwork" ifname wlp2s0 type wifi ssid "aNetwork"
sudo nmcli con modify "aNetwork" wifi-sec.key-mgmt wpa-psk
sudo nmcli con modify "aNetwork" wifi-sec.psk aPassword
sudo nmcli con up id "aNetwork"

From syslog, it seems it adds it correctly and sets it to scanning:

ug 12 08:55:06 bacer-104 NetworkManager[585]: <info>  [1565600106.4111] Config: added 'ssid' value 'aNetwork'
Aug 12 08:55:06 bacer-104 NetworkManager[585]: <info>  [1565600106.4111] Config: added 'scan_ssid' value '1'
Aug 12 08:55:06 bacer-104 NetworkManager[585]: <info>  [1565600106.4112] Config: added 'key_mgmt' value 'WPA-PSK'
Aug 12 08:55:06 bacer-104 NetworkManager[585]: <info>  [1565600106.4112] Config: added 'psk' value '<omitted>'
Aug 12 08:55:06 bacer-104 NetworkManager[585]: <info>  [1565600106.4128] sup-iface[0x1b0ff90,wlp2s0]: config: set interface ap_scan to 1

However after I make the AP visible, it never scans/connects, but when the connection is activated when the ESSID was present at creation, I get the following entry:

NetworkManager[489]: <debug> [1565287017.8330] device[0x1fb95f0] (wlp2s0): add_pending_action (3): 'scan'

But when the connection is activated *and the ESSID was not present at creation I get this:

NetworkManager[489]: <debug> [1565287064.3891] device[0x1fb95f0] (wlp2s0): add_pending_action (1): 'scan'
NetworkManager[489]: <debug> [1565287065.4580] device[0x1fb95f0] (wlp2s0): remove_pending_action (0): 'scan'

The contents of /etc/NetworkManager/system-connection/aNetwork are:

[connection]
id=aNetwork
uuid=6f24046b-b265-46d5-b89f-59ec802ce0af
type=wifi
interface-name=wlp2s0
permissions=
secondaries=

[wifi]
mac-address-blacklist=
mac-address-randomization=0
seen-bssids=
ssid=aNetwork

[wifi-security]
group=
key-mgmt=wpa-psk
pairwise=
proto=
psk=aPassword

[ipv4]
dns-search=
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

I have diffed the contents between profiles created where theESSID are both present and absent and there is no difference.

Looking at the output of nmcli con show aNetwork between the two shows a big difference:

  1. The output when disconnected, no ESSID at creation/activation is:

    connection.id:                          aNetwork
    connection.uuid:                        9dfacadb-f52a-453b-b6f1-2fbae6426d79
    connection.interface-name:              wlp2s0
    connection.type:                        802-11-wireless
    connection.autoconnect:                 yes
    connection.autoconnect-priority:        0
    connection.timestamp:                   0
    connection.read-only:                   no
    connection.permissions:
    connection.zone:                        --
    connection.master:                      --
    connection.slave-type:                  --
    connection.autoconnect-slaves:          -1 (default)
    connection.secondaries:
    connection.gateway-ping-timeout:        0
    connection.metered:                     unknown
    connection.lldp:                        -1 (default)
    802-11-wireless.ssid:                   aNetwork
    802-11-wireless.mode:                   --
    802-11-wireless.band:                   --
    802-11-wireless.channel:                0
    802-11-wireless.bssid:                  --
    802-11-wireless.rate:                   0
    802-11-wireless.tx-power:               0
    802-11-wireless.mac-address:            --
    802-11-wireless.cloned-mac-address:     --
    802-11-wireless.mac-address-blacklist:
    802-11-wireless.mac-address-randomization:default
    802-11-wireless.mtu:                    auto
    802-11-wireless.seen-bssids:
    802-11-wireless.hidden:                 no
    802-11-wireless.powersave:              default (0)
    802-11-wireless-security.key-mgmt:      wpa-psk
    802-11-wireless-security.wep-tx-keyidx: 0
    802-11-wireless-security.auth-alg:      --
    802-11-wireless-security.proto:
    802-11-wireless-security.pairwise:
    802-11-wireless-security.group:
    802-11-wireless-security.leap-username: --
    802-11-wireless-security.wep-key0:      <hidden>
    802-11-wireless-security.wep-key1:      <hidden>
    802-11-wireless-security.wep-key2:      <hidden>
    802-11-wireless-security.wep-key3:      <hidden>
    802-11-wireless-security.wep-key-flags: 0 (none)
    802-11-wireless-security.wep-key-type:  0 (unknown)
    802-11-wireless-security.psk:           <hidden>
    802-11-wireless-security.psk-flags:     0 (none)
    802-11-wireless-security.leap-password: <hidden>
    802-11-wireless-security.leap-password-flags:0 (none)
    ipv4.method:                            auto
    ipv4.dns:
    ipv4.dns-search:
    ipv4.dns-options:                       (default)
    ipv4.dns-priority:                      0
    ipv4.addresses:
    ipv4.gateway:                           --
    ipv4.routes:
    ipv4.route-metric:                      -1
    ipv4.ignore-auto-routes:                no
    ipv4.ignore-auto-dns:                   no
    ipv4.dhcp-client-id:                    --
    ipv4.dhcp-timeout:                      0
    ipv4.dhcp-send-hostname:                yes
    ipv4.dhcp-hostname:                     --
    ipv4.dhcp-fqdn:                         --
    ipv4.never-default:                     no
    ipv4.may-fail:                          yes
    ipv4.dad-timeout:                       -1 (default)
    ipv6.method:                            auto
    ipv6.dns:
    ipv6.dns-search:
    ipv6.dns-options:                       (default)
    ipv6.dns-priority:                      0
    ipv6.addresses:
    ipv6.gateway:                           --
    ipv6.routes:
    ipv6.route-metric:                      -1
    ipv6.ignore-auto-routes:                no
    ipv6.ignore-auto-dns:                   no
    ipv6.never-default:                     no
    ipv6.may-fail:                          yes
    ipv6.ip6-privacy:                       -1 (unknown)
    ipv6.addr-gen-mode:                     stable-privacy
    ipv6.dhcp-send-hostname:                yes
    ipv6.dhcp-hostname:                     --
    
  2. The output when disconnected, and the ESSID is present at creation/activation is:

    connection.id:                          aNetwork
    connection.uuid:                        10d2d80a-4f64-4466-9e4e-6190e4628d45
    connection.interface-name:              wlp2s0
    connection.type:                        802-11-wireless
    connection.autoconnect:                 yes
    connection.autoconnect-priority:        0
    connection.timestamp:                   1565600053
    connection.read-only:                   no
    connection.permissions:
    connection.zone:                        --
    connection.master:                      --
    connection.slave-type:                  --
    connection.autoconnect-slaves:          -1 (default)
    connection.secondaries:
    connection.gateway-ping-timeout:        0
    connection.metered:                     unknown
    connection.lldp:                        -1 (default)
    802-11-wireless.ssid:                   aNetwork
    802-11-wireless.mode:                   --
    802-11-wireless.band:                   --
    802-11-wireless.channel:                0
    802-11-wireless.bssid:                  --
    802-11-wireless.rate:                   0
    802-11-wireless.tx-power:               0
    802-11-wireless.mac-address:            --
    802-11-wireless.cloned-mac-address:     --
    802-11-wireless.mac-address-blacklist:
    802-11-wireless.mac-address-randomization:default
    802-11-wireless.mtu:                    auto
    802-11-wireless.seen-bssids:            9A:9B:CB:54:C4:5A
    802-11-wireless.hidden:                 no
    802-11-wireless.powersave:              default (0)
    802-11-wireless-security.key-mgmt:      wpa-psk
    802-11-wireless-security.wep-tx-keyidx: 0
    802-11-wireless-security.auth-alg:      --
    802-11-wireless-security.proto:
    802-11-wireless-security.pairwise:
    802-11-wireless-security.group:
    802-11-wireless-security.leap-username: --
    802-11-wireless-security.wep-key0:      <hidden>
    802-11-wireless-security.wep-key1:      <hidden>
    802-11-wireless-security.wep-key2:      <hidden>
    802-11-wireless-security.wep-key3:      <hidden>
    802-11-wireless-security.wep-key-flags: 0 (none)
    802-11-wireless-security.wep-key-type:  0 (unknown)
    802-11-wireless-security.psk:           <hidden>
    802-11-wireless-security.psk-flags:     0 (none)
    802-11-wireless-security.leap-password: <hidden>
    802-11-wireless-security.leap-password-flags:0 (none)
    ipv4.method:                            auto
    ipv4.dns:
    ipv4.dns-search:
    ipv4.dns-options:                       (default)
    ipv4.dns-priority:                      0
    ipv4.addresses:
    ipv4.gateway:                           --
    ipv4.routes:
    ipv4.route-metric:                      -1
    ipv4.ignore-auto-routes:                no
    ipv4.ignore-auto-dns:                   no
    ipv4.dhcp-client-id:                    --
    ipv4.dhcp-timeout:                      0
    ipv4.dhcp-send-hostname:                yes
    ipv4.dhcp-hostname:                     --
    ipv4.dhcp-fqdn:                         --
    ipv4.never-default:                     no
    ipv4.may-fail:                          yes
    ipv4.dad-timeout:                       -1 (default)
    ipv6.method:                            auto
    ipv6.dns:
    ipv6.dns-search:
    ipv6.dns-options:                       (default)
    ipv6.dns-priority:                       0
    ipv6.addresses:
    ipv6.gateway:                            --
    ipv6.routes:
    ipv6.route-metric:                       -1
    ipv6.ignore-auto-routes:                 no
    ipv6.ignore-auto-dns:                    no
    ipv6.never-default:                      no
    ipv6.may-fail:                           yes
    ipv6.ip6-privacy:                        -1 (unknown)
    ipv6.addr-gen-mode:                      stable-privacy
    ipv6.dhcp-send-hostname:                 yes
    ipv6.dhcp-hostname:                      --
    GENERAL.NAME:                            aNetwork
    GENERAL.UUID:                            10d2d80a-4f64-4466-9e4e-6190e4628d45
    GENERAL.DEVICES:                         wlp2s0
    GENERAL.STATE:                           activated
    GENERAL.DEFAULT:                         no
    GENERAL.DEFAULT6:                        no
    GENERAL.VPN:                             no
    GENERAL.ZONE:                            --
    GENERAL.DBUS-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/15
    GENERAL.CON-PATH:                        /org/freedesktop/NetworkManager/Settings/11
    GENERAL.SPEC-OBJECT:                     /org/freedesktop/NetworkManager/AccessPoint/12
    GENERAL.MASTER-PATH:                     --
    IP4.ADDRESS[1]:                          192.168.179.29/24
    IP4.GATEWAY:                             192.168.179.1
    IP4.DNS[1]:                              192.168.179.1
    DHCP4.OPTION[1]:                         dhcp_rebinding_time = 18900
    DHCP4.OPTION[2]:                         requested_domain_search = 1
    DHCP4.OPTION[3]:                         requested_host_name = 1
    DHCP4.OPTION[4]:                         requested_time_offset = 1
    DHCP4.OPTION[5]:                         requested_domain_name = 1
    DHCP4.OPTION[6]:                         requested_rfc3442_classless_static_routes = 1
    DHCP4.OPTION[7]:                         requested_broadcast_address = 1
    DHCP4.OPTION[8]:                         requested_wpad = 1
    DHCP4.OPTION[9]:                         requested_netbios_scope = 1
    DHCP4.OPTION[10]:                        next_server = 192.168.179.1
    DHCP4.OPTION[11]:                        expiry = 1565621653
    DHCP4.OPTION[12]:                        requested_interface_mtu = 1
    DHCP4.OPTION[13]:                        requested_subnet_mask = 1
    DHCP4.OPTION[14]:                        routers = 192.168.179.1
    DHCP4.OPTION[15]:                        dhcp_message_type = 5
    DHCP4.OPTION[16]:                        ip_address = 192.168.179.29
    DHCP4.OPTION[17]:                        broadcast_address = 192.168.179.255
    DHCP4.OPTION[18]:                        requested_static_routes = 1
    DHCP4.OPTION[19]:                        dhcp_renewal_time = 10800
    DHCP4.OPTION[20]:                        requested_domain_name_servers = 1
    DHCP4.OPTION[21]:                        requested_ms_classless_static_routes = 1
    DHCP4.OPTION[22]:                        domain_name_servers = 192.168.179.1
    DHCP4.OPTION[23]:                        subnet_mask = 255.255.255.0
    DHCP4.OPTION[24]:                        dhcp_lease_time = 21600
    DHCP4.OPTION[25]:                        requested_ntp_servers = 1
    DHCP4.OPTION[26]:                        requested_netbios_name_servers = 1
    DHCP4.OPTION[27]:                        ntp_servers = 192.168.179.1
    DHCP4.OPTION[28]:                        network_number = 192.168.179.0
    DHCP4.OPTION[29]:                        requested_routers = 1
    DHCP4.OPTION[30]:                        dhcp_server_identifier = 192.168.179.1
    IP6.ADDRESS[1]:                          fd00::1:79ff:2a88:6b89:f5a3/64
    IP6.ADDRESS[2]:                          fd00::1:53f4:ea8b:a2c6:88bc/64
    IP6.ADDRESS[3]:                          fe80::42af:506a:16:1256/64
    IP6.GATEWAY:
    IP6.ROUTE[1]:                            dst = fd00:0:0:1::/64, nh = fe80::9a9b:cbff:fe54:c457, mt = 600
    IP6.DNS[1]:                              fd00::1:9a9b:cbff:fe54:c457
    DHCP6.OPTION[1]:                         requested_dhcp6_domain_search = 1
    DHCP6.OPTION[2]:                         dhcp6_name_servers = fd00::1:9a9b:cbff:fe54:c457
    DHCP6.OPTION[3]:                         dhcp6_server_id = 0:3:0:1:98:9b:cb:54:c4:57
    DHCP6.OPTION[4]:                         requested_dhcp6_client_id = 1
    DHCP6.OPTION[5]:                         requested_dhcp6_name_servers = 1
    DHCP6.OPTION[6]:                         dhcp6_client_id = 0:4:cd:4c:df:d9:4d:62:c6:97:e1:a2:ed:b7:68:6a:be:9c
    

Notice all the GENERAL. entries, including GENERAL.STATE Activated and entries for DBUS-PATH and CON-PATH so I'm lead to believe this is what is causing the connection to not auto-connect, but I don't really know where to go from here.

I need to:

  • be able to create the profile out of range of the network
  • have it auto-connect when it's in range.
  • use NetworkManager

How do i proceed from here?

dkc

I ran into the same issue and after trying to debug it for a while, I went on Network Manager IRC channel and asked them directly. For Wi-Fi networks, this is intentional, the restriction comes from this check:

https://github.com/NetworkManager/NetworkManager/blob/master/src/devices/wifi/nm-device-wifi.c#L999

Quoting the comments just above the check:

    /* Don't autoconnect to networks that have been tried at least once
     * but haven't been successful, since these are often accidental choices
     * from the menu and the user may not know the password.
     */

The reasoning is questionable but that's what it is. If you look at /var/lib/NetworkManager/timestamps, you'll see that for the network it never connected to the timestamp value is 0. As far as I know, there is no way to change this value from D-Bus/nmcli, so you'll have to edit the file and eventually restart NetworkManager (no idea if the file is run when changed or on a periodic basis).

In my case, we're building Network Manager for an embedded distribution and have a chance to patch it in the process, so I commented out the check and it auto-connects to networks it never connected to before.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Have to restart NetworkManager to get wifi autoconnect

From Dev

NetworkManager timeout and "ip-config-unavailable" on Ethernet

From Dev

NetworkManager doesn't see my wireless card

From Dev

NetworkManager doesn't see my wireless card

From Dev

Why is my wireless network no longer listed in NetworkManager

From Dev

wireless unavailable - 802.1x supplicant failed

From Dev

Workstation 9 Error: Connection activation failed: Device not managed by NetworkManager or unavailable

From Dev

NetworkManager controls my wireless card, but it can't find any networks?

From Dev

How can I make NetworkManager ignore my wireless card?

From Dev

How to programmatically get a list of wireless SSIDs in range from NetworkManager

From Dev

Fedora wireless: mac change every reboot (with NetworkManager disabled)

From Dev

VPN Autoconnect

From Dev

VPN Autoconnect

From Dev

Time of creation of a Github Fork

From Dev

Order by creation time in OpenEdge

From Dev

Sorting Directories by creation time

From Dev

Vtable and *_vptr creation time

From Dev

Kubernetes object creation time

From Dev

Time of creation of a Github Fork

From Dev

Vtable and *_vptr creation time

From Dev

Is ctime of find the creation time?

From Dev

Creation time anomaly

From Dev

Minimagick error: libgomp: Thread creation failed: Resource temporarily unavailable

From Dev

Minimagick error: libgomp: Thread creation failed: Resource temporarily unavailable

From Dev

Wireless backups with Time Machine without Time Capsule

From Dev

Some const char * are unavailable at compile time?

From Dev

Stop autorotation of UIViewController at creation time

From Dev

Preserve file creation time with Java

From Dev

Get file creation time with lua

Related Related

  1. 1

    Have to restart NetworkManager to get wifi autoconnect

  2. 2

    NetworkManager timeout and "ip-config-unavailable" on Ethernet

  3. 3

    NetworkManager doesn't see my wireless card

  4. 4

    NetworkManager doesn't see my wireless card

  5. 5

    Why is my wireless network no longer listed in NetworkManager

  6. 6

    wireless unavailable - 802.1x supplicant failed

  7. 7

    Workstation 9 Error: Connection activation failed: Device not managed by NetworkManager or unavailable

  8. 8

    NetworkManager controls my wireless card, but it can't find any networks?

  9. 9

    How can I make NetworkManager ignore my wireless card?

  10. 10

    How to programmatically get a list of wireless SSIDs in range from NetworkManager

  11. 11

    Fedora wireless: mac change every reboot (with NetworkManager disabled)

  12. 12

    VPN Autoconnect

  13. 13

    VPN Autoconnect

  14. 14

    Time of creation of a Github Fork

  15. 15

    Order by creation time in OpenEdge

  16. 16

    Sorting Directories by creation time

  17. 17

    Vtable and *_vptr creation time

  18. 18

    Kubernetes object creation time

  19. 19

    Time of creation of a Github Fork

  20. 20

    Vtable and *_vptr creation time

  21. 21

    Is ctime of find the creation time?

  22. 22

    Creation time anomaly

  23. 23

    Minimagick error: libgomp: Thread creation failed: Resource temporarily unavailable

  24. 24

    Minimagick error: libgomp: Thread creation failed: Resource temporarily unavailable

  25. 25

    Wireless backups with Time Machine without Time Capsule

  26. 26

    Some const char * are unavailable at compile time?

  27. 27

    Stop autorotation of UIViewController at creation time

  28. 28

    Preserve file creation time with Java

  29. 29

    Get file creation time with lua

HotTag

Archive