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

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.

Let’s say for simplicity sake that there are exactly one of each type and that all three are using default OS settings.

Since Windows XP SP2, the built-in Windows host firewall has been enabled by default. That means Syncthing on Windows must generally initiate connections.

Android includes support for iptables in Linux, so depending on the particular Android version, it might also block inbound connections by default. Also, since Android 11, security changes have been affecting network discovery. Together it makes it more likely that Syncthing on Android will have to initiate connections.

For Linux, the default state of iptables (superseded by nftables in newer kernels) largely depends on the distro. Ubuntu and many other distros ship with no firewall rules by default while Fedora defaults to blocking all inbound connections except for DHCP and mDNS (plus port 22 for SSH on server editions). So odds are that Syncthing on a typical Linux system will accept inbound connections on port 22000 without user intervention.

This results in a situation where Syncthing on Linux “works fine” while on Windows there might be no connections, only via a relay, or intermittent – e.g., won’t connect to Android, but connects to Linux. Same for Syncthing on Android where it might connect to Linux but not Windows without going thru a relay.

With global discovery and relaying disabled, it increases the odds that some devices won’t automatically find its peers without manually setting local network addresse(s) for each device.

Depending on how much data changes at any given time, focusing on having Syncthing always using the mesh network might simplify your setup, i.e., use the mesh network even when all your devices are at home.

It takes time to find the right combination of settings to make it work seamlessly, especially for your particular setup which isn’t typical.

I’ve currently got five different VPNs configured on my primary laptop (including a mesh VPN), four PCs and five Android devices (phones and tablets) of varying vintages, all with Syncthing. My backup phone and tablet go months at a time without being powered on, but Syncthing finds a connection shortly after launching. Some devices have global discovery and relaying enabled, some do not (I’ve never seen any of my devices rely on a relay).

I have static IP addresses everywhere. So, it’s easiest to hard code the address. I do use the meshnet IP address on my cell for talking to the other machines.

you have a lot more equipment than I do.

My Linux machines run in a Virtualbox VM. Booting from Windows.

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