Android's dhcp server sucks kinda bad
I have a bit of a special use-case: I mostly use my android phone (google pixel 5a) as a router.
When travelling my laptop & other devices are just paired to my phone & it has a keyboard and a camera to be able to type or scan into wifi networks. It also has LTE, although I try to avoid that when possible.
I also carry around a GLInet portable router with me, although I haven't gotten around to configuring it in such a way that it's not always dead.
A couple hiccups with using my phone as my primary router:
- It doesn't resolve hostnames of connected devices
- I can't open a remote adb shell into it.
DNS queries pulling from DHCP
Once upon a time, android just used dnsmasq for both it's DNS & DHCP. there are a bunch of old stackexchange posts outlining this relation and how modifying /etc/dnsmasq.conf (after running an adb remount) would do just about anything you'de want.
These days though, it looks like android ships it's own DHCP server implementation (ugh).
strace -p $(pgrep dnsmasq) -f & sleep 0.2; pkill -SIGHUP dnsmasq
https://medium.com/@IamCOD3X/understanding-and-resolving-selinux-denials-on-android-ca3cee3719b6
for some reason reads on /tmp/* dirs/files would fail even with the proper permissioning. grr selinux(?)
Pointing addn-hosts=/data/misc/dhcp/hosts seems to work, though
dhcp-leasefile=/data/misc/dhcp/leases does not though. probably because it's not running a dhcp server
SIGHUP seems to refresh the listings
also:
--hostsdir=<path>
Read all the hosts files contained in the directory. New or changed files are read automatically and modified and deleted files have removed records automatically deleted.
unfortunately, my version of dnsmasq doesn't support the directory flags :(
looks like we're stuck with a host file & SIGHUP
IDhcpEventCallbacks > startwithcallbacks :eyes:
makeDhcpServer
where does the dhcpserver get created???
Self-directed DNS
I want to connect to local devices via name from my phone on my wlan
https://source.android.com/docs/core/ota/modular-system/dns-resolver
adb server binding interface
https://man.archlinux.org/man/dnsmasq.8
https://linux.die.net/man/5/dhcpd.leases
https://serverfault.com/a/786141
https://android.stackexchange.com/a/214072
https://jpmens.net/2013/10/21/tracking-dhcp-leases-with-dnsmasq/
https://medium.com/moqume/poor-mans-device-discovery-dns-492a95ea8c8b
https://ncrmnt.org/tag/dnsmasq/
https://ncrmnt.org/2012/06/27/making-android-hotspot-mode-usable/
https://ncrmnt.org/2013/04/10/android-and-dnsmasq-making-a-better-dnsmasq-wrapper/