How do I assign a permanent static IP address to hotspot in Android 10

Search This thread

TheJags

Senior Member
Nov 16, 2017
61
6
I would like to assign a permanent static IP address to hotspot in Android 10 (Unofficial LineageOS 17.1 for Natrium by LuK1337, rooted with Magisk v20.3 and updated to Jan 11, 2020 build).

Now whenever I turn on the hotspot, it assigns a different IP to hotspot, 192.168.43.xxx (this will be the gateway IP to other devices that connects to this hotspot).

Note: For simplicity, instead of connecting other devices to this hotspot, I'm just gonna find hotspot IP by running "ip r" on the phone itself.

On the phone, when I open Termux (have tried other Terminal app with the same results), and run, "ip r" and "ip a", I get:
Code:
:/ $ ip r
 192.168.43.0/24 dev wlan0 proto kernel scope link [B]src 192.168.43.100[/B]
 :/ $


:/ $ ip a
25: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 3000
    link/ether 78:02:f8:f0:4d:87 brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.[B]100[/B]/24 brd 192.168.43.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::7a02:f8ff:fef0:4d87/64 scope link
       valid_lft forever preferred_lft forever
:/ $
Now this "src 192.168.43.100" will be different (e.g: 192.168.43.101, 192.169.43.102 etc) everytime I turn hotspot on and off... and I would like to assign a permanent static IP like ".100"

In LineageOS 16 I used the following workaround, which is no longer working in Android 10 (Unofficial LineageOS 17.1):

Code:
In the Termux (have tried other Terminal app with the same results):

(1)
su
mount -o rw,remount /vendor
nano /vendor/etc/init/hostapd.android.rc

and add:

on property:init.svc.hostapd=running
exec - -- /system/bin/sleep 2
exec u:r:magisk:s0 -- /system/bin/ip address add 192.168.43.[B]100[/B]/24 dev wlan0

Save the file.

mount -o ro,remount /vendor

and
(2)

su
mount -o rw,remount /
nano /etc/dnsmasq.conf

and add:

dhcp-host=78:02:f8:f0:4d:87,192.168.43.[B]100[/B]

Save the file.
Then set the permissions:

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

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

mount -o ro,remount /
Any help is greatly appreciated, many thanks in advance.
 
Last edited:

DMechnikov

Member
Mar 16, 2015
27
12
I've got the same problem with my Pixel 3 running Android 10, also using Termux.
My use case is SSHing into the phone from my iPad to use VIM.

Previously, I used PDANet for its hotspot functionality, but it doesn't work anymore on my Pixel. Depending on your phone, you could give that a shot.
 
  • Like
Reactions: pocketrule

bloodyearth

New member
May 28, 2020
1
2
Unfortunately, starting with Android 9, the gateway is always set randomly. You cannot change it without editing the source code and building the firmware, but you can assign an additional static IP address through which you can connect to the phone. I'm not sure that this will help you, but you can see here three methods to solve this problem:
android.stackexchange.com/questions/213514/how-can-i-permanently-change-my-hotspot-tethering-ip-address
Personally, I use the first method and it is enough for my needs.
 

Cis#

Senior Member
Aug 16, 2015
55
4
Google Pixel 3a
It got even worse. I'm not sure this is a thing since Android 11, but whenever I turn my Hotspot off and on again, it changes the last two segments of my gateway IP, so it's always 192.168.x.x. This sucks even twice, because now all static IPs of all clients need to be updated to get in the right scope for the subnet mask that is still 255.255.255.0.

Pretty ****ty move by Google. I wish there was a solution to this nonsense. I want a static gateway IP without root ... (I know, impossible)
 

legendofrj10

New member
Jul 12, 2020
1
0
It got even worse. I'm not sure this is a thing since Android 11, but whenever I turn my Hotspot off and on again, it changes the last two segments of my gateway IP, so it's always 192.168.x.x. This sucks even twice, because now all static IPs of all clients need to be updated to get in the right scope for the subnet mask that is still 255.255.255.0.

Pretty ****ty move by Google. I wish there was a solution to this nonsense. I want a static gateway IP without root ... (I know, impossible)
You said without root it's impossible but can we do something with root so that we don't have to update gateway ip everytime hotspot is restarted?
 

byquip

New member
Jul 5, 2021
1
1
It got even worse. I'm not sure this is a thing since Android 11, but whenever I turn my Hotspot off and on again, it changes the last two segments of my gateway IP, so it's always 192.168.x.x. This sucks even twice, because now all static IPs of all clients need to be updated to get in the right scope for the subnet mask that is still 255.255.255.0.

Pretty ****ty move by Google. I wish there was a solution to this nonsense. I want a static gateway IP without root ... (I know, impossible)
Faced the same problem after my mobile got an update to Android 11.
Please let me know if you found any solution.
 
  • Like
Reactions: TechnoSparks

trevmlt

New member
Aug 16, 2021
1
1
Faced the same problem after my mobile got an update to Android 11.
Please let me know if you found any solution.
You said without root it's impossible but can we do something with root so that we don't have to update gateway ip everytime hotspot is restarted?
I got close...used MacroDroid with root (Magisk) and I was able to create a macro that started the hotspot and then used secure settings to set the wlan0 IP to what I wanted using ifconfig. Using both ifconfig and a network scanner I confirmed the hotspot had the ip I wanted, but I was not able to actually use it for a stable connection - clients constantly dropped the connection.
 
  • Like
Reactions: pocketrule

Gasel2

New member
Feb 26, 2021
4
0
I'm still on Android 8.1 beacause of this random hotspot IP address issue.
Is there any recent phone or ROM with a static IP address for its hotspot?
 

double b26

Senior Member
Feb 14, 2013
63
14
West Virginia, USA
LG Velvet
Not really THE solution, but I've had pretty good results serving data thru the phones hotspot to an old dd wrt router (set up as a "repeater bridge"). The router/repeater handles all traffic on a local network then looks to the hotspot for data. Basically, just like your home wifi, but swap your modem with the phone.

Behind the router, it functions like a "real" connection. All apps function, push notices come thru, smart TVs, and even Chromecast works! You can assign static IP on the virtual network.

Devices don't seem to notice the random IP changes between the hotspot and router. At the most, you may lose data for a second or two while it .. switches stuff? Idk... but other than a quick lag in chat, if that, you won't even notice anything happened.

A couple sidebars:
  • The old wifi b/g routers with ddwrt are cheap on ebay. Although, router throughput could be a limiting factor on network speeds. Not just the older wifi protocols, but running repeater mode sets router to half duplex.
  • With a lot of the older routers, a USB-to-5v cable works to power it from any USB port (charger, battery pack, accessory port). Ideal for hotel/dorm, work, rural or mobile living. Wherever you need a private, fully functional wifi connection.
  • In dd wrt setup, follow tutorials for repeater bridge setup, but leave the gateway and dns ip blank (all zeros).
  • Naturally, speed and ping depends on the cellphones signal strength.
 
Last edited:

DMechnikov

Member
Mar 16, 2015
27
12
I don’t have an Android phone any more, but I noticed on my family’s Pixels, PDANet gave gives out a consistent 192.168.1.XXX address. PDANet hotspots work like regular hotspots as far as I know, so it might be worth a shot for when you’re on the go without a router to use.
 

double b26

Senior Member
Feb 14, 2013
63
14
West Virginia, USA
LG Velvet
I don’t have an Android phone any more, but I noticed on my family’s Pixels, PDANet gave gives out a consistent 192.168.1.XXX address. PDANet hotspots work like regular hotspots as far as I know, so it might be worth a shot for when you’re on the go without a router to use.
Good to know. I didn't even know pdanet was still around. I'll have to mess with it sometime and see what's up. It would be nice to have a static IP coming from the phone, just cause.
Are you talking about the free or a paid version (if there are still two versions)??

Right now I'm using a rooted Umidigi A7 Pro with a 'hotspot unlock' magisk module, coupled with the VPN Hotspot app. This setup allows me to have unlimited hotspot data, I believe stops reporting of hotspot activity back to the ISP, while tunneling the hotspot data thru my phone's VPN connection.

I live waaay out in the sticks of West Virginia. My only ISP option at this time is Hughesnet satellite, which is just THE worst connection on the face of the planet, not to mention pricey. Speeds is so slow, and ping so high, you can't stream media, play games, or use it for voice or FaceTime chats. Instead, I use the phone setup mentioned above.

Luckily, there is a sprint tower (now T-Mobile) near enough to get a bar or two in the window. I picked up an 850mhz band5 cell booster / repeater (actually on band 26, which is a subsection if band 5). Got it set up, now can use the device in-hand throughout my home and out on the porches. Also helped improve speeds, reduce ping, and stabilize jitter on the LAN.
Call of duty mobile pings around 60-80ms

My Metro by T-Mobile plan is $40 per month, no data caps, but no hotspot allotment either. With the rooted device, I routinely use 200+ gb per month of hotspot data on devices connected via the router/repeater in my home.

I've been running this setup for nearly a year now and not had any problems from my ISP.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    I would like to assign a permanent static IP address to hotspot in Android 10 (Unofficial LineageOS 17.1 for Natrium by LuK1337, rooted with Magisk v20.3 and updated to Jan 11, 2020 build).

    Now whenever I turn on the hotspot, it assigns a different IP to hotspot, 192.168.43.xxx (this will be the gateway IP to other devices that connects to this hotspot).

    Note: For simplicity, instead of connecting other devices to this hotspot, I'm just gonna find hotspot IP by running "ip r" on the phone itself.

    On the phone, when I open Termux (have tried other Terminal app with the same results), and run, "ip r" and "ip a", I get:
    Code:
    :/ $ ip r
     192.168.43.0/24 dev wlan0 proto kernel scope link [B]src 192.168.43.100[/B]
     :/ $
    
    
    :/ $ ip a
    25: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 3000
        link/ether 78:02:f8:f0:4d:87 brd ff:ff:ff:ff:ff:ff
        inet 192.168.43.[B]100[/B]/24 brd 192.168.43.255 scope global wlan0
           valid_lft forever preferred_lft forever
        inet6 fe80::7a02:f8ff:fef0:4d87/64 scope link
           valid_lft forever preferred_lft forever
    :/ $
    Now this "src 192.168.43.100" will be different (e.g: 192.168.43.101, 192.169.43.102 etc) everytime I turn hotspot on and off... and I would like to assign a permanent static IP like ".100"

    In LineageOS 16 I used the following workaround, which is no longer working in Android 10 (Unofficial LineageOS 17.1):

    Code:
    In the Termux (have tried other Terminal app with the same results):
    
    (1)
    su
    mount -o rw,remount /vendor
    nano /vendor/etc/init/hostapd.android.rc
    
    and add:
    
    on property:init.svc.hostapd=running
    exec - -- /system/bin/sleep 2
    exec u:r:magisk:s0 -- /system/bin/ip address add 192.168.43.[B]100[/B]/24 dev wlan0
    
    Save the file.
    
    mount -o ro,remount /vendor
    
    and
    (2)
    
    su
    mount -o rw,remount /
    nano /etc/dnsmasq.conf
    
    and add:
    
    dhcp-host=78:02:f8:f0:4d:87,192.168.43.[B]100[/B]
    
    Save the file.
    Then set the permissions:
    
    chown 0.0 /etc/dnsmasq.conf
    chmod 0644 /etc/dnsmasq.conf
    chcon u:object_r:system_file:s0 /etc/dnsmasq.conf
    
    magiskpolicy "allow dnsmasq system_file file { read getattr open }"
    magiskpolicy "allow dnsmasq system_file dir { search }"
    
    mount -o ro,remount /
    Any help is greatly appreciated, many thanks in advance.
    2
    Unfortunately, starting with Android 9, the gateway is always set randomly. You cannot change it without editing the source code and building the firmware, but you can assign an additional static IP address through which you can connect to the phone. I'm not sure that this will help you, but you can see here three methods to solve this problem:
    android.stackexchange.com/questions/213514/how-can-i-permanently-change-my-hotspot-tethering-ip-address
    Personally, I use the first method and it is enough for my needs.
    2
    It got even worse. I'm not sure this is a thing since Android 11, but whenever I turn my Hotspot off and on again, it changes the last two segments of my gateway IP, so it's always 192.168.x.x. This sucks even twice, because now all static IPs of all clients need to be updated to get in the right scope for the subnet mask that is still 255.255.255.0.

    Pretty ****ty move by Google. I wish there was a solution to this nonsense. I want a static gateway IP without root ... (I know, impossible)
    1
    I've got the same problem with my Pixel 3 running Android 10, also using Termux.
    My use case is SSHing into the phone from my iPad to use VIM.

    Previously, I used PDANet for its hotspot functionality, but it doesn't work anymore on my Pixel. Depending on your phone, you could give that a shot.
    1
    It got even worse. I'm not sure this is a thing since Android 11, but whenever I turn my Hotspot off and on again, it changes the last two segments of my gateway IP, so it's always 192.168.x.x. This sucks even twice, because now all static IPs of all clients need to be updated to get in the right scope for the subnet mask that is still 255.255.255.0.

    Pretty ****ty move by Google. I wish there was a solution to this nonsense. I want a static gateway IP without root ... (I know, impossible)
    Faced the same problem after my mobile got an update to Android 11.
    Please let me know if you found any solution.