Skip to content

Managing wifi using connman

ConnMan is a command-line network manager designed for use with embedded devices and fast resolve times. It is modular through a plugin architecture, but has native DHCP and NTP support.

Enabling and disabling Wi-Fi

To check if Wi-Fi is enabled you can run

connmanctl technologies

and check for the line that says Powered: True/False.

To power the Wi-Fi on you can run

connmanctl enable wifi

or if you need to disable it you can run

connmanctl disable wifi

Connecting to an open access point

The commands in this section show how to run connmanctl in command mode.

To scan the network connmanctl accepts simple names called technologies. To scan for nearby Wi-Fi networks:

connmanctl scan wifi

To list the available networks found after a scan run (example output):

connmanctl services
MyNetwork               wifi_dc85de828967_68756773616d_managed_psk
OtherNET                wifi_dc85de828967_38303944616e69656c73_managed_psk
AnotherOne              wifi_dc85de828967_3257495245363836_managed_wep
FourthNetwork           wifi_dc85de828967_4d7572706879_managed_wep
AnOpenNetwork           wifi_dc85de828967_4d6568657272696e_managed_none

Every Wi-Fi network is identified by a name composed as

wifi_<hashlocal>_<hashremote>_managed_<encryption>

To connect to an open network, look for Wi-Fi networks ending with _managed_none:

connmanctl connect wifi_dc85de828967_4d6568657272696e_managed_none

Network names can be tab-completed

You should now be connected to the network. Check using ip addr or run

connmanctl state

Connecting to a protected access point

For protected access points you will need to provide some information to the ConnMan daemon, at the very least a password or a passphrase.

The commands in this section show how to run connmanctl in interactive mode, it is required for running the agent command. To start interactive mode simply type:

connmanctl

You then proceed almost as above, first scan for any Wi-Fi technologies:

scan wifi

To list services:

services
MyNetwork               wifi_dc85de828967_68756773616d_managed_psk
OtherNET                wifi_dc85de828967_38303944616e69656c73_managed_psk
AnotherOne              wifi_dc85de828967_3257495245363836_managed_wep
FourthNetwork           wifi_dc85de828967_4d7572706879_managed_wep
AnOpenNetwork           wifi_dc85de828967_4d6568657272696e_managed_none

Now you need to register the agent to handle user requests. The command is:

agent on

You now need to connect to one of the protected services.

To do this easily, just use tab completion for the wifi_ service.

If you were connecting to OtherNET in the example above you would type:

connect wifi_dc85de828967_38303944616e69656c73_managed_psk

The agent will then ask you to provide any information the daemon needs to complete the connection.

The information requested will vary depending on the type of network you are connecting to.

The agent will also print additional data about the information it needs as shown in the example below.

Agent RequestInput wifi_dc85de828967_38303944616e69656c73_managed_psk
  Passphrase = [ Type=psk, Requirement=mandatory ]
  Passphrase?

Provide the information requested, in this example the passphrase, and then type:

quit

If the information you provided is correct you should now be connected to the protected access point.

Static IP Address

To use static IP address, run the following command after establishing a successful connection to AP

config <service> --ipv4 manual <ip address> <netmask> <gateway>

Settings

Settings and profiles are automatically created for networks the user connects to often.

They contain fields for the passphrase, ESSID and other information.

Profile settings are stored in directories under /var/lib/connman/ by their service name.

To view all network profiles run this command from root shell:

cat /var/lib/connman/*/settings

Using Multiple Network Interfaces

When using Ethernet and Wi-Fi at the same time, create the following file to configure connman to connect both interfaces. Create /etc/connman/main.conf with:

PreferredTechnologies=wifi,ethernet
SingleConnectedTechnology=false