0

When I run sudo openvpn foo.conf I do not yet have a default gateway defined.

Once the connection is established, I run sudo ip route add default via X.X.X.X, where X.X.X.X is the local IP of the newly created tun interface.

That works perfectly fine.

Avoiding the manual step, I would like OpenVPN do this for me. So I add route default to the configuration.

This fails with: NOTE: unable to redirect default gateway -- Cannot read current default gateway from system

Why does it want a current default gateway when I would replace it anyway? How can I have OpenVPN add the default gateway correctly (without using external scripts)?

user569825
  • 351
  • 3
  • 6
  • 12
  • 2
    This `;push "route 192.168.10.0 255.255.255.0"` is in my config file. I believe it's one of the default, but commented options. You may be able to add `push "route 0.0.0.0 0.0.0.0"` to define a default route. – user38537 Dec 20 '18 at 22:34
  • You can't `redirect-gateway` when you don't actually have one to redirect! – Michael Hampton Dec 20 '18 at 23:15
  • 1
    @user38537 I have no control over the other side. Anyway, 0.0.0.0 is not the same as "default". Tried that already with `route 0.0.0.0..`. @Michael: Not using said option; – user569825 Dec 21 '18 at 13:34

1 Answers1

0

The best practice of the openvpn is adding the two routes (0.0.0.0/1 and 128.0.0.0/1) to avoid replace the original default route. For this you can use the route options in the open vpn client configuration file:

route 0.0.0.0 128.0.0.0
route 128.0.0.0 128.0.0.0
Anton Danilov
  • 5,082
  • 2
  • 13
  • 23