WIFI
Connect to Wi-Fi
Switch to superuser mode:
sudo suScan for available Wi-Fi networks:
nmcli dev wifiConnect 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"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.
root@linaro-alip:/home/linaro# nmcli dev wifi connect test password 123456789
Device 'wlan0' successfully activated with 'bd88cdf5-2c04-406a-b4b6-1caaa0b1bf6c'.
root@linaro-alip:/home/linaro#
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:
- If the index number of an onboard device provided by Firmware or BIOS is available, it is used for naming, for example, eno1.
- 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.
- If the hardware interface's physical or location information is available, it is used for naming, for example, enp2s0.
- If the network interface's MAC address is available, it is used for naming, for example, enx525400d5e0fb.
- 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:
Interface Type: The naming uses the prefix "wl" to indicate a wireless network interface.
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.
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
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:ffCreate 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"Restart the device:
sudo rebootVerify 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.
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 changesCommon Commands
Command Function nmcli n Display if NetworkManager is controlling the network settings nmcli n on Set NetworkManager to take control of the network nmcli n off Disable NetworkManager's control over the network nmcli c status View brief information about connections nmcli c show View detailed information about connections nmcli c up/down ifname Start/stop the specified connection (ifname refers to the network interface) nmcli c show(s) ifname View detailed information about the connection on the specified network interface (ifname) nmcli c delete(de) wlan0 Delete the specified connection nmcli d status Display the status of all network interface devices nmcli d show View detailed information about devices nmcli d sh wlan0 Display detailed information about a specific device (wlan0) nmcli d connect(c) wlan0 Connect to the device nmcli d disconnect(c) wlan0 Disconnect the device - Here, "c" is an abbreviation for "connection," and "d" is an abbreviation for "device."
3.1 Using nmcli to change the hostname.
Check the current hostname:
linaro@linaro-alip:~$ sudo nmcli general hostname
linaro-alipSet a new hostname and restart the development board:
linaro@linaro-alip:~$ sudo nmcli general hostname luckfox
linaro@linaro-alip:~$ sudo rbootIf you encounter "sudo: unable to resolve host luckfox: Name or service not known," simply modify the hostname in /etc/hosts.
linaro@luckfox:~$ sudo vim /etc/hosts
#Simply change the hostname after 127.0.1.1 to "luckfox".
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 luckfox
3.2 Changing Hostname Using hostnamectl
View the current hostname:
linaro@linaro-alip:~$ sudo hostnamectl status --static
linaro-alipSet a new hostname and restart the development board:
linaro@linaro-alip:~$ sudo nmcli hostnamectl set-hostname luckfox
linaro@linaro-alip:~$ sudo rboot
3.3 Configuring Wireless Network with Static IP (nmcli)
View the IP address and default gateway of the device:
linaro@linaro-alip:~$ sudo ip route list
default via 192.168.11.1 dev eth0 proto dhcp metric 100
default via 192.168.11.1 dev wlan0 proto dhcp metric 600
192.168.8.0/22 dev eth0 proto kernel scope link src 192.168.10.63 metric 100
192.168.8.0/22 dev wlan0 proto kernel scope link src 192.168.10.69 metric 600List all the configured network connections and their respective properties.
linaro@linaro-alip:~$ sudo nmcli c show
NAME UUID TYPE DEVICE
JSBPI-5G 2d54e176-7559-49c8-bc90-1e5e2058a523 wifi wlan0
luckfox 2b38ada1-8c51-3b21-bdba-59f85ad1a14c ethernet eth0Set static IPv4 address, netmask, default gateway, and DNS servers:
sudo nmcli connection modify JSBPI-5G ipv4.address 192.168.10.79/24 # Set IP address and subnet mask
sudo nmcli connection modify JSBPI-5G ipv4.method manual # Set IP address and subnet mask
sudo nmcli connection modify JSBPI-5G ipv4.gateway 192.168.11.1 # Set default gateway
sudo nmcli connection modify JSBPI-5G ipv4.dns 114.114.114.114,8.8.8.8 # Set default gateway
sudo nmcli connection modify JSBPI-5G ipv6.method ignore # Disable IPv6
sudo nmcli connection modify JSBPI-5G connection.autoconnect yes
3.4Configuring Wireless Network with Static IP (nmtui)
You can use the arrow keys for navigation, press Enter to select an option, press Esc to cancel and go back, and use Space to choose a predefined option.
If you don't know the network device name to use in the connection, display the available devices:
linaro@linaro-alip:~$ sudo nmcli device status
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected Wired connection 1
wlan0 wifi disconnected --
lo loopback unmanaged --Launch nmtui:
sudo nmtuiSelect "Edit a connection" and press Enter.

Press the "Add" button.

Choose
Wi-Fifrom the list of network types, then press Enter.

Enter a name for the NetworkManager configuration file to easily identify the purpose of the configuration set.
Enter the network device name in the "Device" field.
Enter the name of the Wi-Fi network (Service Set Identifier - SSID) in the "SSID" field.
Set the Mode to the default value "Client."
Select "Security," press Enter, and then choose the authentication type for the network from the list.
Fill in the password for the wireless network.
If the Wi-Fi network requires a static IP address:
Press the "Automatic" button next to the protocol and then select "Manual" from the displayed list.
Press the "Show" button next to the protocol you want to configure to display additional fields and fill them in.
Enter the static IPv4 address, netmask, default gateway, and DNS servers.
Press the "OK" button to create and automatically activate the new connection.

Press the "Back" button to return to the main menu.
Select "Quit," then press Enter to close the
nmtuiapplication.