Skip to content

Keeps the managed-mode gateway's MAC across starts, so clients don't see a new network every time - #8

Merged
ravindu644 merged 2 commits into
ravindu644:mainfrom
poqdavid:fixed-gateway-mac
Oct 23, 2026
Merged

ravindu644 merged 2 commits into
ravindu644:mainfrom
poqdavid:fixed-gateway-mac

Conversation

@poqdavid

@poqdavid poqdavid commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

In managed mode the clients' gateway is vaplan0, the container end of the veth pair that config_network_bridged() creates on every start. A new veth gets a new random MAC from the kernel, so the gateway's MAC changes every time the hotspot or the container restarts.

Clients that remember networks by their gateway's MAC see a brand new network each time. Windows is the obvious one: it creates a new profile (wn17 2, wn17 3, ...) and puts it back in the Public category, so setting it to Private never sticks and discovery and file sharing get blocked again.

Fix

The backend gets -m <mac>, saved in ap.conf as GW_MAC, which sets the MAC on vaplan0 after the rename and before the link comes up. Empty, the default, keeps the random one, and a MAC the kernel refuses is a warning, not a failed start. A MAC equal to ap0's is refused too, because ap0 sits on the same bridge and the bridge would keep the gateway's frames for itself. caps now reports the Wi-Fi's factory MAC as mac=, and status the gateway's live one as gw_mac=. The factory MAC comes from wifi_sta_factory_mac_address in the Wi-Fi service's WifiConfigStore.xml, which AOSP fills from the Wi-Fi HAL on Android 11 and up, so it doesn't depend on the vendor. The kernel's permanent address and Samsung's efs copy are the fallbacks.

In the app, the Advanced card in managed mode gets a Gateway MAC mode and a MAC box, in place of the DNS field the container owns there:

  • Random every start (default): today's behaviour. The box is read-only and shows the live MAC while the hotspot runs.
  • Random once: a random locally administered MAC, picked when the mode is chosen and then kept. Editable.
  • Static MAC: prefilled with the Wi-Fi's factory MAC. Editable.

An invalid MAC blocks Start through APConfig.isValid(), so the Quick Settings tile follows it too. Routed mode is untouched: its gateway is ap0, and that MAC belongs to the Wi-Fi driver.

Tested on a Samsung Galaxy A15 4G (SM-A155F, MT6789) in managed mode with the OpenWrt container

Screenshot_20261023_023703 Screenshot_20261023_023645 Screenshot_20261023_023532 Screenshot_20261023_023521

vaplan0 is a new veth on every start, so the gateway gets a new random
MAC each time and clients treat the hotspot as a new network. -m <mac>
sets a fixed MAC on vaplan0 before it comes up; empty, the default,
keeps the random one. A MAC equal to ap0's is refused, since the bridge
would keep the gateway's frames for itself.

caps now reports the Wi-Fi's factory MAC (mac=, from Android's Wi-Fi
settings store, the kernel or Samsung's efs) and status the gateway's
live one (gw_mac=).
Advanced gets a Gateway MAC mode with a MAC box: Random every start
(the default, read-only, shows the live MAC while running), Random once
(picked once and kept, editable) and Static MAC (prefilled with the
Wi-Fi's factory MAC, editable). An invalid MAC blocks Start through
isValid().
@poqdavid

Copy link
Copy Markdown
Contributor Author

I should add that i been using this and its working just fine

@ravindu644
ravindu644 merged commit de9bd50 into ravindu644:main Oct 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants