kylemanna / docker-openvpn

🔒 OpenVPN server in a Docker container complete with an EasyRSA PKI CA
https://hub.docker.com/r/kylemanna/openvpn/
MIT License
8.62k stars 2.37k forks source link

Is it possible to change the server's subnet by editing the `openvpn.conf`? #753

Open darkasassin44 opened 11 months ago

darkasassin44 commented 11 months ago

Here is my situation.

  1. I ran this command to generate the server configurtation:

    docker run --rm \
    -v $OVPN_DATA_DIR_TEST_0:/etc/openvpn \
    kylemanna/openvpn ovpn_genconfig \
    -u udp://www.mydomain.com \
    -s 10.95.0.0/16 \
    -n 8.8.8.8 \
    -n 8.8.4.4 \
    -n {myDns1} \
    -n {myDns2} \
    -p "route 172.18.0.0 255.255.0.0"
  2. Then, I recognized that I mistyped the subnet argument -s 10.95.0.0/16, which is already occupied with another existing OpenVPN server. I should type something like -s 10.99.0.0/16, instead of -s 10.95.0.0/16. Therefore I edited the openvpn.conf file, from server 10.95.0.0 255.255.0.0 to server 10.91.0.0 255.255.0.0 to change the server's subnet scope and restarted this container.

  3. Client can connect to VPN server. Client can ping to server(10.95.0.1), and server can ping to client either. (also connection log can be found via docker logs) But the client cannot use the internet.

I scrutinized every part of the problem that could arise, like routing tables for both host and container, my custom docker network which is still working well with other OpenVPN container, DNS test, and so on. I'm already running a several OpenVPN container in this single host for more than a year, and I think that there is no problem with setting or configuration in host OS or docker.

I strongly suspect that it is caused by a typo in the subnet when executing the ovpn_genconfig command, and that this is not reflected by modifying the openvpn.conf file. Because when I re-entered the ovpn_genconfig command without a typo after everything was cleaned up, it all worked as expected.

If anyone knows about this, please let me know if my assumption is correct or not.

davoam commented 10 months ago

Maybe this can help

AndreCostaaa commented 1 month ago

Had the same problem after trying to change the subnet on the openvpn.conf file Rerunning the ovpn_genconfig script solved it for me aswell. Thank you :+1: