-
-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set static IP addresses (Android 11+) #193
Comments
This is an intended feature of Android 11. You should complain to Google instead. |
Reopening since technically |
This "feature" is really useless. Why did they do this? |
In principle, it is possible to hijack the DNS so that a fixed domain will point to the gateway. However, this requires root and I do not see a useful use case for now. |
This is an example of redirecting DHCP requests to your own instance of Dnsmasq serving on a non-standard port, in this case for usb tethering. This lets you set any local network, dns servers, static leases. Clear and set addresses and add the route
Take broadcast udp traffic on port 67 and redirect it to 1067.
Start a new Dnsmasq instance with the dhcp-alternate-port option to receive requests on our alternative port.
Edit:
And we can then redirect to the new dns server.
|
@worstperson Thanks for looking into this! However, I prefer to not kill |
Below "Edit:", I had fixed it by setting the DNS port to avoid conflicting and added a rule to point traffic to it. |
Sorry that wasn't very clear. I quickly realized that you wouldn't accept the original PoC shortly after posting, so I hurriedly fixed the dns server conflict and added it at the bottom of the post with inadequate description. Android seems to still use Dnsmasq as a dns cache, so I used the --port option to change the dns listening port and added an iptables rule to intercept dns requests from clients and redirect them to the port we're listening on. I also changed the dnsmasq command to direct clients to it's dns server, rather than sending them the remote servers to query directly.
An example of how to reverse the changes made. The variable $NETWORK should be set to the ip that was originally assigned to the interface.
|
Thanks for the POC. Still not sure if I want to implement all of that though. 🤣 |
For days I'm looking for a way to have a fixed DHCP range for my pixel 5. |
It would be very nice if you implement this feature to reverse these annoying changes that Google made to Android. |
It does not add any meaningful security to my local network that is WPA encrypted anyway. I am not going to hijack my own dns. This is an annoying change that makes using android hot spot less convenient. |
Any news on this ? Really want this feature added, thanks |
Yes I had a similar issue, I was unable to set a IP address and I had to statically for ethernet for my USBC hub and I've never had the problem before I usually used kali Linux, on my phone as chroot o program routers and stuff before but I hadn't tried it on this device yet. There is no option for setting a static IP address for programming a router or something like I could not manually assign it at all plug up the USBC hub it gets what it gets like I couldn't figure it out for anything I finally gave up and went home and got my PC when I've done this before but not on this device Motorola generally was what I roll though outside of a few htcs the HTC One M8 and U11 other than that I've never had this problem before it's confusing wasn't an option anywhere for ethernet for that, there's a tether by (or hotspot)by ethernet in settings that was the only one I found. I was on Android 12 at the time but since I've taken a 13 update I would have to look, I doubt anything has changed. If there wasn't much trouble implementing a feature where you can assign your own IP ranges and addresses they would be helpful because I needed to give myself, on the host/server device an IP address and I was unable to. |
I think the best way to do this at the moment is to write an Xposed module to hook up relevant methods in |
Can we please get this feature , I have read on here and stackexchange that it can be done by some hacky method . |
Mygod is right, making a simple Xposed module or framework patcher is for sure the best approach, it's not VPN Hotspot's fault Android does this. I spent some time to make a patch if you want to try. It's missing GUI options, ideally you'd set an IP per interface, but here it is hardcoded so you can only safely apply to one interface at a time. DNSMasq's pid file should also go into getFilesDir().getPath() rather than /sdcard/. In be.mygod.vpnhotspot.net.Routing
And create a function to do the override, I placed it right under the function "masquerade"
In be.mygod.vpnhotspot.TetheringService
|
Thanks a lot @worstperson! Unfortunately that patch seems to hacky to be merged (and having a way to configure this for multiple tethering interfaces is probably also needed). :) |
@worstperson What do you think of @poqdavid's script in #537? It seems to me that that seems like a better solution than hacking around dnsmasq if it works. |
I have a suggestion maybe we could have both as an option like how IP Masquerade Mode works in the app for more compatibility |
I think it would be ideal to avoid keeping a separate instance of dnsmasq alive. |
@Mygod I think it might be better to just add the new address and route to the interface. Clients can use static addresses if they want to operate in that specific range and clients connecting with DHCP will still get a working connection and ip from the original range. Basically just my patch above without the lines to collect the nfmark, redirect DHCP, and spawn DNSMasq. |
Right. If all we want is a stable IP address for the clients to connect to, why not just create a new interface with a static IP (can make it /32 even)? This way we should break virtually zero things. |
Added static IP support via a |
No luck here, though I could be just dumb. The interface gets created and assigned, seems to be a single address assignment though. staticip Link encap:Ethernet HWaddr ae:0c:ad:fb:72:98 No route is created afaict, but also I don't know how a dummy interface can be used like this without bridging to the tether interface (which we can't do ofc). Is it supposed to be a virtual sub-interface or something like that? |
Ok, scratch that. Added a cidr to the default address and it sets up the address and route correctly now. Still not getting any traffic to pass between the client and phone in either direction though. |
What do you mean? It works fine for me. What do you get if you run EDIT: Also check that |
btw with my script DHCP still sends the randomly generated IP is there a way to change or prevent that? |
@poqdavid I did not plan to support that. What is your use case? |
Well, I use my phone's hotspot a lot to connect a lot to the internet and I run things like DNSCrypt, VBAN and it gets really difficult when the IP keeps changing so that's why I been using that script |
Okay but I don't see why you need all the clients to have static IPs? |
Well, I host things using Termux and every time IP changes, I got to change settings on both my phone and PC |
Just point your clients to the static IP instead and you'll be fine. |
Sorry for the late reply, was at work. I switched from rndis to wlan for testing today to see if it changes anything. I set Static IP to 10.0.0.1 to make things easier and assigned my computer to 10.0.0.2. Appending a cidr doesn't seem to effect the test results. The tests through wlan have no upstream, ethernet adapter is not available rn and I don't want to setup a reverse tether. Shouldn't matter though.
But no route to my computer
If I specify the interface it works?!
Now checking from my computer, I have a route to the phone
But packets never get a response
Testing with another device, this time with rndis0 as the downstream and wlan0 as an upstream
Specifying the interface still works
And still no response from the phone
|
@worstperson You don't assign your computer a static IP. Just use DHCP and connect to the new static IP, for example |
That works, I see what you were doing now. I didn't realize this was only for running services on the phone lol. Was thinking custom local ranges so I could (for example) block DHCP requests from reaching the phone and serve it on the client that forwards the tether to other devices, but fair enough. This is still a useful feature as-is. |
@worstperson Yes. Not sure why you would want to do that. If there is a reasonable use case, I can consider supporting it. |
The idea is to let me run servers with known fixed addresses from any arbitrary device(could be nfs or a webserver or a webclient for a torrent client, or any number of things) on my local network. DHCP was my example because I could use it to assign static addresses to devices on my network without having to set their network configuration. DoH/DoT servers and network wide adblocking are other great applications. If you additionally gave the option to drop DHCP requests from the static subnet in the app, it'd make it easy to just bridge the tether interface to ethernet in Windows and let any old router on the network provide that service. But me personally, I'd just patch the framework and be done with it. It's not a big ask to just diy it from my point of view. What you've already implemented is great and I'm perfectly happy leaving it there. |
Please post the link of Lsposed(xposed) module if you build it to bypass this silly restriction of Android |
I don't know if it's the Pixel 5 Android 11, but before on my Moto X4 Android 10 the IPs given to clients was always 192.168.43.XXX. With my Pixel 5, it is now completely random every time I turn the hotspot on. I do not know if this is Android 11, Pixel 5, or a bug in VPN Hotspot. I need my IPs to be static.
What it did on Moto X4
Desktop - 192.168.43.125
Server - 192.168.43.100
What its doing now on Pixel 5
Desktop 192.168.170.125
Server - 192.168.170.100
The bold is random everytime, but it does keep the last digits the same.
If this isn't a ug, could this be a feature request to allow control over this?
The text was updated successfully, but these errors were encountered: