I'm trying setting up at home an automated torrent client to download some big GIS databases I produce at work and release as .torrent files.
My home server is a Raspberry PI with one Ethernet interface, and the torrent client I choose is Transmission (the lightest in my tests). I connect to my work network through an OpenVPN client configuration.
Since Transmission can't be bounded to an interface but only to an IP, and the OpenVPN configuration (which I do not control) releases a dynamic IP address to each client on every connection, I created a script that launches the VPN on the Raspberry at midnight, reads the assigned IP, closes Transmission and restarts it bounded to this address. Transmission is running 24/7 on the server, so in the morning the same script stops the VPN, closes Transmission an restarts it bounded to the loopback interface, so no torrent traffic is produced but Transmission can still receive notification of new database releases and add them to the download queue (this is done with a daemon).
This works perfectly (the VPN clients sets the new default gateway), but I want to eliminate the hassle of closing and starting Transmission twice a day.
My idea is to setup a virtual interface eth0.1 with static IP and bound it to tun0 so that ALL traffic generated on eth0.1 will go through tun0, and then bound Transmission to the static IP of eth0.1 . This would allow Transmission to be up 24/7, but torrent traffic to be dropped when tun0 is down. When the VPN is up the torrent traffic will go through tun0.
It's the first time I'm dirtying my hands with IPtables as such, so I don't know if this will work nor how to do this, so I'm not asking for a solution but only to be directed to some good tutorials on the matter, since the ones I found were not on the spot...
Thanks.
0 Answers