How to set up WiFi on Ubuntu Server

Modern server solutions increasingly require wireless connectivity, especially when deploying infrastructure in remote locations or temporary offices. Ubuntu Server It provides flexible tools for working with network interfaces, but Wi-Fi configuration here differs from the familiar desktop environment with a graphical interface. The lack of visual switches forces the administrator to delve deeper into network configuration processes.

Unlike desktop versions of the operating system, the server version often relies on Netplan or systemd-networkd for connection management. This ensures stability and predictability, which is critical for production environments. Proper configuration prevents connection interruptions and ensures automatic reconnection after a hardware reboot.

In this article, we'll take a detailed look at connecting to a wireless network using modern network management techniques. You'll learn how to check hardware compatibility, configure static IP addresses, and troubleshoot common driver issues. For most modern Wi-Fi adapters to work in access point or client mode on a server, it is often necessary to disable network management via NetworkManager in favor of Netplan.

Checking compatibility and preparing equipment

The first step should always be checking the presence of a wireless adapter and its visibility by the system. Many server motherboards do not have a built-in Wi-Fi module, so USB dongles or PCIe cards are often used. Make sure the device is detected by the Linux kernel and the appropriate driver is loaded.

For diagnostics, use the utility lspci for internal cards or lsusb For external devices. If the adapter appears in the list but doesn't work, you may need to install proprietary drivers or firmware files. Lack of drivers is the most common reason for initial setup failure.

Check the interface status using the command ip link. You should see the interface name, which usually starts with wlan or wlpIf the interface is in the state DOWN, it will need to be raised programmatically before starting the configuration.

  • 📡 Run the command lspci | grep -i network to search for PCIe adapters.
  • 🔌 Use lsusb, if your Wi-Fi module is connected via a USB port.
  • 👀 Make sure the interface is visible in the command output ip link show.
  • 🛠 Check for drivers via lshw -C network.

It's worth noting that some older adapters may not support operating modes required for server tasks, such as monitor mode or access point. Modern chips from Intel And Realtek, generally have better support in the Linux kernel.

Installing the required packages and utilities

A basic Ubuntu Server installation may not include all the necessary tools for working with wireless networks. Minimal builds often lack even a basic set of utilities for scanning the airwaves. Therefore, the first step is to update the repositories and install the missing components.

The main tool for working with Wi-Fi on the command line is the package iw or its older version iwconfig. To manage connections and the DHCP client, you may also need wpasupplicant, although modern versions of Netplan often do without it, using built-in functions.

⚠️ Warning: When installing new network packages on a remote server via SSH, there is a risk of connection loss if the network configuration is changed during the process. It is recommended to have physical access to the console or a backup connection (e.g., a 4G modem).

To install the required software, run the following commands in the terminal:

sudo apt update

sudo apt install netplan.io wpasupplicant iw

After installation, make sure that the services do not conflict with each other. For example, running simultaneously NetworkManager And Netplan This can lead to instability. It's preferable to use only one management tool on servers, and Netplan has been the de facto standard for Ubuntu since version 17.10.

Searching and selecting a wireless network

Before manually entering settings, you need to know the exact name of your network (SSID) and ensure the signal is stable. Scanning for available networks is performed using a previously installed utility. iwThis helps avoid errors in the network name, which is especially important for SSIDs with hidden characters or spaces.

It's important to note that the interface must be active for scanning to work, but it doesn't necessarily have to be connected. If the interface is blocked, use the command ip link set dev wlan0 up, replacing wlan0 with the name of your interface. After that, you can start the scan.

The scan command may take a few seconds as the adapter switches channels to search for beacon frames. The output will show a list of available networks, their frequency, signal strength, and the security standard used (WPA2/WPA3).

sudo iw dev wlan0 scan | grep SSID

Pay attention to signal strength. For server connections, where stability is essential, it's not recommended to use networks with a signal strength weaker than -70 dBm. A weak signal will result in packet retransmission and a drop in actual throughput.

  • 📶 Check the signal level: a value closer to 0 is better (for example, -40 is better than -80).
  • 🔒 Make sure your network uses the WPA2 or WPA3 secure protocol.
  • 📡 Remember the exact SSID name, including case.

If your network is hidden (Hidden SSID), it won't appear in the list during scanning. In this case, you'll need to manually enter the network name, making sure every character is correct. A single character error will prevent you from connecting.

Netplan configuration for WiFi connection

In modern versions of Ubuntu Server (20.04, 22.04, 24.04) the main configuration tool is Netplan. It uses YAML files located in the directory /etc/netplan/YAML syntax is indentation-sensitive, so be careful when editing the configuration.

First, let's create a backup copy of the existing configuration file, and then create a new one or edit the current one. The file name can be anything, but it must end in .yaml, For example, 01-wifi-config.yaml.

⚠️ Note: YAML syntax requires indentation (spaces), not tabs. Using tabs will cause parsing errors and network inoperability.

Open the file for editing:

sudo nano /etc/netplan/01-wifi-config.yaml

Add the following structure, replacing the data with your own:

network:

version: 2

renderer: networkd

wifis:

wlan0:

dhcp4: true

access-points:

"Name_of_your_SSID":

password: "Your_Password"

In this example dhcp4: true means that the IP address will be obtained automatically. If you need a static IP, the file structure will change. The parameter renderer: networkd indicates that a daemon is responsible for applying the settings systemd-networkd.

After making changes, you need to apply the configuration. Netplan will first check the file for syntax errors, and only if the check is successful will it apply the settings.

sudo netplan try

sudo netplan apply

Team netplan try This is useful because it temporarily applies the settings and waits for confirmation. If you lose the connection, the settings will be rolled back after 120 seconds, preventing the remote server from being blocked.

Setting up a static IP address

Servers often require a fixed IP address so that other network nodes can reliably access it. Unlike DHCP, a static IP address prevents the address from changing after a router reboot or lease expiration.

To configure a static address in Netplan, you need to disable DHCP and enter the addresses manually. You'll need to know the gateway (router) and DNS server addresses. Typically, the gateway is the first address in the subnet (e.g., 192.168.1.1).

Example configuration for static IP:

network:

version: 2

renderer: networkd

wifis:

wlan0:

dhcp4: no

addresses:

- 192.168.1.50/24

routes:

- to: default

via: 192.168.1.1

nameservers:

addresses: [8.8.8.8, 1.1.1.1]

Here 192.168.1.50/24 — this is your IP and subnet mask. Mask /24 equivalent to 255.255.255.0. Make sure the selected IP address is outside the range of your router's DHCP pool to avoid address conflicts.

  • 🔢 Please enter a valid static IP address in CIDR format (e.g. /24).
  • 🚪 Specify the default gateway for Internet access.
  • 🌐 Use reliable DNS, such as Google (8.8.8.8) or Cloudflare (1.1.1.1).

After changing the file, do not forget to apply the settings with the command sudo netplan applyCheck the result with the command ip addr show wlan0 - You should see the assigned static address.

Diagnostics and problem solving

Even with proper configuration, connection issues may still occur. These are most often related to drivers, incorrect passwords, or MAC address blocking on the router. The first step in troubleshooting should always be reviewing the logs.

System logs systemd contain detailed information about the connection process. Use the command journalctl to search for errors related to network services. This will help you understand at what stage the failure occurs.

sudo journalctl -u systemd-networkd -f

If you see authentication error messages, double-check the password in the YAML file. It's also worth checking if MAC address filtering is enabled on the access point. In this case, the server simply won't receive an IP address, even if the password is correct.

Another common issue is the Wi-Fi adapter's power-saving mode. Servers must operate 24/7, and the adapter's sleep mode is unacceptable. This can lead to intermittent connection drops.

Problem Possible cause Solution method
Interface not found Driver missing Install firmware-linux-nonfree
Authentication failed Incorrect password Check the layout and capitalization in YAML
No DHCP offers Blocking on the router Check the MAC filtering list
Intermittent connection Energy saving Disable power management

To disable power saving, you can create a configuration file for NetworkManager (if used) or use iw commands. However, when using pure Netplan And networkd, it is better to create a rule for udev or use driver settings.

⚠️ Note: Command line interfaces and configuration file names may change in new versions of Ubuntu. Always consult the official documentation for your specific distribution if the standard methods don't work.

📊 Which method of setting up Wi-Fi on a server do you prefer?
Via Netplan (YAML)
Via nmcli (NetworkManager)
Via /etc/network/interfaces
Wired connection only

☑️ Check before applying settings

Completed: 0 / 5
How to disable Wi-Fi power saving on Ubuntu Server?

To disable power saving, create the file /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf (if using NM) and set wifi.powersave = 2. For pure networkd, this is often solved by configuring the adapter itself via iw or disabling USB autosuspend in the BIOS/UEFI.

Frequently Asked Questions (FAQ)

Is it possible to use Ubuntu Server without a graphical shell to configure Wi-Fi?

Yes, absolutely. Ubuntu Server is designed from the ground up for command-line operation. All necessary configuration is accomplished through text-based configuration files and CLI utilities such as netplan, iw, and ip.

Why is my Wi-Fi adapter not visible in the system?

Most likely, your hardware is missing proprietary drivers or firmware. Check the adapter model using lsusb or lspci and find the appropriate package to install (often these are packages named firmware-realtek or firmware-misc-nonfree).

How to set up a Wi-Fi hotspot on Ubuntu Server?

To create an access point, you will need an adapter that supports AP mode and installation of the package hostapdThe Netplan configuration in this case will be different: you will need to set a static IP for the interface and configure a DHCP server for clients.

Is it safe to store a Wi-Fi password in plaintext in a yaml file?

Configuration files in /etc/netplan/ Readable only by the root user. However, if security is critical, it's recommended to use limited file system permissions and change passwords regularly. Enterprise environments often use WPA-Enterprise with certificates.

What should I do if my Wi-Fi settings are reset after a reboot?

Make sure you have run the command sudo netplan applyAlso check that the configuration file has the correct extension. .yaml and is located in the directory /etc/netplan/Syntax errors may cause the file to be ignored when downloading.