This shell script automates Docker setup to redirect traffic from containers through host's VPN. In order to access resources protected by VPN (e.g. Forti Сlient VPN) through Docker container, the latter must be set up properly. For example, this could be a Build Target in Aurora/Sailfish SDK's Build Engine that uses Docker as virtualization technology.
- Check subnet mask for
docker0
interface:Ifip a
inet 172.17.0.1/16
subnet mask is returned, follow the steps below. - Create
sudo vim /etc/docker/daemon.json
file and add the following config:{ "bip": "172.17.0.1/24" }
- Set
ACCEPT
policy for theFORWARD
package redirection chain:Warning: this setting is preserver until the next system restart only, the default value forsudo iptables --policy FORWARD ACCEPT
FORWARD
package redirection chain policy isDROP
(prohibit package redirection). - Stop
docker
service:sudo systemctl stop docker
- Flush all chains for
nat
table:sudo iptables --table nat --flush
- Install
bridge-utils
package if necessary:sudo apt install bridge-utils
- Stop and remove
docker0
interface:sudo ifconfig docker0 down sudo brctl delbr docker0
- Restart
docker
service:sudo systemctl restart docker