Skip to content

SudharshanAIML/linux-hotspot-enabler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 Linux Hotspot Enabler

Simultaneous WiFi + Hotspot on Linux β€” without disconnecting

License: MIT Language: C Platform: Linux

A lightweight C tool with a responsive ncurses TUI that creates a virtual AP interface alongside your existing WiFi connection, enabling internet sharing while staying connected.


🎯 The Problem

On most Linux distributions (including Zorin, Ubuntu, Mint), enabling a Wi-Fi hotspot disconnects you from your current WiFi network. This is because the built-in hotspot feature takes exclusive control of the wireless adapter.

Linux Hotspot Enabler solves this by leveraging AP/STA concurrency β€” creating a virtual access point (ap0) on the same radio as your WiFi client connection, so both run simultaneously.


✨ Features

Feature Description
πŸ“‘ Simultaneous WiFi + Hotspot Stay connected to WiFi while sharing your internet
πŸ–₯️ Responsive TUI Beautiful ncurses terminal interface with 4 screens
πŸ”§ Auto-Detection Automatically finds WiFi interface, channel & AP support
🌍 Cross-Distro Ubuntu, Zorin, Debian, Mint, Arch, Fedora, RHEL & more
πŸ‘₯ Live Client Monitoring See connected devices with IP, MAC, and hostname
πŸ” WPA2 Security Hotspot is password-protected with WPA2/CCMP
πŸ”„ Auto Band Detection Automatically matches client band (2.4/5 GHz)
🧹 Clean Shutdown Properly removes virtual interfaces, NAT rules & temp files
βš™οΈ Configurable Edit SSID, password, channel, 5GHz mode, hidden network

πŸ“Έ Screenshots

Dashboard

β”Œβ”€ WiFi Client ───────────────────────┐ β”Œβ”€ Hotspot ────────────────────────────┐
β”‚ Status:      Connected              β”‚ β”‚ Status:      RUNNING                 β”‚
β”‚ SSID:        MyNetwork              β”‚ β”‚ SSID:        LinuxHotspot            β”‚
β”‚ IP:          192.168.1.42           β”‚ β”‚ Interface:   ap0                     β”‚
β”‚ Channel:     6                      β”‚ β”‚ Clients:     2                       β”‚
β”‚ Signal:      -45 dBm                β”‚ β”‚ Uptime:      1h 23m 15s             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Configuration

β”Œβ”€ Hotspot Configuration ─────────────────────────────────────────────────────┐
β”‚ SSID:           LinuxHotspot                                                β”‚
β”‚ Password:       β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’                                                β”‚
β”‚ Channel:        Auto (match client)                                         β”‚
β”‚ Band:           2.4 GHz (auto)                                              β”‚
β”‚ Hidden:         No                                                          β”‚
β”‚ Max Clients:    10                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Dependencies

Tool Purpose
iw Wireless interface management
hostapd Access Point daemon
dnsmasq DHCP & DNS server for hotspot clients
iptables NAT/firewall rules for internet sharing
ncurses Terminal UI library (dev headers)
gcc / make Build toolchain

Install Dependencies

🟠 Ubuntu / Zorin / Debian / Linux Mint
sudo apt update && sudo apt install -y iw hostapd dnsmasq iptables libncurses-dev build-essential
πŸ”΅ Arch Linux / Manjaro
sudo pacman -Sy --noconfirm iw hostapd dnsmasq iptables ncurses base-devel
πŸ”΄ Fedora / RHEL / CentOS
sudo dnf install -y iw hostapd dnsmasq iptables ncurses-devel gcc make
🟒 openSUSE
sudo zypper install -y iw hostapd dnsmasq iptables ncurses-devel gcc make

πŸ”¨ Build & Install

# Clone the repository
git clone https://github.com/SudharshanAIML/linux-hotspot-enabler.git
cd linux-hotspot-enabler

# Build
make

# (Optional) Install system-wide
sudo make install

To uninstall:

sudo make uninstall

πŸš€ Usage

sudo ./hotspot-enabler

Note: Root privileges are required to manage network interfaces, hostapd, dnsmasq, and iptables rules.

TUI Keyboard Shortcuts

Key Action
F1 Dashboard β€” WiFi & Hotspot status overview
F2 Config β€” Edit SSID, password, channel, band
F3 Clients β€” View connected devices
F4 Log β€” Event and error log
Tab Cycle through screens
Enter Start/Stop hotspot (Dashboard) Β· Edit field (Config)
↑ / ↓ Navigate fields or scroll logs
q Quit (with clean shutdown)

βš™οΈ How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Internet   │◄────────│   Router     β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                        β”‚ WiFi (e.g. channel 6)
       β”‚                 β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
       β”‚                 β”‚   wlo1       β”‚ ← Your WiFi client
       β”‚                 β”‚  (managed)   β”‚
       β”‚                 β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
       β”‚    iptables NAT β”‚   ap0        β”‚ ← Virtual AP interface
       │◄────────────────│  (__ap)      β”‚
       β”‚                 β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                        β”‚ Hotspot (same channel)
       β”‚                 β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
       β”‚                 β”‚   Clients    β”‚
       β”‚                 β”‚  Phone, Tab  β”‚
       β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Startup Sequence

  1. Detect your active WiFi interface and verify AP/STA concurrency support
  2. Create a virtual AP interface (ap0) on the same physical radio
  3. Configure NetworkManager to ignore the AP interface
  4. Launch hostapd to broadcast your hotspot SSID (WPA2 secured)
  5. Assign IP address to ap0 and configure the gateway
  6. Launch dnsmasq to provide DHCP/DNS to connected clients
  7. Configure iptables NAT to forward traffic: hotspot β†’ WiFi β†’ internet
  8. Monitor connections and provide live status via the TUI

Shutdown Sequence

  1. Stop hostapd and dnsmasq processes
  2. Remove iptables NAT rules
  3. Delete the virtual ap0 interface
  4. Restore NetworkManager configuration
  5. Clean up all temporary config files

πŸ—οΈ Project Structure

linux-hotspot-enabler/
β”œβ”€β”€ include/
β”‚   β”œβ”€β”€ hotspot.h          # Hotspot config, status structs & API
β”‚   β”œβ”€β”€ net_utils.h        # Network utility structs & functions
β”‚   └── tui.h              # TUI state, screens & rendering
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.c             # Entry point, root check, dependency verify
β”‚   β”œβ”€β”€ hotspot.c          # Core hotspot management (hostapd, dnsmasq, NAT)
β”‚   β”œβ”€β”€ net_utils.c        # Interface detection, AP support, client listing
β”‚   └── tui.c              # ncurses TUI (dashboard, config, clients, log)
β”œβ”€β”€ Makefile               # Build system
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

⚠️ Requirements

Hardware

Your WiFi adapter must support AP/STA concurrency (most modern adapters do). Verify with:

iw list | grep -A 8 "valid interface combinations"

Look for output containing both managed and AP:

valid interface combinations:
    * #{ managed } <= 1, #{ AP, P2P-client, P2P-GO } <= 1,
      total <= 3, #channels <= 2

Software

  • Linux kernel 4.0+ (for proper nl80211 AP/STA support)
  • Root/sudo access
  • Active WiFi connection (to share internet from)

πŸ”§ Troubleshooting

❌ "WiFi adapter does not support AP+STA concurrency"

Your adapter may not support running AP and client mode simultaneously. Try:

iw list | grep -A 8 "valid interface combinations"

If the output does not show both managed and AP, your adapter's driver doesn't support this feature.

Workaround: Use a second USB WiFi adapter dedicated to the hotspot.

❌ "Failed to create virtual AP interface"
  • Ensure your WiFi driver is loaded: lsmod | grep <your_driver>
  • Check if rfkill is blocking: rfkill list β†’ sudo rfkill unblock wifi
  • Try unloading and reloading your WiFi driver
❌ "hostapd failed"
  • Check the hostapd log: cat /tmp/hotspot_enabler_hostapd.log
  • Ensure hostapd isn't already running: sudo pkill hostapd
  • Your adapter may not support the selected channel β€” try a different one in Config (F2)
❌ "Failed to start dnsmasq"

Another DNS service may be using port 53:

sudo systemctl stop systemd-resolved
sudo systemctl stop dnsmasq

Then try again.

❌ Clients connect but have no internet
  • Verify IP forwarding: cat /proc/sys/net/ipv4/ip_forward (should be 1)
  • Check iptables rules: sudo iptables -t nat -L
  • Ensure your WiFi connection itself has internet access

🀝 Contributing

Contributions are welcome! Feel free to:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Made with ❀️ for the Linux community

If this project helped you, consider giving it a ⭐!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors