idlab-discover / easy-openvpn-server

Plug-and-play OpenVPN server which generates server and client config files for you
https://snapcraft.io/easy-openvpn-server
GNU Affero General Public License v3.0
69 stars 9 forks source link

Wrong IP address #22

Closed jimafisk closed 1 year ago

jimafisk commented 1 year ago

First I want to just that this project is amazing and really helps lower the barriers to setting up a VPN, so thank you very much!

I'm trying to set this up on a Digital Ocean droplet. The interesting thing with these servers is that I assigned a Reserved IP (178.xxx.xxx.xxx) but it also still has a different ipv4 address (143.xxx.xxx.xxx) listed in my Digital Ocean dashboard. When I try to add a client using this project it seems to use the default ipv4 address, which I assume changes periodically (or at the very least couldn't be transferred to another droplet):

INFO: Public addresses according to get_public_addresses: [IPv4Address('143.xxx.xxx.xxx')]

Is there a way to get this to use the Reserved IP instead? Thanks!


Edit: I was able to figure this out before posting, but thought I should post here anyways in case it helps someone out: https://docs.digitalocean.com/products/networking/reserved-ips/how-to/outbound-traffic/

Couple of things to note:

  1. You actually use the specific IP address 169.254.169.254 in the curl command (don't replace this with another IP). This is a specific internal address on your server.
  2. When running the easy-openvpn-server add-client command it will still show the ipv4 IP address, but if you connect to the VPN your traffic will get routed through the Reserved IP (just type "my ip" into Google to verify).
merlijn-sebrechts commented 1 year ago

Oh, I just realized what you did:

  1. The client connects to the 143.xxx.xxx.xxx address in order to setup the vpn.
  2. Using these instructions, you configured the server to send outgoing traffic through ip 178.xxx.xxx.xxx.

So the traffic from your client now goes like this:

image

That is why your client IP has now changed to the 178.x address. However, your client still connects to the 143.x address. If you want to change this, run the following commands. By runnin

# Set the correct IP for client configs
sudo snap set easy-openvpn-server public-address=178.x.x.x
# re-generate client config
sudo easy-openvpn-server show-client default > default.ovpn

Then use the new config on your client. Now the VPN should use 178.x.x.. for both inbound and outbound traffic.

jimafisk commented 1 year ago

You're 100% right, thanks for the great visual, that makes things easier to understand! Very cool that you can change the inbound IP as well. This project is amazing, thank you :raised_hands: