Sync Linux and Andorid over USB tethering but without internet

I did the following.

  1. Connect My Linux PC and my Android smartphone with a USB-c cable
  2. Enable USB tethering in my Android smartphone.
  3. Run syncthing on both PC and smartphone, and configure the IP addresses correctly.

After doing these steps, I find myself in two situations.

  1. If my phone is connected to 4G data or to a Wifi network, Syncthing is able to work and sync files between the smartphone and the PC.
  2. If my phone is not connected to any network and is only connected with USB-c cable, syncthing never discovers the other device, and no sync is happening.

What do syncthing seems to need an internet connection from the smartphone to sync between devices?

I read this topic which explains why it should work: Sync between a mobile phone(Cellular Network) and PC (tethered with a mobile phone via usb cable). - #9 by gadget but in my case, it does not, unless the smartphone has an internet connection.

I’m not certain the discovery mechanism will work over usb. You might need to figure out the ip addresses assigned over tethering and configure device addresses manually.

If you don’t mind, on your Linux PC (while tethered via USB to your Android phone), could you post the output from the following network command?

ip address show

I’m a bit in the same situation, I’ve got my Linux pc tethered, but via wifi, no usb, to my android phone witch is connected on the internet using my sim card 5G. I try some different settings.

On the android phone I check ‘run on wifi’ + ‘run on metered wifi’ and the devices don’t connect. When I check ‘run on mobile data’ they connect. Then, what I find weird, with these three boxes checked, if I disable the 5G on the phone, so I don’t have any internet, Syncthing is keeping on connecting the devices.

At this point the result is ok for me, as my main goal is to use Syncthing without consuming my mobile data on the 5G, but it’s not easy to use. So on my pc, I disabled the dynamic addressing in the settings of the device known as my phone, and affect the TCP address that is displayed when the connection work. But on the phone when I uncheck ‘run on mobile data’ the devices become disconnected.

Is there a convenient way to have Syncthing in this wifi tethering situation, with being sure that it doesn’t use mobile data ?

Here is the print of ‘ip address show’

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever

2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,DYNAMIC,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 8c:16:45:90:2a:f5 brd ff:ff:ff:ff:ff:ff

3: wlp2s0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether b0:fc:36:62:65:8f brd ff:ff:ff:ff:ff:ff inet brd scope global dynamic noprefixroute wlp2s0 valid_lft 1907sec preferred_lft 1907sec inet6 fe80::80ce:1097:d339:74ea/64 scope link noprefixroute valid_lft forever preferred_lft forever

Ah, “hotspot” mode (the network configuration is very different between hotspot and tethering modes).

In tethering mode, the phone acts like a USB Ethernet adapter (the PC doesn’t see the phone as a phone). Then inside the phone, that virtual network adapter is connected to a virtual network router where the phone is also connected. The phone’s Wi-Fi -or- cell modems provide the WAN connection to the internet.

In hotspot mode, to the PC, the phone looks like a Wi-Fi router for the LAN connection while the phone’s cell modem provides the WAN connection to the internet (the Wi-Fi modem is in use for the hotspot).

Was the phone in airplane mode or was it just mobile data turned off?

no the phone wasn’t in airplane mode, just mobile data turned off. Thank for your answer, and furthermore, thank for your explanations.

I wasn’t able to replicate what you experienced with 5G disabled while the same run conditions were enabled in Syncthing.

From the perspective of the phone, there’s no Wi-Fi connection because the phone itself is providing the Wi-Fi connection – it’s either a hotspot or it’s a client to an external hotspot (it generally can’t be both at the same time, though there might be phones that can).

With “Enable run conditions” on, Syncthing is restricted to running with an external Wi-Fi connection or mobile data connection.

So disabling “Enable run conditions” allows Syncthing to use any available connection, including the hotspot’s virtual network switch. Of course, that means Syncthing could use the mobile data connection, so that needs to be disabled.

As you already mentioned, telling Syncthing on the PC to use the IP address of the phone is an option. You’ll also need to disable global discovery in Syncthing if you want no mobile data usage while leaving the cell modem on.

I’m opening a new topic, I don’t want to pollute this one, as you specified, my subject is about using the phone as a hotspot.

There is an app in Google Play called “IP Tools: Wifi Analyzer”. It will give you the proper internal IP address of your phone, which is what syncthing will be using.

Tethering and hotspot are different and will have unique IP information.

I’ve tested USB tethering between my Android phone and Linux computer, and it works when configured properly.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.