Skip to main content

WIFI

Connect to Wi-Fi​

TIP

First, make sure the antenna is properly connected to the development board; otherwise, it will be unable to scan for or connect to any Wi-Fi networks.

  1. Switch to superuser mode:

    sudo su
  2. Scan for available Wi-Fi networks:

    nmcli dev wifi
  3. Connect to a Wi-Fi network (replace "wifi_name" and "wifi_password" with your actual Wi-Fi SSID and password):

    nmcli dev wifi connect "wifi_name" password "wifi_password"
  4. If you see "successfully," it means the wireless network is connected successfully. The board will automatically connect to your specified Wi-Fi network on the next boot.

    nmcli dev wifi connect Luckfox-5G password luckfox12345

    root@aura:/home/aura# nmcli dev wifi connect Luckfox-5G password luckfox12345
    Device 'wlan0' successfully activated with 'eb3c1765-e312-484c-b71b-740c5b988c34'.

1. Linux Network Interface Naming​

In Linux distributions, Debian adopts the "Predictable Network Interface Names" scheme for naming network interfaces. This naming scheme aims to provide a consistent and predictable way of identifying and referencing network interfaces in the system, replacing the traditional irregular naming approach. It determines the names based on interface properties, hardware location, and other identifiers. According to the "Predictable Network Interface Names" scheme, the naming strategy for network interfaces includes the following:

  1. If the index number of an onboard device provided by Firmware or BIOS is available, it is used for naming, for example, eno1.
  2. If the index number of a PCI-E expansion slot provided by Firmware or BIOS is available, it is used for naming, for example, ens1.
  3. If the hardware interface's physical or location information is available, it is used for naming, for example, enp2s0.
  4. If the network interface's MAC address is available, it is used for naming, for example, enx525400d5e0fb.
  5. Traditional kernel-native naming, for example, eth0.

Consistent Network Device Naming is a specification used for wireless network interface naming in Linux. It aims to provide a consistent, predictable, and stable way of naming interfaces to reduce potential interface name changes during system reboots or hardware changes. In the consistent network device naming specification, the naming of wireless network interfaces typically includes the following information:

  1. Interface Type: The naming uses the prefix "wl" to indicate a wireless network interface.

  2. Device Physical Location or Topology: A numeric identifier, such as "0," is used to represent the position or sequence of the wireless network interface in the system. By default, the first detected wireless network interface will be named "wlan0," the second one "wlan1," and so on.

  3. Interface Bus and Device Physical Location: A series of characters and numbers are used to represent the bus and physical location of the interface. The following characters and numbers have specific meanings:

    • w: Represents a wireless network interface.
    • l: Represents a network device in the kernel (Linux).
    • p: Represents the PCI bus.
    • s: Represents the slot.
    • Number: Represents the bus and slot number.

    For example, an interface named "wlp3s0" indicates a wireless network interface connected to the third slot of the PCI bus.

2. Using udev rules to assign user-defined network interface names​

  1. Display all network interfaces and their MAC addresses:

    linaro@linaro-alip:~$ sudo ip link list
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 1a:7a:d7:64:5d:56 brd ff:ff:ff:ff:ff:ff
    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DORMANT group default qlen 1000
    link/ether b8:2d:28:43:ad:b0 brd ff:ff:ff:ff:ff:ff
  2. Create a file named /etc/udev/rules.d/70-custom-ifnames.rules with the following content:

    SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="1a:7a:d7:64:5d:56",ATTR{type}=="1",NAME="RJ-45"
    SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="b8:2d:28:43:ad:b0",ATTR{type}=="1",NAME="WIFI"
  3. Restart the device:

    sudo reboot
  4. Verify if the interface names for each MAC address match the values set in the NAME parameter of the rules file:

    linaro@linaro-alip:~$ sudo ip link show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: RJ-45: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 1a:7a:d7:64:5d:56 brd ff:ff:ff:ff:ff:ff
    3: WIFI: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DORMANT group default qlen 1000
    link/ether b8:2d:28:43:ad:b0 brd ff:ff:ff:ff:ff:ff

3. Network Manager Introduction​

In the previous tutorial, we learned how to connect to WiFi using nmcli. In this section, we will provide a detailed overview of nmcli and its usage.

Network Manager Command-Line Interface (nmcli) is a command-line tool used to manage network connections on Linux and Unix systems. It serves as the command-line frontend for Network Manager, allowing users to configure and manage networks through the terminal or shell scripts. nmcli can be used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display the status of network devices.

  1. Use the "--help" option to view the composition of nmcli commands:

    linaro@linaro-alip:~$ nmcli --help
    Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

    OPTIONS
    -o[verview] overview mode (hide default values)
    -t[erse] terse output
    -p[retty] pretty output
    -m[ode] tabular|multiline output mode
    -c[olors] auto|yes|no whether to use colors in output
    -f[ields] <field1,field2,...>|all|common specify fields to output
    -g[et-values] <field1,field2,...>|all|common shortcut for -m tabular -t -f
    -e[scape] yes|no escape columns separators in values
    -a[sk] ask for missing parameters
    -s[how-secrets] allow displaying passwords
    -w[ait] <seconds> set timeout waiting for finishing operations
    -v[ersion] show program version
    -h[elp] print this help

    OBJECT
    g[eneral] NetworkManager's general status and operations
    n[etworking] overall networking control
    r[adio] NetworkManager radio switches
    c[onnection] NetworkManager's connections
    d[evice] devices managed by NetworkManager
    a[gent] NetworkManager secret agent or polkit agent
    m[onitor] monitor NetworkManager changes
  2. Common Commands

    CommandFunction
    nmcli nDisplay if NetworkManager is controlling the network settings
    nmcli n onSet NetworkManager to take control of the network
    nmcli n offDisable NetworkManager's control over the network
    nmcli c statusView brief information about connections
    nmcli c showView detailed information about connections
    nmcli c up/down ifnameStart/stop the specified connection (ifname refers to the network interface)
    nmcli c show(s) ifnameView detailed information about the connection on the specified network interface (ifname)
    nmcli c delete(de) wlan0Delete the specified connection
    nmcli d statusDisplay the status of all network interface devices
    nmcli d showView detailed information about devices
    nmcli d sh wlan0Display detailed information about a specific device (wlan0)
    nmcli d connect(c) wlan0Connect to the device
    nmcli d disconnect(c) wlan0Disconnect the device
    • Here, "c" is an abbreviation for "connection," and "d" is an abbreviation for "device."