lisenet / docker-openvpn

OpenVPN server in a Docker container.
MIT License
19 stars 2 forks source link

ovpn_genconfig -d parameter is not working #23

Open PMG-cpablo opened 5 months ago

PMG-cpablo commented 5 months ago

I'm using the command below to generate configurations and when I've added the "-d" parameter it doesn't work and produces an error.

I've tried added the OVPN_ROUTES+=("192.168.254.0/24") in the [ "${#OVPN_ROUTES[@]}" == "0" ] && [ "$OVPN_DEFROUTE" == "1" ] and it worked.

Question: Why did the "OVPN_ROUTES+=("192.168.254.0/24")" removed? and why it stopped working when I've removed that parameter?

Command: ovpn_genconfig -N -D -c -e 'client-config-dir ccd' -u udp://192.168.1.100:1194 -d -C 'AES-256-GCM' -a 'SHA384' -T 'TLS-<sensitive>'

Error: Traceback (last called is first): main() in /usr/bin/ovpn_genconfig:288 The command [ "$OVPN_DEFROUTE" == "1" ] exited with exit code 1. Cleaning up before Exit ...

lisenet commented 5 months ago

Hi, thanks for your comment. The 192.168.254.0/24 was a useless route added by the author of the original code as that's the subnet that he used. See this issue for more info.

This route has therefore been removed from this repository as it simply served no purpose.

carllacandazo commented 5 months ago

Thank you for your reply Lisenet.

Oh I see, but nothing changes kn the -d parameter aside from this static ip route. Do you have any idea why the -d produces an error if this route are redundant?

lisenet commented 5 months ago

The -d parameter disables the default route. Since there are no other routes defined (with 192.168.254.0/24 being removed), we should either remove the -d parameter from the configuration, or provide means for setting an alternative route that works with the client's subnet when the default route is disabled.

Would you be able to provide a bit more details about your use case here?

burner1024 commented 1 month ago

-d produces an error because there are no extra routes defined. VPN without default gateway and without any routes does nothing and makes no sense. [ "${#OVPN_ROUTES[@]}" == "0" ] && [ "$OVPN_DEFROUTE" == "1" ] works when OVPN_ROUTES is not empty because of short circuiting. Extra routes can be passed with -r.

Script works fine, but it should exit with a meaningful message when -d is used without -r, instead of just failing.