My phone Moto X 4 has LineageOS 17.1 installed and is rooted with magisk. I use the phone's hot spot as main mean to connect to the internet.
In this scenario the android device acts as DHCP server, therefore distributing random IP addresses in the 192.168.43.0/24 sub range. I would like to assign static IP addresses to my devices, then i can connect to them trough SSH easily. The clementine android remote also requires my laptop to be available on a fixed IP.
I do not like to carry a travel router for this basic network ability.
On android 9 this was possible by setting up the dnsmasq.conf file, setting the file permissions and configuring SELinux rules.
This workaround helped me to set it up.
Android uses dnsmasq as its DHCP/DNS server (up to Pie). So create the configuration file /etc/dnsmasq.conf with option dhcp-host=<MAC>,<IP>.
dnsmasq
DHCP server in favor of Java implementation which we cannot configure by simply editing a file. Creating hotspot from commandline should work though: How to create a wifi hotspot from the terminal? unless a better solution is found.tether_enable_legacy_dhcp_server
but it's meant to be used only for tests. On Android 11, however, it seems thatdevice_config put connectivity tether_enable_legacy_dhcp_server true
should do the trick: android.googlesource.com/platform/packages/modules/Connectivity/…. But I haven't tested.Requested IP Address
option sent in DHCPDISCOVER message. Yes that should work with any standard DHCP server implementation. But if you control all of the clients and don't mind manually configuring them, then there's no need to use DHCP at all. Set a static IP address on each client and disable DHCP client service. But if even one of the clients is using DHCP, the IP conflict may occur and DHCP server may refuse the requested IP address.