Sync between a mobile phone(Cellular Network) and PC (tethered with a mobile phone via usb cable).

Hello guys. Is there a way to sync files between pc connected to a mobile phone (Cellular mobile network) using a USB tethering cable ? No WiFi in the house.

I think there could possibly be two ways to have this working:

  1. Without any special config - the devices should be able to connect through a relay using mobile data.
  2. Using a fixed IP address for the phone on the PC side in Syncthing - this should allow for a direct connection, however I haven’t tested such a configuration myself.

Do you mean whether a PC running Syncthing and a phone running Syncthing can sync over a USB cable?

Or, do you mean a PC tethered to a phone syncing to another PC?

If your phone supports it, could enable Wi-Fi hotspot mode so that your phone acts like a wireless router.

Yes.

I just tested it. I have a LAN connection between my cell and PC. Here is what you need to do:

The cell phone has an “Internal” IP address. This address won’t show up in Android settings. I found it using the Google Play app “IP Tools:” It will also be the default gateway for the Windows Ethernet adapter once USB Ethernet Tethering is enabled.

Connect the USB cable between phone and PC (Mine is running Windows 11).

Go to Android Settings/Connections/Mobile Hotspot and Tethering/ and enable USB tethering.

This will assign a new IP address to a new Ethernet network adapter in Windows. There will be a non Internet routable IP address. Open a command prompt and run “ipconfig”. Look for the new Ethernet adapter that starts with 192.168.x.x. Mine starts 192.168.237.x. The “default gateway” will also be the “internal” IP address of the phone.

On Windows, in the Syncthing admin console, in the remote devices area, locate and Edit the settings for the phone. Go to the Advanced tab and change (Temporarily) the “Addresses” setting from “Default” to “tcp://192.168.237.x”.

This will tell Syncthing to use the phones “Internal” IP address as the location for Syncthing running on the phone.

My Syncthing installation needed less than a minute to begin the connection and start synchronizing files between windows and the phone. I had over two gigabytes of data that needed to be synchronized to the Computer from the phone. it moved over very quickly as it should have because it was going over the USB cable.

In the Syncthing admin console, my phone shows up as “TCP LAN” in the Remote Devices area. Not WAN as it did with the address setting set to “Default”.

When you’re done synchronizing you can change the IP setting back to default or you can leave it that way if that’s the only way that you’re going to use it.

I hope I covered everything. Let me know if you run into trouble replicating what I did successfully to test your configuration.

Perhaps someone else can convert these instructions for someone who is using Linux on the PC. I’m not aware how to Ethernet tether a cell phone to a Linux machine.

1 Like

Thank u for your two options. :slight_smile: What’s a physical relay location ? Who owns a relay ?

Thank u for your answer. :slight_smile: I mean can PC running Syncthing and a phone running Syncthing sync over a USB cable?

Thank you very much for your very detailed explanation. :slight_smile: I’m a Linux beginner. I’ll try to convert your instructions to Linux and will bring updates back. U brought me very close to the solution.

1 Like

See…

Yes…

Here’s a quick bird’s-eye view diagram:

In a tethering setup, an Android device effectively acts like a virtual network router whether a PC is connected via USB cable or Wi-Fi:

  • USB tethering: If a PC supports RNDIS, a virtual network interface is created. Not all versions of operating systems support RNDIS. (Note that this is very different from the “USB CDC” standard used by USB Ethernet adapters.)

  • Wi-Fi tethering: The Android device acts like a wireless access point. Almost any operating system that supports Wi-Fi (aka., IEEE 802.11) will work, although if a wireless adapter only offers 802.11a, it’s not guaranteed.

Android offers the PC a private IP address via DHCP with the private IP address of the phone’s virtual network router as the network gateway.

On the Android device, its cell modem and Wi-Fi adapter get internet access via an ISP (the virtual network router effectively has dual WAN connections).

From the perspective of web browsers and other network apps on the PC, it’s just another Ethernet link connected to a (mini) LAN.

Syncthing…

Syncthing on the PC sees the virtual network interface (e.g., 192.168.123.10) that just happens to be connected via a USB cable to the Android device.

Syncthing’s local discovery process will result in the PC and Android devices finding each other on what appears to be a private LAN. There shouldn’t be any need to change Syncthing’s default settings (global discovery, NAT traversal and relaying can be optionally disabled).

The only potential speed bump is when the PC has a firewall, but since the virtual network router on Android has all network ports open, it’s generally not an issue unless the PC firewall filters both inbound and outbound connections.

All of the current desktop Linux distributions generally include the RNDIS drivers. The only exceptions might be distros optimized for really low-power systems.

To check your Linux system, search the kernel modules directory with the following command:

find /lib/modules/ -name rndis*

Or use the modinfo command to see if the rndis_host kernel module is installed:

modinfo rndis_host

If either command returns an error, USB tethering isn’t supported.

If the RNDIS kernel module is available, then it should be plug-n-play. NetworkManager will automatically detect the new network interface and auto-configure it.

Syncthing will automatically bind to the new network interface (unless it’s been configured to only bind to specific interfaces).

1 Like

You’re very welcome.

By the way, I just installed Syncthing in a Virtualbox VM running Linux Mint 21.1.

The USB connection was immediately recognized as a LAN connection in Linux and assigned a private IP address.

Then, I installed and ran Syncthing.

Android discovery is broken as you may know, so it won’t automatically discover the Linux computer, However, Linux WAS able to discover the phone running syncthing.

I shared my pictures folder to Linux and it synched just fine.

I did NOT need to customize any settings in Syncthing or Linux.

You should have no troubles.

I accidentally left WiFi running on Windows when I had the USB connection to my phone enabled.

So, my Windows Syncthing installation had TWO paths to the Internet and the Cell phone.

My Windows installation of Syncthing began synching files over it’s WAN CONNECTION to the phone, moving data over the cellular network.

syncthing should have realized that there were two paths to the cell phone and chosen the LAN connection over the WAN connection only for some reason it did not.

The reason that I manually edited the IP address location of the cell phone was because the software was going the wrong way of the two possible ways that it could get to the phone.

Windows had a valid WiFi connection to the Internet, and it was also connected via USB to the phone. Windows effectively had two paths to sync with the phone and it chose the WAN connection and Not the LAN connection.

Is there a way to tell Syncthing to prioritize LAN over WAN?

I did find a setting in windows that lets you change the priority of the network adapters themselves but it would be nice if syncthing could be set to use a LAN in priority over a WAN.

These commands worked fine on my Mint 21.1 installation.

My Linux runs in a virtual machine so I wasn’t sure if I would be able to get the usb connection to work properly with my cell phone in that environment and it turns out that it does work fine.

Virtualbox let me connect my cell as a LAN adapter.

Syncthing works perfectly.

From Syncthing’s and any other network application’s point of view, both the Wi-Fi and USB links are on private LANs.

There is code in Syncthing that looks at network latency, but I don’t know how if it goes as far as analyzing the entire network path.

Did Syncthing on Windows use a relay to get to Syncthing on Android when it connected thru the Wi-Fi connection?

Syncthing can be told to bind to only specific interfaces, but I’m not aware of a way to assign priority.

Network interfaces look the same to an application (see OSI model). In terms of which network link is best to use, it’s a distinction just in our eyes.

Adjusting the routing metric is one of the recommended methods. There’s also traffic shaping where packets from certain processes can be directed to specific network interfaces.

Syncthing does grativate to a LAN connection over a WAN connection, so there must have been something that caused it to find Syncthing on Android via the cellular link instead of the USB link.

Good question. I don’t recall for certain, only I think it must have. I would need to hook it up and run the test again.

How would I do that? That’s useful information.

OK, when I have time, I run a few trials and see what typically happens.

In Syncthing, under Actions → Connections, there’s a “Sync Protocol Listen Addresses” box.

The default value is default, which tells Syncthing to bind to all available network interfaces on port 22000.

To bind to port 34567 on the network interface that’s been assigned the IPv4 address 192.168.1.2, use the value tcp4://192.168.1.2:34567).

The Listen Addresses section of the Syncthing Configuration has more details.

1 Like

Thank you, easy enough.

One more question.

if I have two devices that haven’t synced in a while they turn to a status of “Disconnected (Inactive)”

When I start syncthing on both devices, they don’t talk to one another and update. I find that I need to go in to the server settings and change the location of the remote device from dynamic to its actual IP address and then syncing begins.

Then I switched them back to dynamic.

Other than this manual workaround is there a command line switch or something else that can force two devices to begin updating each other after they are in this status?

I don’t recall what the threshold is, but a device that hasn’t been responding to pings from other peered Syncthing devices will eventually switch from “Disconnected” to “Disconnected (Inactive)”.

Once Syncthing is running again on a formerly dormant device, it’ll automatically reconnect with its peers.

Based on what you need to do, it sounds like a network issue.

If you wait a few minutes, does it eventually use a Syncthing relay?

Did you disable global and/or local discovery?

What OSes are the two devices?

Do the two devices stay connected when you do that?

Not that I’m aware of. You should enable some of the debugging options and then review the log on each device.

Global and Relay are off everywhere. I only have servers at home, on the same network.

The devices are Windows,Linux and Android.

Yes.

I also have a free mesh network running on all devices and when I hard code the private IP address everything can sync. I primarily use this feature to synchronize my cell phone when I’m away from home with my computer at home. Any pictures I take while I’m away can get synchronized to my server at home over the cellular network.