As the title says I look for a way to permanently change the default IP address range form 192.168.43.xxx to 192.168.1.xxx.

Reason: On my router some of my devices get a static IP trough DHCP, in the 192.168.1.xxx range. Using the hotspot on the road I would like to have the same setup.

I have tried to change the range following this steps, but it did not work out on both of my devices. They are rooted and Lineage OS is installed. The last answer suggest an easy way to do this, but it is not possible in Lineage OS.

Also this post from anroidpolice.com suggests that it is possible by an app, I look for a solution to do this with adb. I have no access to Google Play, and do not want it.


1 Answer 1


NOTE: Root is required.

Default DHCP IP address range is hard-coded (1), you can't change it without rebuilding ROM with modified source code. Or use a little hack.

When you switch on tethering, what happens (at least):

  • hostapd - the daemon which manages access points - is started.
  • Network interfaces are set up, IP address is added to Wi-Fi interface (hard-coded before Android Pie (2, 3), randomized afterwards (4)), and routing table is added (5) for local network.
  • dnsmasq - the DHCP/DNS server (up to Pie) - is started with hard-coded commandline arguments (6) (which can be set through /etc/dnsmasq.conf (7) otherwise).

So we can replace /system/bin/dnsmasq with a custom shell script, taking control of the process in between. Rename the original binary to something else:

~# mv /system/bin/dnsmasq /system/bin/dnsmasq.bin

Create script /system/bin/dnsmasq:


LOCAL_TABLE=$(awk '$2=="local_network" {print $1}' /data/misc/net/rt_tables)

export PATH=/system/bin

# delete old route, add new
ip route del ${OLD_SUBNET}.0/24 dev ${WIFI_INTERFACE} table $LOCAL_TABLE
ip route add ${NEW_SUBNET}.0/24 dev ${WIFI_INTERFACE} table $LOCAL_TABLE

# set new IP address on Wi-Fi interface
ip address add ${NEW_SUBNET}.1/24 dev $WIFI_INTERFACE

# inject new subnet in hard-coded arguments received from netd
set -- $(printf '%s' "$*" | sed 's/'"${OLD_SUBNET}"'/'"${NEW_SUBNET}"'/g')

# execute original binary with new arguments
exec dnsmasq.bin $*

Confirm the name of your Wi-Fi interface (wlan0 usually). Check with ip link or ls /sys/class/net/ or iw:

WIFI_INTERFACE=$(iw dev | grep -E 'ssid |Interface ' | grep -B1 ssid | awk '$1=="Interface" {print $2}')

Also confirm your local_network (8, 9) routing table (97) is being used for hotspot. Android's routing is a mess, getting more complex with every new release. So I'm not sure if this has been persistent or not. Also before making any changes, check your routing policies and tables to figure out what you should put in your script:

~# RULES="$(ip rule | grep -vE 'unreachable|local')"
~# echo "$RULES"
~# for t in $(echo "$RULES" | awk '{print $NF}' | uniq); do ip r s table $t; done

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

# execute binaries from /system/bin
allow netd system_file dir { read open getattr search }
allow netd system_file file { read gettattr open execute execute_no_trans }

# execute /system/bin/sh
allow netd shell_exec file { read getattr open execute execute_no_trans }

# execute /system/bin/toolbox and its applets
allow netd toolbox_exec file { read gettattr open execute execute_no_trans }

# configure RPDB rules / routing tables
allow netd netd capability { sys_admin }

* Rules are not persistent across reboots, use some init.d script or replace /sepolicy in ramdisk

Set permissions on files:

~# chown 0.0 /system/bin/dnsmasq*; chmod 0755 /system/bin/dnsmasq*
~# chcon u:object_r:system_file:s0 /system/bin/dnsmasq
~# chcon u:object_r:dnsmasq_exec:s0 /system/bin/dnsmasq.bin


Another options is to modify the value of config_tether_dhcp_range (10) in Android framework as explained in this answer, but I haven't tested this.

Or you can setup complete tethering from commandline, running your own processes. This answer includes the instructions, though the question is different.


  • @Irfan Latif this does not work anymore on LineageOS 17.1 aka android 10. Could you please help to set it up there.
    – kocjs
    Commented Feb 1, 2021 at 11:13
  • @kocj yes already mentioned: "dnsmasq - the DHCP/DNS server (up to Pie) ". I haven't tried anything on Android 10+ so far. They use Java implementation of DHCP server which isn't as easy to alter as a commandline tool is. Possibly the only way would be to patch some system file, or recompile the whole ROM after patching source code. Commented Feb 1, 2021 at 13:18
  • @IrfanLatif Thank you for your quick repaly. LineageOS 17.1 still has the DNSmasq executable. When when i switch on the tethering i am unable to find the dnsmasq.leases file. So there have been some changes. I will open a new question for android 10
    – kocjs
    Commented Feb 2, 2021 at 2:33
  • @kocj dnsmasq is being used as DNS server but DHCP server is moved to Java. Some related details here in comments: android.stackexchange.com/questions/232041/… Commented Feb 2, 2021 at 5:25
  • @IrfanLatif your answer here android.stackexchange.com/questions/201024/… might be the way to go. The thing is that the lshw command does not work for me. Do you think that i will work on android 11 too?
    – kocjs
    Commented Feb 2, 2021 at 11:23

You must log in to answer this question.

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