docker-openvpn icon indicating copy to clipboard operation
docker-openvpn copied to clipboard

How to generate client with specific port ?

Open kevincaradant opened this issue 8 years ago • 5 comments

Hi

I read all the documentation. I think I understood a lot of things as have two instances of the docker-openvpn to have two protocol / port different BUT I didn't understand how to generate a client with the good port. I got always a client with 1194. So for the moment I edit the file at hand.

I tried: --port or -p to generate with the good port but starting with that I'm sticked:

docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME
docker-compose run --rm openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn

If you have any idea, I take it. Maybe I miss something in the doc, you will tell me :)

Thank you in advance,

Regards

kevincaradant avatar Dec 18 '17 19:12 kevincaradant

easyrsa is a separate CLI utility, looking at its source ( build-client-full in easyrsa-v3) I see that there are only 2 parameters (username which is also the filename and an optional password), so you cannot set the port name using this call, I think. I guess you can install easyrsa locally and play with it, maybe you can find a command that suits you.

bgadrian avatar Mar 11 '18 16:03 bgadrian

In my opinion easyrsa is in no way connected to this issue.

What @kevincaradant wants is to edit the $OVPN_PORT at https://github.com/kylemanna/docker-openvpn/blob/master/bin/ovpn_getclient#L40, which is not possible right now as it comes from the ovpn_env.sh script.

marvin-w avatar May 30 '18 20:05 marvin-w

I want to do exactly what @marvin-w describes. The idea is to run several different VPNs on the same host.

LindezaGrey avatar Sep 21 '18 18:09 LindezaGrey

Hey again, i adapted the ovpn_getclient script to allow a custom port:

https://github.com/LindezaGrey/docker-openvpn/blob/master/bin/ovpn_getclient

you would call it like this: docker-compose run --rm openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn 1195

Of course you would have to build your own docker image first.

best regards!

LindezaGrey avatar Sep 30 '18 19:09 LindezaGrey

I change the port using a simple string replacement inline with the sed command like this:

openvpn ovpn_getclient $CLIENTNAME | sed "s/1194 udp/$NEW_PORT udp/g" > $CLIENTNAME.ovpn

h3ct0r avatar Jan 21 '21 22:01 h3ct0r