Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:edge-2l:applications:wifi-sta-ap-mode

This is an old revision of the document!


Edge-2L Wi-Fi STA/AP Mode Configuration

Download Script

Download and install the configuration script:

wget https://raw.githubusercontent.com/khadas/fenix/refs/heads/master/archives/filesystem/common/usr/local/bin/khadas_ap.sh
sudo chmod 777 khadas_ap.sh
sudo mv khadas_ap.sh /usr/local/bin

Note: This script will be included in future system images. For now, you can manually download it or rebuild your image to include it.

Overview

This guide explains how to configure dual Wi-Fi modes using the khadas_ap.sh script (v1.0). It enables the Edge-2L to operate in one of the following modes simultaneously:

  • STA+AP Mode: wlan0 acts as a Station (STA) to connect to an existing Wi-Fi network, while wlan1 creates an Access Point (AP) hotspot.
  • ETH+AP Mode:(Not available on Edge-2L) eth0 provides an Ethernet uplink while wlan1 creates an AP hotspot.

Prerequisites

  • Root privileges are required.
  • Ensure wireless interfaces are properly identified:
    • STA interface: wlan0
    • AP interface: wlan1
  • Important: The Edge-2L does not have an Ethernet interface (eth0), making the ETH+AP mode non-functional on this device.

Configuration Script Usage

Run the script with root privileges:

sudo khadas_ap.sh

You will see the following menu:

========================================
 WiFi Configuration Tool v1.0
========================================
1. STA+AP Mode
2. ETH+AP Mode
3. Stop All Services
4. Exit
========================================
Please select an option [1-4]:
  1. STA+AP Mode (Recommended): Creates NAT forwarding between wlan0 (connected to an existing Wi-Fi) and wlan1 (AP hotspot). Hotspot IP: 192.168.43.1, DHCP range: 192.168.43.2-254.
  2. ETH+AP Mode: Creates NAT forwarding between eth0 and wlan1. Note: This mode will not work on Edge-2L as it lacks an eth0 interface.
  3. Stop All Services: Stops the AP, DHCP, and NAT forwarding services.
  4. Exit: Quit the script

Configuration Steps

  1. Select your desired operation mode from the menu (use Option 1 for Edge-2L).
  2. For AP modes, you will be prompted to:
    • Enter SSID for hotspot
    • Set password (WPA2-PSK required)
  3. The script automatically configures:
    • Hostapd (for the AP)
    • Dnsmasq (for DHCP)
    • IP forwarding and iptables NAT rules

Verification

After configuration, verify the interface status:

ifconfig wlan0 && ifconfig wlan1

In STA+AP mode, test internet connectivity from the device:

ping -I wlan0 google.com

To connect to the hotspot from another device:

  • SSID: The name you configured.
  • Password: The password you set.
  • Client IP range: 192.168.43.2 - 192.168.43.254

Important Notes

Edge-2L Device Limitations: The Edge-2L does not have an Ethernet interface (eth0). Therefore, ETH+AP Mode (Option 2) will not function.Use STA+AP Mode (Option 1) exclusively.

Technical Details

  • IP Configuration:
    • AP Static IP: 192.168.43.1/24.
    • DHCP Range: 192.168.43.2-254.
    • DNS: Google DNS (8.8.8.8) via port 5353.
  • Security: WPA2-PSK with mandatory CCMP/AES cipher.
  • Default channel: 6.
  • Required Services: dnsmasq, hostapd, iptables.

Troubleshooting

  • AP Not Appearing:
    • Confirm the wlan1 interface exists.
    • Check for conflicting services: ps aux | grep -E 'hostapd|dnsmasq'
  • No Internet Access for Clients:
    • Verify the STA connection: iwconfig wlan0
    • Check NAT rules: iptables -t nat -L -n -v
  • DHCP Failures:
    • Check if dnsmasq is running: systemctl status dnsmasq
Last modified: 2026/02/23 22:28 by gray