2

My phone Moto X 4 has LineageOS 17.1 installed and is rooted with magisk. I use the phone's hot spot as main mean to connect to the internet.

In this scenario the android device acts as DHCP server, therefore distributing random IP addresses in the 192.168.43.0/24 sub range. I would like to assign static IP addresses to my devices, then i can connect to them trough SSH easily. The clementine android remote also requires my laptop to be available on a fixed IP.

I do not like to carry a travel router for this basic network ability.

On android 9 this was possible by setting up the dnsmasq.conf file, setting the file permissions and configuring SELinux rules.

This workaround helped me to set it up.

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

4
  • 2
    Android 10 deprecated dnsmasq DHCP server in favor of Java implementation which we cannot configure by simply editing a file. Creating hotspot from commandline should work though: How to create a wifi hotspot from the terminal? unless a better solution is found. Feb 2, 2021 at 21:05
  • There's a setting in global namespace: tether_enable_legacy_dhcp_server but it's meant to be used only for tests. On Android 11, however, it seems that device_config put connectivity tether_enable_legacy_dhcp_server true should do the trick: android.googlesource.com/platform/packages/modules/Connectivity/…. But I haven't tested. Feb 2, 2021 at 21:07
  • @IrfanLatif it seems that the most convenient way to achieve static IPs would be to ask the android device for it. Using the debian network-manager tool nm-connection-editor and set up a static IP to the tethered connection. I just don't know if that would conflict with the randomized tethering IP that has been introduced with android 9.
    – kocjs
    Feb 3, 2021 at 15:30
  • 1
    You are talking about Requested IP Address option sent in DHCPDISCOVER message. Yes that should work with any standard DHCP server implementation. But if you control all of the clients and don't mind manually configuring them, then there's no need to use DHCP at all. Set a static IP address on each client and disable DHCP client service. But if even one of the clients is using DHCP, the IP conflict may occur and DHCP server may refuse the requested IP address. Feb 3, 2021 at 17:24

2 Answers 2

1

DHCP is Dynamic Hosting Control Protocol. It give you dynamic IP address. Static IP address you need to lease. DHCP server give ip address to host, it is not static.

You can assign IP address. Go to setting / connection / select network / manage network setting / Advance option. Here you can give static IP address.

After Question Update.

Go to Wi-Fi / setting / Advance networking / DHCP IP reservation / Here add static IP address and also select device for static IP address.

Network admin use static IP address for shared device like ZEROX machine printer.

3
  • Thank you for your answer. This would be ideal. Still, I do not have this settings, witch phone and what version of lineageOS are you using?
    – kocjs
    Feb 2, 2021 at 16:27
  • This may not be in built OS option. I have done on Google Wi-Fi app. Some router and hub driver software has such setting.
    – aliz lopaz
    Feb 3, 2021 at 9:03
  • I think there's a small language barrier/translation, here. But, just to clear, static addresses generally do not need to be "approved" by the DHCP server. There are serval ways around it, generally through "static mapping" - but, ideally, your static maps and your DHCP pools should not overlap.
    – RVT
    Sep 5, 2021 at 11:10
1

As a workaround, you can likely convince each individual device to request the same IP address, or set them statically. I understand this may be a PITA if you havemany devices, though.

That said, setting a LONG lease time may also help mitigate issues, as devices wait until half way through their lease before they re-request a lease. They also default for asking for the previously used IP address, first, the next time they reconnect... it's up to the DHCP server to confirm that request, however.

2
  • thanks. As a workaround i assign an additional static IP in Linux. On android I set a static IP if possible. I did not have a conflict so far. Still, it's not a valid answer.
    – kocjs
    Feb 14, 2021 at 4:25
  • i think this is how my previous set up worked with android <9. I just connected to the hotspot once and on every subsequent reconnection, i got the same IP assigned. It is not working after i flashed with a later Custom ROM(android 11) Feb 17, 2021 at 18:01

You must log in to answer this question.

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