This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:sbc:common:applications:wifi-sta-ap-mode [2022/07/08 05:22] frank |
products:sbc:common:applications:wifi-sta-ap-mode [2025/02/19 02:32] (current) jacobe |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Wi-Fi STA/AP Mode ====== | + | ====== |
- | ===== Introduction | + | ===== Download |
+ | ``` | ||
+ | wget https:// | ||
+ | sudo chmod 777 khadas_ap.sh | ||
+ | sudo mv khadas_ap.sh / | ||
+ | ``` | ||
+ | We will add it in next version and users could also rebuild the image. | ||
+ | ===== Overview ===== | ||
+ | This guide explains how to configure dual Wi-Fi mode using the provided script (v1.0), enabling simultaneous operation in: | ||
- | This document mainly introduces the STA+AP | + | STA+AP |
- | ===== System Configuration ===== | + | ETH+AP Mode: '' |
- | ==== Upgrade System | + | ===== Prerequisites ===== |
- | Please make sure you use the latest image, if not please follow [[/ | + | Root privileges required |
- | ==== Configuration Instructions ==== | + | Ensure wireless interfaces are properly identified: |
- | Configure | + | STA interface: |
- | === Add Wlan1 Interface === | + | AP interface: '' |
- | ```shell | + | Ethernet |
- | khadas@Khadas: | + | |
- | ``` | + | |
- | Use '' | + | ===== Configuration Script Usage ===== |
+ | Run the script with root privileges: | ||
- | ```shell | + | ``` |
- | khadas@Khadas: | + | sudo khadas_ap.sh |
- | wlan0: flags=4099< | + | ``` |
- | ether 18: | + | |
- | RX packets 0 bytes 0 (0.0 B) | + | |
- | RX errors 0 dropped 0 overruns 0 frame 0 | + | |
- | TX packets 2 bytes 180 (180.0 B) | + | |
- | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | + | |
- | wlan1: flags=4099< | + | |
- | ether 1a: | + | ==== Main Menu Options ==== |
- | RX packets 0 bytes 0 (0.0 B) | + | ``` |
- | RX errors 0 dropped 0 overruns 0 frame 0 | + | ======================================== |
- | TX packets 0 bytes 0 (0.0 B) | + | WiFi Configuration Tool v1.0 |
- | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 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 for most devices: creates NAT forwarding between '' | ||
- | === Setup Wlan1 as a Hotspot === | + | 2.ETH+AP Mode - For devices with Ethernet port: creates NAT forwarding between '' |
- | Setup '' | + | 3.Stop All Services - Terminates AP/DHCP/NAT services |
+ | 4.Exit - Quit the script | ||
- | == 2.4 GHz Frequency | + | ==== Configuration Steps ==== |
- | We shall name our hotspot | + | Select operation mode from menu |
- | ```shell | + | |
- | $ sudo nmcli con add type wifi ifname wlan1 con-name Hostspot autoconnect yes ssid khadas_ap | + | For AP modes (1 or 2): |
- | $ sudo nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared | + | |
- | $ sudo nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk | + | * Enter SSID for hotspot |
- | $ sudo nmcli con modify Hostspot wifi-sec.psk " | + | * Set password |
- | $ sudo nmcli con modify Hostspot ipv4.addresses 192.168.2.20/ | + | * Script automatically handles: |
- | $ sudo nmcli con modify Hostspot ipv4.gateway 192.168.2.1 | + | * Hostapd configuration |
- | $ sudo nmcli con up Hostspot | + | * Dnsmasq DHCP setup |
+ | * IP forwarding | ||
+ | * iptables NAT rules | ||
+ | |||
+ | ===== Verification ===== | ||
+ | Check interface status after configuration: | ||
+ | |||
+ | ``` | ||
+ | ifconfig wlan0 && ifconfig wlan1 | ||
``` | ``` | ||
- | == 5 GHz Frequency == | + | Verify internet connectivity (STA+AP mode): |
- | To setup a 5GHz network, you’ll need to use the channel argument. \\ | ||
- | We shall name our hotspot '' | ||
- | ```shell | ||
- | $ sudo nmcli con add type wifi ifname wlan1 con-name Hostspot autoconnect yes ssid khadas_ap | ||
- | $ sudo nmcli c modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band a 802-11-wireless.channel 149 802-11-wireless.powersave 2 ipv4.method shared | ||
- | $ sudo nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk | ||
- | $ sudo nmcli con modify Hostspot wifi-sec.psk " | ||
- | $ sudo nmcli con modify Hostspot ipv4.addresses 192.168.2.20/ | ||
- | $ sudo nmcli con modify Hostspot ipv4.gateway 192.168.2.1 | ||
- | $ sudo nmcli con up Hostspot | ||
``` | ``` | ||
+ | ping -I wlan0 google.com | ||
+ | ``` | ||
+ | Test hotspot access: | ||
- | Use '' | + | SSID: [Your configured SSID] |
- | ```shell | + | |
- | khadas@Khadas: | + | |
- | wlan0: flags=4099< | + | |
- | ether 18: | + | |
- | RX packets 0 bytes 0 (0.0 B) | + | |
- | RX errors 0 dropped 0 overruns 0 frame 0 | + | |
- | TX packets 2 bytes 180 (180.0 B) | + | |
- | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | + | |
- | wlan1: flags=4163< | + | Password: [Your set password] |
- | inet 192.168.2.20 | + | |
- | inet6 fe80:: | + | |
- | ether 1a: | + | |
- | RX packets 0 bytes 0 (0.0 B) | + | |
- | RX errors 0 dropped 0 overruns 0 frame 0 | + | |
- | TX packets 18 bytes 1312 (1.3 KB) | + | |
- | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | + | |
- | ``` | + | |
- | ===== Go Online! ===== | + | Client IP range: 192.168.43.2-254 |
+ | ===== Important Notes ===== | ||
+ | <WRAP important> | ||
+ | Edge2 Device Limitations: | ||
+ | |||
+ | No Ethernet interface ('' | ||
+ | |||
+ | ETH+AP Mode (Option 2) will not function | ||
+ | |||
+ | Use STA+AP Mode (Option 1) exclusively | ||
- | Verify that wlan0 has a working internet connection: | ||
- | <WRAP info > | ||
- | You need to connect Wi-Fi first. | ||
</ | </ | ||
- | ```shell | + | ===== Technical Details ===== |
- | khadas@Khadas:~$ sudo ping -I wlan0 www.khadas.com | + | |
- | PING td-balancer-dc11-60-161.wixdns.net (185.230.60.161) from 192.168.124.80 wlan0: 56(84) bytes of data. | + | IP Configuration: |
- | 64 bytes from 185.230.60.161 (185.230.60.161): icmp_seq=1 ttl=240 time=293 ms | + | |
- | 64 bytes from 185.230.60.161 | + | * AP Static IP: 192.168.43.1/24 |
- | 64 bytes from 185.230.60.161 | + | * DHCP Range: |
- | ... | + | * DNS: Google DNS (8.8.8.8) via port 5353 |
+ | |||
+ | Security: | ||
+ | |||
+ | * WPA2-PSK encryption | ||
+ | * CCMP/AES cipher mandatory | ||
+ | |||
+ | Default channel: 6 | ||
+ | |||
+ | Dependencies: | ||
+ | |||
+ | * dnsmasq | ||
+ | * hostapd | ||
+ | * iptables (NAT forwarding) | ||
+ | |||
+ | ===== Troubleshooting ===== | ||
+ | |||
+ | AP Not Appearing: | ||
+ | |||
+ | Confirm '' | ||
+ | |||
+ | Check for conflicting services: | ||
``` | ``` | ||
+ | ps aux | grep -E ' | ||
+ | ``` | ||
+ | No Internet Access: | ||
- | Verify | + | Verify |
- | * Name: 2.4G/'' | + | |
- | * Password:'' | + | |
+ | ``` | ||
+ | iwconfig wlan0 | ||
+ | ``` | ||
+ | Check NAT rules: | ||
+ | |||
+ | ``` | ||
+ | iptables -t nat -L -n -v | ||
+ | ``` | ||
+ | DHCP Failures: | ||
+ | |||
+ | Confirm dnsmasq running: | ||
+ | |||
+ | ``` | ||
+ | systemctl status dnsmasq | ||
+ | ``` |