Solution (TL; DR;)
Create the script /etc/openvpn/fix-routes.sh
with the following contents:
#!/bin/sh echo "Adding default route to $route_vpn_gateway with /0 mask..." ip route add default via $route_vpn_gateway echo "Removing /1 routes..." ip route del 0.0.0.0/1 via $route_vpn_gateway ip route del 128.0.0.0/1 via $route_vpn_gateway
Add the executable bit to the file: chmod o+x/etc/openvpn/fix-routes.sh
. Change the owner of this file to root: chown root:root/etc/openvpn/fix-routes.sh
.
Add the following two lines to your configuration:
script-security 2 route-up /etc/openvpn/fix-routes.sh
explanation
Openvpn adds routes for the following networks: 0.0.0.0/1
and 128.0.0.0/1
(these routes cover the entire range of IP addresses), and Docker cannot find the range of IP addresses to create its own private network.
You need to add a default route (for routing everything through openvpn) and disable these two specific routes. The fix-routes
script does this.
This script is called after openvpn adds its own routes. To run the scripts, you need to set the script-security
parameter to 2
which allows you to run bash scripts from the openvpn context.
thanks
I would like to thank the author of this comment on github , also thanks to the support of ovpn .
source share