3

I use my phone as an extended display with x11vnc, which works as intended. The only issue is, that I have to change the IP address on the VNC client on my phone, very often. Because of dynamic DHCP, I suppose. I use a Motorola g Turbo Lineage OS 7.1.2, rooted.

Is Android capable of IP reservation? It basically assigns IP address and hostname depending on the MAC address. Or something that achieves the same.

Edit:

Is it possible to assign new static lease through an ADB command immediately?

3

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> (1).

Root is required to place this file. Since /etc is a symlink to /system/etc, /system partition needs to be mounted R/W. Make sure you don't break dm-verity if enabled on your device.

Set permissions:

~# chown 0.0 /etc/dnsmasq.conf
~# chmod 0644 /etc/dnsmasq.conf
~# chcon u:object_r:system_file:s0 /etc/dnsmasq.conf

SELinux rules also need to be defined if status is enforcing. Use Magisk's suploicy or some other similar tool like sepolicy-inject:

allow dnsmasq system_file file { read getattr open }
allow dnsmasq system_file dir { search }

Is it possible to assign new static lease through an ADB command immediately?

No, you need to modify configuration file and restart the dnsmasq server (switch Hotspot OFF and ON) for changes to take effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.