Linux Wi-Fi Debugging Techniques

Linux Wi-Fi Debugging Techniques

For more content, you can join the Linux system knowledge base package (tutorials + videos + Q&A).

Linux Wi-Fi Debugging Techniques

Table of Contents

  • 1. Tool Summary
    • 1.1. hostapd
    • 1.2. hostapd_cli
    • 1.3. wpa_supplicant
    • 1.4. wpa_cli
    • 1.5. iw
    • 1.6. iwgetid
    • 1.7. udhcpc
    • 1.8. udhcpd
    • 1.9. dnsmasq
    • 1.10. iwpriv
  • 2. Configuration File Introduction
    • 2.1. hostapd.conf Configuration
  • 3. General Methods to Enable Wi-Fi
    • 3.1. AP
    • 3.2. Enable
  • 4. Common Issues When Enabling Wi-Fi

Consolidate, share, and grow, so that both you and others can gain something! 😄

  • Wi-Fi functionality implemented by different configuration files in the Linux system
  • Common parameter descriptions for conf and ini files
  • Mastering the process of enabling Wi-Fi in Linux

1. Tool Summary

1.1. hostapd

Introduction: A user-space daemon that turns a Linux host into a Wi-Fi access point. Command:

  • Start: hostapd /etc/hostapd/hostapd.conf

1.2. hostapd_cli

A command-line tool for interacting with a running hostapd instance. Command:

  • Check status: hostapd_cli status
  • List associated STAs: hostapd_cli list sta

1.3. wpa_supplicant

Introduction:

  • Client tool
  • Supports WPA and WPA2 security standards
  • Connects to Wi-Fi networks Command:
  • Start: wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf

1.4. wpa_cli

Introduction: A command-line tool for interacting with a running wpa_supplicant instance. Command:

  • Check current status: wpa_cli status
  • List configured networks: wpa_cli list network
  • Select and connect to a specified network: wpa_cli select network
  • Disconnect current connection: wpa_cli disconnect

1.5. iw

List wireless interfaces: iw dev Show interface details: iw dev info Scan surrounding wireless networks: iw dev scan Connect to a specific SSID: iw dev connect View connected AP information: iw dev link

1.6. iwgetid

Get connected SSID: iwgetid Get SSID without quotes: iwgetid -r Get more related information: iwgetid -e

1.7. udhcpc

Start DHCP client on specified network card: udhcpc -i wlan0

1.8. udhcpd

Start DHCP server and specify configuration file: udhcpd /etc/udhcpd.conf

1.9. dnsmasq

Start dnsmasq and specify configuration file: dnsmasq -C /etc/dnsmasq.conf

1.10. iwpriv

Check temperature: iwpriv wlan0 get_temp Query channel list: iwpriv wlan0 getChannelList Query network card version: iwpriv wlan0 version

2. Configuration File Introduction

2.1. hostapd.conf Configuration

The file is named hostapd.conf, typically located at /etc/hostapd/hostapd.conf in Linux systems. In Android systems, it is usually located at: /etc/misc/wifi/hostapd.conf. There are many options in hostapd.conf, and most have default settings that do not need modification.

  • interface=wlan0: Interface name, this property can also be overridden by the “-i” parameter.
  • driver=nl80211: Driver interface type (hostap/wired/none/nl80211/bsd), default is: nl80211.
  • ctrl_interface=/var/run/hostapd: A socket file will be created in this directory to listen for status information and configuration requests. The socket file will be named after the interface, allowing multiple hostapd processes to run simultaneously.
  • ssid=test: The name of the AP. It can also be formatted as “double-quoted strings, hexadecimal dumps, or printf escape strings” as follows: # ssid=test
  • hw_mode=g: Operating mode, a is 5 GHz, g is 2.4 GHz.

3. General Methods to Enable Wi-Fi

3.1. AP

Hostapd tool: hostapd -B /etc/hostapd/hostapd.conf -P /var/run/data/hostapd_ssid1.pid -dd -t -f /var/run/hostapd.log

  1. Load Wi-Fi driver
  2. Load network card
  3. Start hostapd
  4. Set IP address
  5. Start UDHCPD service After successful startup, enter hostapd_cli status to check if it started successfully.

3.2. Enable

wpa_supplicant -d -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf -B

  1. Load driver
  2. Start daemon
  3. Obtain IP address

After enabling: use the command wpa_cli status to check if it started successfully.

4. Common Issues When Enabling Wi-Fi

  1. Failed to connect to hotspot, check if the SSID and encryption method in the configuration file match the hotspot.
  2. After enabling the hotspot, the device cannot connect or obtain an IP address; check if the configurations in the udhcpd configuration file match those in wlan0.
  3. Successfully connected to the hotspot but unable to obtain an IP address; the DHCP service is not started and needs to be enabled.
  4. hostapd/wpa_supplicant processes are not running; there may be issues with the configuration file parameters, typically the country code and channel need to be prioritized.

Leave a Comment