IP address is by default and there is no option to change it permanently. Is it possible to change it without root access?

My phone is Huawei Android 5.1.


1 Answer 1


Note: Adding / removing IP address requires root access.


Before Android Pie, tethering IP ( was hard-coded (1, 2). But now it's randomized on each session(3). You can use Android's builtin ip command to set an additional fixed IP address (within same subnet obviously):

~# ip address add dev wlan0

* Replace add with del to delete.

Make sure that the name of your Wi-Fi interface (wlan0 usually) is correct. Check with ip link or ls /sys/class/net or iw dev.


The problem with above approach is that the added IP is not permanent. Once you switch OFF the hotspot, IP will get cleared. So you can use an init trigger to set IP address whenever hotspot is turned ON. Add these lines to (/vendor)/etc/init/hostapd.android.rc file (or any .rc file under /etc/init/):

on property:init.svc.hostapd=running
    exec - -- /system/bin/sleep 2
    exec u:r:magisk:s0 -- /system/bin/ip address add dev wlan0
  • hostapd is the system service which manages access points.
  • Service uses Magisk's SELinux context assuming that the device is rooted with Magisk.


dnsmasq starts listening on all IP addresses which are set on WiFi interface before dnsmasq is started. But with both above methods there is no way to make sure that IP is added after netd sets up the interface and before dnsmasq starts. So the added IP address may conflict with IP leased to another host (saved in /data/misc/dhcp/dnsmasq.leases) by DHCP server (dnsmasq up to Pie) from DHCP range ( to by default) (4).

To address this problem:

  • Reserve the manually added IP address by editing dnsmasq.conf. See How can I permanently assign a static IP address to Wi-Fi or USB tether clients?
  • Or modify DHCP IP range, but it's hard coded. You can replace dnsmasq with a shell script to achieve this. See How to change the default hotspot DHCP IP address range?
  • Or replace /system/bin/dnsmasq with a shell script which adds IP address before executing original dnsmasq binary. Rename dnsmasq to dnsmasq.bin and create script: /system/bin/dnsmasq:

    # set fixed IP address on Wi-Fi interface
    ip address add dev wlan0
    # execute original binary
    exec dnsmasq.bin $*
    • Set ownership, permission and SELinux context on both files. See this answer for details.
    • Additionally you may add listen-address= (5) to dnsmasq.conf.
    • Use ss or netstat to make sure that DHCP server is listening on reserved IP address (or on all IP addresses i.e. so that to avoid IP address collision.

NOTE that in order to modify .rc, dnsmasq or dnsmasq.conf files, /vendor and /system partitions need to be mounted R/W which requires dm-verity disabled. Otherwise you may use bind mounts (used by Magisk modules). On non-SAR devices /init.rc can also be edited to modify /init.rc file in ramdisk by unpacking boot.img.

  • 1
    I was able to set this up on a MotoG3 turbo with LineageOS 17.1 android-10.
    – kocjs
    Feb 5, 2021 at 16:35
  • Hi, I just want to clarify that this Q&A is about setting the Android's hotspot IP to static, but not the given IP to the devices that are connected to the hotspot right? I did a peek at deleted comments and looks like there was also confusion, so just to be sure before I wrongly close other questions as a duplicate of this.
    – Andrew T.
    Jun 6, 2022 at 14:30
  • 1
    @AndrewT. Yes. This question is about the hotspot IP address of the Android device. There's another question about the IP addresses assigned to the devices connected to the Android hotspot: How can I permanently assign a static IP address to Wi-Fi or USB tether clients?. Jun 6, 2022 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .