Thursday, August 21, 2014

wifi hotspot - How can I permanently assign a static IP address to Wi-Fi or USB tether clients?


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?



Answer




Android uses dnsmasq as its DHCP/DNS server (up to Pie). So create the configuration file /etc/dnsmasq.conf with option dhcp-host=, (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.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...