Static IP for USB Tethering

How can I set a static IP for the USB tethering?

If I connect my phone and enable usb tethering, my balena device gets connected to the internet thru my phone. The problem is its local IP address.

I’d like to assign a static IP address, but it changes once I reboot and tether again…
192.168.42.10 => 192.168.42.9 => … … …

Here is my /boot/system-connections/resin-tethering file to assign a static IP:

[connection]
id=my-ethernet
type=ethernet
interface-name=enp1s0u1u1
permissions=
secondaries=

[ethernet]
mac-address-blacklist=

[ipv4]
address1=192.168.42.150/24,192.168.42.129
dns=8.8.8.8;8.8.4.4;
dns-search=
method=manual

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

192.168.42.129 is the IP address of the Gateway, which was obtained by netstat -nr command on my Raspberry Pi. (Of course, tried 192.168.42.1 too.)
enp1s0u1u1 is the new interface name that was changed from usb0 once tethered.
I tried eth0, usb0, enp1s0u1u1, but nothing worked. Still 192.168.42.9

Appreciated if you could help.

Cheers!

Hi,
your configuration seems to be correct, I was actually able to make the tethering work on my Pi3 with your config. The only difference seems to be that the adapter does not get renamed on my Pi3 and remains usb0 even after I enable tethering. Could you please let us know what version of RPi are you using?

Another thing is that you need to reboot the device after creating the config file in /boot/system-connections for the configuration to actually take effect, could you confirm you did that?

Hi, @mtoman
Thanks for your reply!

I am testing with Raspberry 4 at the moment, but will use Intel NUC afterwards.

So you got a static IP address? 192.168.42.150?

I actually edited the file on my Windows PC after plugged the microsd card in.

Cheers!

Can you please grant support access to the device so we can take a look? If you don’t want to share the device uuid publicly, please DM me the id and I’ll add it to the ticket internally.

We finally changed our plan to use the dynamic IP address…

Thanks!