OpenVPN and BTsync


Recommended Posts

I have BTsync running on several boxes, all of them Windows 7, except one.

That one is running on an Ubuntu server which functions as my NAS. I also run OpenVPN on that server (outgoing). I have set up routing so that any requests to the LAN (e.g. are routed through eth0 instead of tun0 (OpenVPN's virtual adapter).

sudo ip rule add from table 128
sudo ip route add table 128 to dev eth0
sudo ip route add table 128 default via

This works for all the other applications I run on that server... except for BTsync. When the OpenVPN daemon is running, it cannot find the other machines running BTsync. I have enabled lan_use_tcp in the config file, and have Search Lan turned on for all sync'd folders.

I'm a bit of a Linux newb, particularly when it comes to networking/firewall/router rules.

Any advice would be appreciated. It's kind of a PITA to have to stop my OpenVPN daemon every time I want the server to rediscover the other machines. (Once they're discovered, they work, even with OpenVPN turned on... until the next time they go offline for a while, or until the next time I stop and start BTsync on the Linux box.)

Link to post
Share on other sites

Hey there.

Without any profound information and investigation, I would guess that it's broadcasting your're upset on.

The btsync "Search LAN" feature completely relies on default broadcast.

For a simple explanation (even though it's not that simple in all cases), it's like this:

If your local network has, that means that is the very first available IP in this range, the very last. The number is your network name and not available as IP address. The number isn't available as IP address since that's the broadcast address.

Broadcast addresses are defined as "everybody can address this, and everybody is allowed to respond". And ontop of this, boradcasts don't get routed, by default. Broadcast requests are bound to the very local wire.

I guess you have to investigate how to allow OpenVPN to route broadcasts, then you'll be fine. Or you should use the known hosts feature and assign the VPN IPs here. This way is ost likely the easier one.



Link to post
Share on other sites

I wish i could help more than this, but this is my ip table:

ip route show via XXX.241.65.1 dev tap0

default via YYY.196.15.1 dev eth0 metric 100

YYY.196.15.0/24 dev eth0 proto kernel scope link src YYY.196.15.26

ZZZ. via YYY.196.15.1 dev eth0 via XXX.241.65.1 dev tap0

XXX.241.65.0/25 dev tap0 proto kernel scope link src XXX.241.65.6

but I think mine works because i allow some communication in on eth0 to ports 3000,3838, but all outgoing is via tap0.

Link to post
Share on other sites

Thanks for the responses!

@Stephan: I thought the default broadcast address was x.y.z.255 on a /24 network?

The "known hosts" feature is a good suggestion. I had tried it before, but I thought I needed to configure it on the Linux box. Turns out, it's the other peers who needed the Linux box's address.

That works for me because I use static addressing assigned via DHCP, but the mobile client doesn't seem to have a "known hosts" option. I forgot to mention that one device is an Android phone that backs up its Titanium Backup folders to the Linux box.

As for finding out how OpenVPN handles broadcasting, I think I can't figure out the right search terms, as I've come up with nothing useful. Also, in this case, the remote OpenVPN server is 3rd party; I have no control over settings server-side, which complicates my google search on how to set this up.

@Alajjana: Routing tables are a bit beyond me. This is mine now: via dev eth0 via dev tun0 dev tun0 proto kernel scope link src dev eth0 proto kernel scope link src via dev tun0 via dev tun0
default via dev eth0 metric 100

I use tun rather than tap. is my router. is the address assigned by the remote OpenVPN server

Any advice you can provide (along with CLI commands to implement) would be welcome.

Link to post
Share on other sites

Found the solution! I remembered having configured my backup software to always use eth0, and I managed to find the little text file I wrote myself.

Here was the solution:

Download bind.c from


Copy to a temp dir and do:

gcc -nostartfiles -fpic -shared bind.c -o -ldl -D_GNU_SOURCE
cp -i /usr/lib/

Then change the start line for any software needing to go out on local to:

BIND_ADDR="[local adapter address]" LD_PRELOAD=/usr/lib/ [full path & command line]


BIND_ADDR="" LD_PRELOAD=/usr/lib/ /usr/bin/btsync restart

Voila! Problem solved!

Link to post
Share on other sites


This topic is now archived and is closed to further replies.