# How does syncthing chooses which interface to use / when does it stop looking for a better one?

**URL:** https://forum.syncthing.net/t/how-does-syncthing-chooses-which-interface-to-use-when-does-it-stop-looking-for-a-better-one/18729
**Category:** Support
**Created:** [July 20, 2022, 8:12am UTC](https://forum.syncthing.net/t/how-does-syncthing-chooses-which-interface-to-use-when-does-it-stop-looking-for-a-better-one/18729 "2022-07-20T08:12:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hiq](https://forum.syncthing.net/user_avatar/forum.syncthing.net/hiq/32/8830_2.png) [@hiq](https://forum.syncthing.net/u/hiq)
#### Post date: [July 20, 2022, 8:12am UTC](https://forum.syncthing.net/t/how-does-syncthing-chooses-which-interface-to-use-when-does-it-stop-looking-for-a-better-one/18729/1 "2022-07-20T08:12:17Z")

</div>

I have some wireguard tunnel set up to make a computer reachable from another via another server, no matter where I am. These two computers also share files via syncthing.

I’ve seen in the past that the wireguard interface was used by syncthing when it was up. But it has higher latency and lower bandwidth than a (real) direct connection, so ideally syncthing would still try to establish one outside of wireguard.

I know that syncthing makes a distinction between a relayed and non-relayed connection, and gets rid of the relayed one if possible. Does it make further distinctions, e.g. looking at the number of hops / latency / bandwidth? Or is it stuck with the first (seemingly) direct connection it finds? Is it possible to ensure that connections are used in this order, depending on availability:

1. direct
2. wireguard
3. relayed

?

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [July 20, 2022, 8:44am UTC](https://forum.syncthing.net/t/how-does-syncthing-chooses-which-interface-to-use-when-does-it-stop-looking-for-a-better-one/18729/2 "2022-07-20T08:44:17Z")

</div>

No, it looks at the CIDR of the destination address and prefers local over internet ip addresses.

Sounds like you should configure static addresses for devices if you know exactly how you’d like them to connect.

---

<div class="post-metadata">

### Author: ![hiq](https://forum.syncthing.net/user_avatar/forum.syncthing.net/hiq/32/8830_2.png) [@hiq](https://forum.syncthing.net/u/hiq)
#### Post date: [July 21, 2022, 6:40am UTC](https://forum.syncthing.net/t/how-does-syncthing-chooses-which-interface-to-use-when-does-it-stop-looking-for-a-better-one/18729/3 "2022-07-21T06:40:00Z")

</div>

Ok, so my local ip address I get from the wireguard interface will be preferred over a public ip, that’s not ideal in my situation.

Unfortunately I can’t use static addresses as my public IP regularly changes. I guess my best option would be to play with `allowedNetworks` depending on whether I currently want my wireguard connection to be used or not.

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [August 20, 2022, 6:40am UTC](https://forum.syncthing.net/t/how-does-syncthing-chooses-which-interface-to-use-when-does-it-stop-looking-for-a-better-one/18729/4 "2022-08-20T06:40:09Z")

</div>

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