October 25, 201411 yr Hello folks, So I'm new to unraid use to use freenas just building a pro box for the first time, and wanted to use docker for some apps, seems like a good way to go to me. Using 6 beta10a I have a server which is connected to 2 networks. eth0 192.168.1.0/255.255.255.0, normal network connected to most of my home machines internet etc. eth1, 192.168.2.0/255.255.255.0 my VPN network bascially another router connected through torguard. before some one asks why not just have everything go through Torguard ?well thats because I have a 150Mb link and the torguard connections don't run as fast as that so it's a massive waste of bandwidth. Anyway what I want to do is have my unraid server running on eth0 which it currently is, then use plex through docker and also have that running on my normal network, so that bits straight forward. But then I want to run the likes of transmission and Sickbeard etc through my VPN connection. So the question is how would I go about telling which network interface to use for a particular dock ?
October 25, 201411 yr Author Never mind I think I may have found my own answer :- https://docs.docker.com/articles/networking/
November 1, 201411 yr Author Ok so this is a royal pain the backside to do. I have it working but I'm not sure its the most elegant solution :- so just to recap, I have two networks going to 2 routers one VPN the other normal, I want things like my transmission container and SABnzb to download through the VPN connection, everything else to remain on my normal connection. internet ----router ------------192.168.1.0/24------ Unraid server 192.168.1.1 192.168.1.100 plex host connection 192.168.2.100-------------------------192.168.2.0/24---------------------------VPN router ---------------internet br1 running on eth1 192.168.2.1 Transmission Couch potato SABnzb etc. all running bridged so if you stop docker and create a brdige br1 and ad interface eth1 you'd expect any traffic hitting br1 to go out of the eth1 interface correct ? so I did this :- /etc/rc.d/rc.docker stop ifconfig eth1 plumb ifconfig eth1 up brctl addbr br1 brctl addif br1 eth1 ifconfig br1 inet 192.168.2.100 netmask 255.255.255.0 broadcast 192.168.2.255 up /etc/rc2.d/rc.docker start telling docker to use br1 instead of docker0 didn't work, all the traffic went out of eth0, even if I did a docker inspect ######## it showed an ip of say 192.168.2.5 for transmission the traffic still went out of eth0. what I ended up having to do was set the indiviual default routes in each container :- #get the container id of transmission and SAB Transid=`docker ps | grep transmission | cut -b 1-12` SABid=`docker ps | grep SABnzbd | cut -b 1-12` #now find the process id for the container. TransProcID=`docker inspect -f '{{.State.Pid}}' $Transid` SABProcID=`docker inspect -f '{{.State.Pid}}' $SABid` #create the links to allow us to use netns to change variables within the container. mkdir -p /var/run/netns ln -s /proc/$TransProcID/ns/net /var/run/netns/$TransProcID ln -s /proc/$SABProcID/ns/net /var/run/netns/$SABProcID # use netns to change the default root to use the vpn connection. ip netns exec $TransProcID route del default gw 192.168.1.1 ip netns exec $TransProcID route add default gw 192.168.2.1 ip netns exec $SABProcID route del default gw 192.168.1.1 ip netns exec $SABProcID route add default gw 192.168.2.1 I'm now trying to script this into my go file some how, but before I do is there any better way of doing this ? Thanks Steve
Archived
This topic is now archived and is closed to further replies.