When you can't connect to Wi-Fi on Debian, 99% of the time it's due to missing wireless card firmware. Out of commitment to free software, Debian's default standard installation images do not include this non-free firmware.
Core Solution: Install Firmware Packages
Identify your wireless card:
Open a terminal and type lspci | grep -i network or lsusb | grep -i network to see your wireless card model. Common vendors include Intel, Realtek, Broadcom, and Atheros.
Get and install the firmware:
Best method: Use a wired network
If your computer has an Ethernet port, plug in a network cable first.
Edit /etc/apt/sources.list to ensure it includes non-free and non-free-firmware.
Update the package list: sudo apt update
Install the corresponding firmware package based on your card's vendor:
Search for and download the firmware package you need (e.g., firmware-iwlwifi), which will be a .deb file.
Copy this .deb file to your Debian computer using a USB drive.
Install it using the apt command: sudo apt install ./firmware-iwlwifi_xxxxxxxx_all.deb.
The once-and-for-all solution: Use an unofficial image with integrated firmware
When installing Debian, download an installation image that includes all non-free firmware directly from the Debian unofficial images site. This will allow the installer to recognize and configure your wireless network during the installation process.
Wired networks generally have fewer issues than wireless ones because the required firmware is more generic. If you encounter problems, follow these steps to troubleshoot:
Check the physical connection:
Ensure the network cable is securely plugged in at both ends.
Check if the corresponding port's indicator lights on the router or switch are blinking normally.
Check if the network card is recognized:
lspci | grep -i ethernet
If you can see your network card information, the hardware has been recognized by the system.
Check the Network Manager status:
Debian desktop editions typically use the NetworkManager service to manage networks.
Check the service status: sudo systemctl status NetworkManager
If the service is not running, start it: sudo systemctl start NetworkManager
Click the network icon in the system tray to see if a wired connection is available.
Check the IP address:
Run ip a or ifconfig.
Check if your wired network interface (usually enpXsY or eth0) has obtained an IP address.
If the IP address is 169.254.x.x, it means your computer failed to get an IP address from the router (DHCP server). Check your router's settings or restart the router.
Setting a static IP is common for servers or devices that require a fixed address.
Method 1: Using nmtui (Recommended, simple)
nmtui is a text-based NetworkManager configuration tool that is very intuitive.
Run sudo nmtui in a terminal.
Select "Edit a connection" and press Enter.
Select your wired or wireless connection, move to "Edit...", and press Enter.
In the "IPv4 CONFIGURATION" section, change <Automatic> to <Manual>.
On the right side, click <Add...> in the "Addresses" section and enter the static IP address and subnet mask in the format 192.168.1.100/24.
Enter your gateway address (usually the router's IP) in the "Gateway" field.
Add DNS server addresses in the "DNS servers" field, such as 8.8.8.8 or 114.114.114.114.
Move to <OK> at the bottom and press Enter to save.
Exit nmtui, then restart the network connection for the changes to take effect: sudo systemctl restart NetworkManager.
Method 2: Modifying configuration files (Common for servers)
For servers without a desktop environment, you can directly edit the /etc/network/interfaces file.
Note: If your system is using NetworkManager, do not use this method as it will cause conflicts. This method is for systems where network interfaces are managed by ifupdown.
Edit the file: sudo nano /etc/network/interfaces.
Find the configuration for the relevant network interface and modify it as follows:
# The primary network interfaceallow-hotplug enp1s0# iface enp1s0 inet dhcp <-- Comment out or delete the DHCP line# Static IP configurationiface enp1s0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 8.8.8.8 1.1.1.1
After saving, restart the networking service: sudo systemctl restart networking or sudo /etc/init.d/networking restart.
These are two different network configuration management tools on Debian. You should typically use only one of them to avoid conflicts.
/etc/network/interfaces (provided by the ifupdown package)
Role: The traditional, stable, text-file-based method of network configuration.
How it works: You manually edit the /etc/network/interfaces file to define the configuration for each network interface (e.g., enp3s0), specifying whether it's DHCP or a static IP, what the address is, etc. You then use ifup <interface> and ifdown <interface> commands to activate or deactivate the interface.
Pros: Static configuration, very reliable, no extra background processes. It's the preferred choice in a server environment.
Cons: Inflexible. It's very inconvenient for desktop users who need to frequently switch Wi-Fi networks, use VPNs, or connect to Bluetooth networks by manually editing a file each time.
Use case: Servers, or devices with a fixed network environment.
NetworkManager
Role: A modern, dynamic, and powerful network management service.
How it works: It's a service that runs continuously in the background, automatically detecting network hardware, managing wired and wireless connections, handling VPNs, and providing graphical configuration interfaces (like the network icon in the system tray, nmtui, nm-connection-editor).
Pros: Extremely convenient and powerful. It easily handles complex desktop networking needs, such as saving multiple Wi-Fi passwords, automatically switching between networks, and graphical configuration.
Cons: It's a relatively "heavy" service for a minimal server environment.
Use case: All desktop and laptop users.
Which one should I use?
If you installed a Debian desktop edition (GNOME, KDE, Xfce, etc.), use NetworkManager. This is the default configuration method, and all the graphical network tools you see are its frontends. In this case, your /etc/network/interfaces file should be very simple, possibly only containing source /etc/network/interfaces.d/* and a loopback (lo) interface configuration. Do not manually edit it to configure your main network card.
If you installed a Debian server without a GUI, it's recommended to use /etc/network/interfaces. It's more lightweight and direct.
How do I know which one is managing my network?
By default, if the NetworkManager service is running, it will take control of all devices not explicitly configured in /etc/network/interfaces. You can check its status with sudo systemctl status NetworkManager.
This is a classic network problem that almost always points to a DNS (Domain Name System) resolution failure.
Problem Analysis:
You can browse the internet (e.g., you can open a page by directly visiting an IP address like 114.114.114.114 in your browser). This proves that the IP routing from your device to the internet is working. The physical connection, IP address, and gateway are all fine.
ping fails (e.g., ping www.baidu.com shows Name or service not known or Temporary failure in name resolution). This proves that your system cannot convert the domain namewww.baidu.com into its corresponding IP address.
DNS acts like the internet's phone book, responsible for translating easy-to-remember domain names into machine-readable IP addresses.
DNS Troubleshooting Steps:
Confirm the problem:
Try to ping a domain name: ping www.debian.org (likely to fail).
Try to ping a public IP address: ping 8.8.8.8 (Google's DNS server).
If the former fails and the latter succeeds, it is 100% a DNS issue.
Check the current DNS configuration:
The DNS server addresses are stored in the /etc/resolv.conf file.
cat /etc/resolv.conf
Look at the nameserver entries inside. If this file is empty, or if the IP address inside is an inaccessible internal address (like 127.0.0.53, which is the local stub for systemd-resolved), then the DNS configuration is incorrect.
Note: This file is usually generated automatically by NetworkManager or the resolvconf program. It is not recommended to edit it manually, as your changes will be lost after a network restart.
Temporary solution (for testing):
Manually edit /etc/resolv.conf to add a reliable public DNS.
# First, back it upsudo cp /etc/resolv.conf /etc/resolv.conf.bak# Edit the filesudo nano /etc/resolv.conf
Delete all content and add:
nameserver 8.8.8.8nameserver 1.1.1.1
Permanent Solution:
For Desktop (NetworkManager):
Open your network settings through the graphical interface.
Go to your active connection's settings (wired or Wi-Fi).
In the "IPv4" tab, switch "Method" from "Automatic (DHCP)" to "Automatic (DHCP), addresses only".
In the "DNS" field that appears, enter your desired DNS servers, separated by commas (e.g., 8.8.8.8, 1.1.1.1).
Save and reconnect. NetworkManager will now write these DNS servers to /etc/resolv.conf.
For Server (/etc/network/interfaces):
Add a dns-nameservers line to your static IP configuration as shown in the static IP section above.