Skip to content

Conversation

@cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC
Copy link

@cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC commented Dec 16, 2025

Description

Added DHCP support to bt-tether plugin for modern Android devices that randomize tethering subnets.

Key changes:

  • Added ip-method config option ("auto" for DHCP, "manual" for static)
  • Android defaults to DHCP (fixes Android 11+ subnet randomization)
  • iOS defaults to static IP (consistent behavior)
  • DNS validation relaxed for DHCP mode (optional override)
  • Added README documentation

Motivation and Context

Android 11+ randomizes the Bluetooth tethering subnet prefix on each connection (e.g., 192.168.X.Y where X changes). This breaks static IP configurations that assume 192.168.44.x.

  • I have raised an issue to propose this change (required)

Fixes #441

How Has This Been Tested?

  • Tested with Android 14 device using DHCP mode
  • Verified NetworkManager connection profile created correctly
  • Confirmed IP address obtained dynamically from phone
  • Tested connection up/down lifecycle

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s

Added ip-method config option for DHCP vs static IP configuration.
Android 11+ randomizes tethering subnets, breaking static IP configs.

Changes:
- Add ip-method config: "auto" (DHCP) or "manual" (static)
- Android defaults to DHCP, iOS to static
- DNS validation relaxed for DHCP mode

Signed-off-by: cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC <cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC@users.noreply.github.com>
@wpa-2
Copy link
Contributor

wpa-2 commented Dec 16, 2025

Great work, will test soon as i can.

@jayofelony
Copy link
Owner

@wpa-2 is testing bt-tether functionalities. If he says it works I trust him and I will accept the PR.

@cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC

I don't have an iPhone or other Android device for available testing

WIth DHCP I use IPDisplay to get the IP

@wpa-2
Copy link
Contributor

wpa-2 commented Dec 17, 2025

I don't have an iPhone or other Android device for available testing

WIth DHCP I use IPDisplay to get the IP

06:21:06 [INFO] [Thread-47] : [BT-Tether] Defaulting to DHCP mode for Android phones.
06:21:06 [INFO] [Thread-47] : [BT-Tether] Using DHCP for IP configuration
06:21:07 [INFO] [Thread-47] : [BT-Tether] Connection SS7 Network configured
06:21:15 [INFO] [Thread-47] : [BT-Tether] Disabling bettercap's BLE module
06:21:15 [INFO] [Thread-47] : [BT-Tether] Bettercap BLE was already off.


bnep0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.44.2  netmask 255.255.255.0  broadcast 192.168.44.255
        inet6 ab80::a7a7:9137:390b:e069  prefixlen 64  scopeid 0x20<link>
        ether ab:a6:32:fe:20:ab  txqueuelen 1000  (Ethernet)
        RX packets 45  bytes 11031 (10.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 53  bytes 6743 (6.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Sadly didn't work for me, any settings i need to adjust on the config?
The other issue not everyone uses a screen so they wont be able to use IPdisplay.

The issue seems to be with android16 not 11

EDIT
I'm guessing because i left the static IP stuff on the config is why it wouldn't work, soulds like android wont allow custom ip ranges and will be different every time you fire up BT

@cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC
Copy link
Author

cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC commented Dec 17, 2025

For the changes I added the config item ip-method for main.plugins.bt-tether.ip-method. When this is not set, it defaults to DHCP mode. Based on the logs it is using the correct path to call nmcli connection modify ... So I am not sure why this is still using the static address. Maybe there is no DHCP for your Bluetooth PAN?

Maybe the better mode is to use Static mode when ip and gateway are set and DHCP when they are not set. This will require some updates to the PR.

For discovering the IP address, maybe there is a way to get hostname resolution working for Bluetooth PAN?

@wpa-2
Copy link
Contributor

wpa-2 commented Dec 17, 2025

Maybe the better mode is to use Static mode when ip and gateway are set and DHCP when they are not set. This will require some updates to the PR.

For discovering the IP address, maybe there is a way to get hostname resolution working for Bluetooth PAN

Sadly i couldnt find a way to even set a static IP, it seems every time you turn BT on its always random now, which sucks.

@wpa-2
Copy link
Contributor

wpa-2 commented Dec 18, 2025

So what options do we need on the config now then ?

this is the current options?

main.plugins.bt-tether.enabled = true
main.plugins.bt-tether.phone-name = "" # Your phone's name
main.plugins.bt-tether.phone = "" # android or ios
main.plugins.bt-tether.mac = "" # your phone's MAC address
main.plugins.bt-tether.ip = "" # 192.168.44.2-254 for android, 172.20.10.2-254 for ios

@cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC
Copy link
Author

cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC commented Dec 18, 2025

This is the configuration with ip-method added

main.plugins.bt-tether.enabled = true
main.plugins.bt-tether.phone-name = "" # Your phone's name
main.plugins.bt-tether.phone = "" # android or ios
main.plugins.bt-tether.mac = "" # your phone's MAC address
main.plugins.bt-tether.ip = "" # 192.168.44.2-254 for android, 172.20.10.2-254 for ios
main.plugins.bt-tether.ip-method = "" # dhcp or static

This is the current flow to decide which mode to take. For existing configuration this should not change behaviour.

Condition Result
ip + gateway both provided Static mode (ignores ip-method)
ip-method='dhcp' + no ip/gateway DHCP mode
ip-method='static' Static with phone-type defaults
No config (fallback) Static with phone-type defaults
Phone IP Address Gateway
Android 192.168.44.2 192.168.44.1
iOS 172.20.10.2 172.20.10.1

Stale static IP in network connection
When I switched between "dhcp" and "static" the static IP was still present in the network connection. These settings cleared in the current version.

@cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC

discovering the IP address, maybe there is a way to get hostname resolution working for Bluetooth PAN?

The dynamic IP stayed the same during reboots of the pwnagotchi.
The subnet for the DHCP on the Bluetooth PAN changed with each reboot of my Android device.

How to address this:

  1. Hostname resolution via mDNS. I tried mDNS and for the USB connection I got it working to resolve to pwnagotchi.local. However, mDNS does not seem to be available on my stock Android Bluetooth PAN.
  2. Display the IP address, e.g, via PDisplay.
  3. Use a VPN, e.g., Wireguard or Tailsacle
  4. Announce the dynamic IP via Telegram, Discord, ...

@ShinobiHanzo
Copy link

There is one thing consistent with my android build I found recently: it always starts with a 10.x.x.x/24. So depending on what build and model, the BT-pan is confirmed to always keep that consistent depending on the driver and the manufacture as long as it's android 13+

@wpa-2
Copy link
Contributor

wpa-2 commented Dec 19, 2025

This is the configuration with ip-method added

main.plugins.bt-tether.enabled = true
main.plugins.bt-tether.phone-name = "" # Your phone's name
main.plugins.bt-tether.phone = "" # android or ios
main.plugins.bt-tether.mac = "" # your phone's MAC address
main.plugins.bt-tether.ip = "" # 192.168.44.2-254 for android, 172.20.10.2-254 for ios
main.plugins.bt-tether.ip-method = "" # dhcp or static

This is the current flow to decide which mode to take. For existing configuration this should not change behaviour.

Condition Result
ip + gateway both provided Static mode (ignores ip-method)
ip-method='dhcp' + no ip/gateway DHCP mode
ip-method='static' Static with phone-type defaults
No config (fallback) Static with phone-type defaults
Phone IP Address Gateway
Android 192.168.44.2 192.168.44.1
iOS 172.20.10.2 172.20.10.1
Stale static IP in network connection When I switched between "dhcp" and "static" the static IP was still present in the network connection. These settings cleared in the current version.

Tested static option>?

bnep0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.44.2 netmask 255.255.255.0 broadcast 192.168.44.255
inet6 fe80::d368:969c:e4af:e806 prefixlen 64 scopeid 0x20
ether dc:a6:32:fe:20:fb txqueuelen 1000 (Ethernet)
RX packets 15 bytes 3112 (3.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 40 bytes 5147 (5.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Connects to phone but IP isnt working in the UI or pwnlog

and after reboot I get
08:23:00 [INFO] [Thread-68] : [BT-Tether] Using static IP defaults: 192.168.44.2, gateway: 192.168.44.1
08:23:00 [INFO] [Thread-68] : [BT-Tether] NetworkManager configured for static IP: 192.168.44.2
08:23:00 [INFO] [Thread-68] : [BT-Tether] Connection s Network configured
08:23:08 [ERROR] [Thread-68] : [BT-Tether] Error with nmcli
08:23:08 [ERROR] [Thread-68] : [BT-Tether] Exception : Command '['nmcli', 'connection', 'up', 's Network']' returned non-zero exit status 4.
08:23:08 [ERROR] [Thread-68] : [BT-Tether] Failed to connect to device: Command '['nmcli', 'connection', 'up', 's Network']' returned non-zero exit status 4.
08:23:08 [ERROR] [Thread-68] : [BT-Tether] Failed to connect to device: have you enabled bluetooth tethering on your phone?
08:23:08 [INFO] [Thread-68] : [BT-Tether] Disabling bettercap's BLE module
08:23:08 [INFO] [Thread-68] : [BT-Tether] Bettercap BLE was already off.

Even when it does connect IP isnt working
dhcp method doesnt even connect for me so unsure here.

@cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC
Copy link
Author

cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC commented Dec 19, 2025

Marked this PR as Draft, while we try to sort this out.

The log Command '['nmcli', 'connection', 'up', 's Network']' looks like the phone-name is empty. Can you share the config?

For testing I removed the BT-PAN, followed the BT-Tethering process and used the following two configurations

bt-tether w/ static IPs

main.plugins.bt-tether.enabled = true
main.plugins.bt-tether.phone = "android"
main.plugins.bt-tether.phone-name = "Pixel9Pro"
main.plugins.bt-tether.mac = "08:8B:C8:CO:FF:EE"
main.plugins.bt-tether.gateway = "10.208.178.176"  # current IP for Bluetooth PAN on Android device
main.plugins.bt-tether.ip = "10.208.178.226"       # free IP in subnet for Bluetooth PAN on Android device

bt-tether w/ DHCP

main.plugins.bt-tether.enabled = true
main.plugins.bt-tether.phone = "android"
main.plugins.bt-tether.phone-name = "Pixel9Pro"
main.plugins.bt-tether.mac = "08:8B:C8:CO:FF:EE"
main.plugins.bt-tether.ip-method = "dhcp"

Remove BT-PAN

$ sudo bluetoothctl
devices
untrust 08:8B:C8:CO:FF:EE
remove 08:8B:C8:CO:FF:EE
exit
$ nmcli connection show
$ sudo nmcli connection delete $(nmcli -g connection.uuid connection show 'Pixel9Pro Network')

@wpa-2
Copy link
Contributor

wpa-2 commented Dec 19, 2025

The log Co

Let me test again now ?
Are you in the discord, maybe start some testing there.

So to confirm after moving the bt-pan redo the pairing process again.

@wpa-2
Copy link
Contributor

wpa-2 commented Dec 19, 2025

16:26:43 [INFO] [Thread-4] : [BT-Tether] Using static IP: 10.208.178.176, gateway: 10.208.178.226
16:26:43 [INFO] [Thread-4] : [BT-Tether] NetworkManager configured for static IP: 10.208.178.176
16:26:43 [INFO] [Thread-4] : [BT-Tether] Connection SS7 Network configured
16:27:18 [ERROR] [Thread-4] : [BT-Tether] Error with nmcli
16:27:18 [ERROR] [Thread-4] : [BT-Tether] Exception : Command '['nmcli', 'connection', 'up', 'SS7 Network']' returned non-zero exit status 4.
16:27:18 [ERROR] [Thread-4] : [BT-Tether] Failed to connect to device: Command '['nmcli', 'connection', 'up', 'SS7 Network']' returned non-zero exit status 4.
16:27:18 [ERROR] [Thread-4] : [BT-Tether] Failed to connect to device: have you enabled bluetooth tethering on your phone?
main.plugins.bt-tether.enabled = true
main.plugins.bt-tether.phone-name = "SS7"
main.plugins.bt-tether.mac = "MYMAC"
main.plugins.bt-tether.phone = "android"
main.plugins.bt-tether.ip = "10.208.178.176"
main.plugins.bt-tether.gateway = "10.208.178.226"

This is the edit im using?
https://github.com/cVeqT2vkiSX5kJVJxcVmz7rKHKbu9M9FNixoPNC/pwnagotchi/blob/9ce7d8b0ccacfa3b75fb38e3d28ec830c2a7f1b7/pwnagotchi/plugins/default/bt-tether.py

Not tested dhcp yet as I think static IP's is the best approach for thew wider use.

oddly when clicking
http://192.168.1.149:8080/plugins/bt-tether

It does show all the BT information as if it's connected.

@wpa-2
Copy link
Contributor

wpa-2 commented Dec 19, 2025

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.

bt-tether: Add DHCP support for Android

4 participants