Skip to content

About

share you wifi connection via hotspot with set of rules,, no wifi disconnection

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

linuxhotspot

Turn a Linux machine's WiFi card into a hotspot while it's still connected to the same WiFi network — concurrent STA + AP mode on a single wireless adapter, using hostapd + dnsmasq + iptables.

Requires a WiFi chipset/driver that supports the managed + AP interface combination (check with iw phy phy0 info | grep -A5 "valid interface combinations"). Most modern Intel, Atheros, and Realtek chips support this. Some older Broadcom chips do not.

Requirements

  • Linux with root access
  • A WiFi adapter / internal wifi adapter already connected to a network
  • Python 3
  • hostapd, dnsmasq, iw, iptables (auto-installed by the script if missing)

Install

git clone https://github.com/warsecurity/linuxhotspot.git
cd linuxhotspot

No build step. Run directly with sudo python3 wifi.py.

Usage

sudo python3 wifi.py --start

First run asks for:

  • SSID
  • password (8+ characters, WPA2)
  • upstream WiFi interface name (defaults to wlan0)

These are saved to /etc/wifi-hotspot/hotspot.conf. Edit that file directly to change them later, then run --start again.

Stop the hotspot:

sudo python3 wifi.py --stop

This kills hostapd/dnsmasq, removes the iptables rules, and deletes the virtual ap0 interface. It does not uninstall packages or delete your saved config — --start again picks up where you left off.

Check status:

sudo python3 wifi.py --status

Help:

python3 wifi.py --help

What it does

  1. Checks for hostapd, dnsmasq, iw, iptables; installs anything missing via the system package manager (apt/dnf/yum/pacman/zypper).
  2. Reads or creates /etc/wifi-hotspot/hotspot.conf.
  3. Detects the WiFi channel your upstream interface is currently on and matches the AP to it — required for concurrent STA+AP to work on one radio.
  4. Creates a virtual AP interface (ap0) off your upstream interface.
  5. Writes hostapd and dnsmasq configs.
  6. Starts hostapd (backgrounded) and dnsmasq.
  7. Opens the needed UFW ports on ap0 if UFW is active, and adds iptables MASQUERADE/FORWARD rules so hotspot clients route out through your upstream connection.

Known limitation

A single WiFi radio splits airtime between its STA role (talking to your real network) and its AP role (serving hotspot clients). This is not a bug in the script — it's a hardware/driver constraint. Expect noticeably better and more consistent throughput on the hotspot side if you use a second physical WiFi adapter dedicated to the AP role instead of sharing one radio.

Troubleshooting

ap0 doesn't come up as type AP — your driver likely doesn't support concurrent STA+AP. Check iw phy phy0 info as described above.

hostapd fails with "Failed to set beacon parameters" — almost always a channel mismatch between the AP config and whatever channel your upstream interface is actually on. The script handles this automatically, but if your upstream interface roams to a different channel mid-session, re-run --start.

dnsmasq fails with "Address already in use" — another process (an old manual dnsmasq instance, or a container bridge like lxcbr0) is already bound to the same address/port. --start in the latest version of the script kills anything bound to the hotspot's IP before starting.

Phone connects but shows "sign in to network" / no internet — usually missing NAT rules. Confirm with iptables -t nat -L POSTROUTING -v -n — you should see a MASQUERADE line for your upstream interface. The script adds this automatically; if it's still missing, check that UFW's forwarding policy isn't overriding it.

License

MIT

About

share you wifi connection via hotspot with set of rules,, no wifi disconnection

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages