Is there a way to randomize my selected OpenVPN-servers?
I have a ProtonVPN account and connect to VPN servers at all times for internet privacy. Unfortunately, ProtonVPN does not offer a Linux-based client at this point, so they advise to connect to their servers via OpenVPN.
I installed the packages openvpn
network-manager-openvpn
and network-manager-openvpn-gnome
to the official guide to load their .ovpn configuration files.
The connection works fine, but whenever I connect to a VPN on Ubuntu, I have to manually select a specific server from the preconfigured .ovpn files. Instead, on their Android client, for example, I can just tap a button and connect to a random server without even thinking about it.
Is there any way to make the network manager select a random .ovpn config, instead of me having to select one manually? (I'm not afraid of the command line, but preferrably without adding another PPA to my system.)
networking server network-manager vpn openvpn
add a comment |
I have a ProtonVPN account and connect to VPN servers at all times for internet privacy. Unfortunately, ProtonVPN does not offer a Linux-based client at this point, so they advise to connect to their servers via OpenVPN.
I installed the packages openvpn
network-manager-openvpn
and network-manager-openvpn-gnome
to the official guide to load their .ovpn configuration files.
The connection works fine, but whenever I connect to a VPN on Ubuntu, I have to manually select a specific server from the preconfigured .ovpn files. Instead, on their Android client, for example, I can just tap a button and connect to a random server without even thinking about it.
Is there any way to make the network manager select a random .ovpn config, instead of me having to select one manually? (I'm not afraid of the command line, but preferrably without adding another PPA to my system.)
networking server network-manager vpn openvpn
add a comment |
I have a ProtonVPN account and connect to VPN servers at all times for internet privacy. Unfortunately, ProtonVPN does not offer a Linux-based client at this point, so they advise to connect to their servers via OpenVPN.
I installed the packages openvpn
network-manager-openvpn
and network-manager-openvpn-gnome
to the official guide to load their .ovpn configuration files.
The connection works fine, but whenever I connect to a VPN on Ubuntu, I have to manually select a specific server from the preconfigured .ovpn files. Instead, on their Android client, for example, I can just tap a button and connect to a random server without even thinking about it.
Is there any way to make the network manager select a random .ovpn config, instead of me having to select one manually? (I'm not afraid of the command line, but preferrably without adding another PPA to my system.)
networking server network-manager vpn openvpn
I have a ProtonVPN account and connect to VPN servers at all times for internet privacy. Unfortunately, ProtonVPN does not offer a Linux-based client at this point, so they advise to connect to their servers via OpenVPN.
I installed the packages openvpn
network-manager-openvpn
and network-manager-openvpn-gnome
to the official guide to load their .ovpn configuration files.
The connection works fine, but whenever I connect to a VPN on Ubuntu, I have to manually select a specific server from the preconfigured .ovpn files. Instead, on their Android client, for example, I can just tap a button and connect to a random server without even thinking about it.
Is there any way to make the network manager select a random .ovpn config, instead of me having to select one manually? (I'm not afraid of the command line, but preferrably without adding another PPA to my system.)
networking server network-manager vpn openvpn
networking server network-manager vpn openvpn
asked Jan 30 at 12:52
Prototype700Prototype700
49641033
49641033
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
A simple command line script could work like this:
#!/bin/bash
RANGE=200
number=$RANDOM
let "number %= $RANGE"
fname="us${number}.ovpn"
openvpn "$fname"
Assuming that:
- Your OpenVPN config files are named following a scheme like
us176.ovpn
, i.e. a two-letter country code and a running number. - The available OpenVPN config files run from
us1
tous200
.
You would have to adapt the range, and add the directory where the config files are stored. Depending on the exact file name format, which I don't know for ProtonVPN, you may have to make other modifications, but you get the idea. Note that you would need to execute the script as sudo for OpenVPN to work like that.
EDIT: In case your VPN requests a username and password on connection, you can modify the last line of the script like this:
openvpn --config $fname --auth-user-pass /dir/to/userpass.txt
where userpass.txt contains the username and password on two separate lines, if you are comfortable with storing it like that.
Maybe it is good idea to detach the script from the current shell and push it in to the background, something likenohup openvpn "$fname" >/dev/null 2>&1 &
. Or to create.desktop
file that will run the script.
– pa4080
Jan 31 at 18:50
Yes indeed, otherwise you will just block the terminal for it.
– Sebastian
Jan 31 at 18:55
Here is how to get directly a random filename from a directory: stackoverflow.com/a/17410878/6543935
– pa4080
Jan 31 at 18:56
add a comment |
I never did that but as far as i understand the openvpn manual you can write multiple remote <vpn-server-ip>
lines in your .ovpn
config file. When combined with –remote-random
the software openvpn
will choose one for you, otherwise it will select the first remote server that is specified in the list.
I do not know if this will work with NetworkManager but it should work when you run the command from termial likesudo openvpn my.config.file.ovpn
.
Quote form the maual:
--remote host [port] [proto]
Remote host name or IP address. On the client, multiple --remote options may be specified for redundancy, each referring to a different OpenVPN server. Specifying multiple --remote options for this purpose is a special case of the more general connection-profile feature.
See the <connection>
documentation below.
The OpenVPN client will try to connect to a server at host:port in the order specified by the list of --remote options. proto indicates the protocol to use when connecting with the remote, and may be "tcp" or "udp".
The client will move on to the next host in the list, in the event of connection failure. Note that at any given time, the OpenVPN client will at most be connected to one server.
[...]
<connection>
Define a client connection profile.
Client connection profiles are groups of OpenVPN options that describe how to connect to a given Open‐VPN server. Client connection profiles are specified within an OpenVPN configuration file, and each profile is bracketed by <connection>
and </connection>
.
Here is an example of connection profile usage:
client
dev tun
<connection>
remote 198.19.34.56 1194 udp
</connection>
<connection>
remote 198.19.34.56 443 tcp
</connection>
<connection>
remote 198.19.34.56 443 tcp
http-proxy 192.168.0.8 8080
http-proxy-retry
</connection>
[...]
An OpenVPN client will try each connection profile sequentially until it achieves a successful connection.
--remote-random can be used to initially "scramble" the connection list.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1114105%2fis-there-a-way-to-randomize-my-selected-openvpn-servers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
A simple command line script could work like this:
#!/bin/bash
RANGE=200
number=$RANDOM
let "number %= $RANGE"
fname="us${number}.ovpn"
openvpn "$fname"
Assuming that:
- Your OpenVPN config files are named following a scheme like
us176.ovpn
, i.e. a two-letter country code and a running number. - The available OpenVPN config files run from
us1
tous200
.
You would have to adapt the range, and add the directory where the config files are stored. Depending on the exact file name format, which I don't know for ProtonVPN, you may have to make other modifications, but you get the idea. Note that you would need to execute the script as sudo for OpenVPN to work like that.
EDIT: In case your VPN requests a username and password on connection, you can modify the last line of the script like this:
openvpn --config $fname --auth-user-pass /dir/to/userpass.txt
where userpass.txt contains the username and password on two separate lines, if you are comfortable with storing it like that.
Maybe it is good idea to detach the script from the current shell and push it in to the background, something likenohup openvpn "$fname" >/dev/null 2>&1 &
. Or to create.desktop
file that will run the script.
– pa4080
Jan 31 at 18:50
Yes indeed, otherwise you will just block the terminal for it.
– Sebastian
Jan 31 at 18:55
Here is how to get directly a random filename from a directory: stackoverflow.com/a/17410878/6543935
– pa4080
Jan 31 at 18:56
add a comment |
A simple command line script could work like this:
#!/bin/bash
RANGE=200
number=$RANDOM
let "number %= $RANGE"
fname="us${number}.ovpn"
openvpn "$fname"
Assuming that:
- Your OpenVPN config files are named following a scheme like
us176.ovpn
, i.e. a two-letter country code and a running number. - The available OpenVPN config files run from
us1
tous200
.
You would have to adapt the range, and add the directory where the config files are stored. Depending on the exact file name format, which I don't know for ProtonVPN, you may have to make other modifications, but you get the idea. Note that you would need to execute the script as sudo for OpenVPN to work like that.
EDIT: In case your VPN requests a username and password on connection, you can modify the last line of the script like this:
openvpn --config $fname --auth-user-pass /dir/to/userpass.txt
where userpass.txt contains the username and password on two separate lines, if you are comfortable with storing it like that.
Maybe it is good idea to detach the script from the current shell and push it in to the background, something likenohup openvpn "$fname" >/dev/null 2>&1 &
. Or to create.desktop
file that will run the script.
– pa4080
Jan 31 at 18:50
Yes indeed, otherwise you will just block the terminal for it.
– Sebastian
Jan 31 at 18:55
Here is how to get directly a random filename from a directory: stackoverflow.com/a/17410878/6543935
– pa4080
Jan 31 at 18:56
add a comment |
A simple command line script could work like this:
#!/bin/bash
RANGE=200
number=$RANDOM
let "number %= $RANGE"
fname="us${number}.ovpn"
openvpn "$fname"
Assuming that:
- Your OpenVPN config files are named following a scheme like
us176.ovpn
, i.e. a two-letter country code and a running number. - The available OpenVPN config files run from
us1
tous200
.
You would have to adapt the range, and add the directory where the config files are stored. Depending on the exact file name format, which I don't know for ProtonVPN, you may have to make other modifications, but you get the idea. Note that you would need to execute the script as sudo for OpenVPN to work like that.
EDIT: In case your VPN requests a username and password on connection, you can modify the last line of the script like this:
openvpn --config $fname --auth-user-pass /dir/to/userpass.txt
where userpass.txt contains the username and password on two separate lines, if you are comfortable with storing it like that.
A simple command line script could work like this:
#!/bin/bash
RANGE=200
number=$RANDOM
let "number %= $RANGE"
fname="us${number}.ovpn"
openvpn "$fname"
Assuming that:
- Your OpenVPN config files are named following a scheme like
us176.ovpn
, i.e. a two-letter country code and a running number. - The available OpenVPN config files run from
us1
tous200
.
You would have to adapt the range, and add the directory where the config files are stored. Depending on the exact file name format, which I don't know for ProtonVPN, you may have to make other modifications, but you get the idea. Note that you would need to execute the script as sudo for OpenVPN to work like that.
EDIT: In case your VPN requests a username and password on connection, you can modify the last line of the script like this:
openvpn --config $fname --auth-user-pass /dir/to/userpass.txt
where userpass.txt contains the username and password on two separate lines, if you are comfortable with storing it like that.
edited Jan 31 at 18:48
pa4080
14.6k52872
14.6k52872
answered Jan 30 at 18:49
SebastianSebastian
1716
1716
Maybe it is good idea to detach the script from the current shell and push it in to the background, something likenohup openvpn "$fname" >/dev/null 2>&1 &
. Or to create.desktop
file that will run the script.
– pa4080
Jan 31 at 18:50
Yes indeed, otherwise you will just block the terminal for it.
– Sebastian
Jan 31 at 18:55
Here is how to get directly a random filename from a directory: stackoverflow.com/a/17410878/6543935
– pa4080
Jan 31 at 18:56
add a comment |
Maybe it is good idea to detach the script from the current shell and push it in to the background, something likenohup openvpn "$fname" >/dev/null 2>&1 &
. Or to create.desktop
file that will run the script.
– pa4080
Jan 31 at 18:50
Yes indeed, otherwise you will just block the terminal for it.
– Sebastian
Jan 31 at 18:55
Here is how to get directly a random filename from a directory: stackoverflow.com/a/17410878/6543935
– pa4080
Jan 31 at 18:56
Maybe it is good idea to detach the script from the current shell and push it in to the background, something like
nohup openvpn "$fname" >/dev/null 2>&1 &
. Or to create .desktop
file that will run the script.– pa4080
Jan 31 at 18:50
Maybe it is good idea to detach the script from the current shell and push it in to the background, something like
nohup openvpn "$fname" >/dev/null 2>&1 &
. Or to create .desktop
file that will run the script.– pa4080
Jan 31 at 18:50
Yes indeed, otherwise you will just block the terminal for it.
– Sebastian
Jan 31 at 18:55
Yes indeed, otherwise you will just block the terminal for it.
– Sebastian
Jan 31 at 18:55
Here is how to get directly a random filename from a directory: stackoverflow.com/a/17410878/6543935
– pa4080
Jan 31 at 18:56
Here is how to get directly a random filename from a directory: stackoverflow.com/a/17410878/6543935
– pa4080
Jan 31 at 18:56
add a comment |
I never did that but as far as i understand the openvpn manual you can write multiple remote <vpn-server-ip>
lines in your .ovpn
config file. When combined with –remote-random
the software openvpn
will choose one for you, otherwise it will select the first remote server that is specified in the list.
I do not know if this will work with NetworkManager but it should work when you run the command from termial likesudo openvpn my.config.file.ovpn
.
Quote form the maual:
--remote host [port] [proto]
Remote host name or IP address. On the client, multiple --remote options may be specified for redundancy, each referring to a different OpenVPN server. Specifying multiple --remote options for this purpose is a special case of the more general connection-profile feature.
See the <connection>
documentation below.
The OpenVPN client will try to connect to a server at host:port in the order specified by the list of --remote options. proto indicates the protocol to use when connecting with the remote, and may be "tcp" or "udp".
The client will move on to the next host in the list, in the event of connection failure. Note that at any given time, the OpenVPN client will at most be connected to one server.
[...]
<connection>
Define a client connection profile.
Client connection profiles are groups of OpenVPN options that describe how to connect to a given Open‐VPN server. Client connection profiles are specified within an OpenVPN configuration file, and each profile is bracketed by <connection>
and </connection>
.
Here is an example of connection profile usage:
client
dev tun
<connection>
remote 198.19.34.56 1194 udp
</connection>
<connection>
remote 198.19.34.56 443 tcp
</connection>
<connection>
remote 198.19.34.56 443 tcp
http-proxy 192.168.0.8 8080
http-proxy-retry
</connection>
[...]
An OpenVPN client will try each connection profile sequentially until it achieves a successful connection.
--remote-random can be used to initially "scramble" the connection list.
add a comment |
I never did that but as far as i understand the openvpn manual you can write multiple remote <vpn-server-ip>
lines in your .ovpn
config file. When combined with –remote-random
the software openvpn
will choose one for you, otherwise it will select the first remote server that is specified in the list.
I do not know if this will work with NetworkManager but it should work when you run the command from termial likesudo openvpn my.config.file.ovpn
.
Quote form the maual:
--remote host [port] [proto]
Remote host name or IP address. On the client, multiple --remote options may be specified for redundancy, each referring to a different OpenVPN server. Specifying multiple --remote options for this purpose is a special case of the more general connection-profile feature.
See the <connection>
documentation below.
The OpenVPN client will try to connect to a server at host:port in the order specified by the list of --remote options. proto indicates the protocol to use when connecting with the remote, and may be "tcp" or "udp".
The client will move on to the next host in the list, in the event of connection failure. Note that at any given time, the OpenVPN client will at most be connected to one server.
[...]
<connection>
Define a client connection profile.
Client connection profiles are groups of OpenVPN options that describe how to connect to a given Open‐VPN server. Client connection profiles are specified within an OpenVPN configuration file, and each profile is bracketed by <connection>
and </connection>
.
Here is an example of connection profile usage:
client
dev tun
<connection>
remote 198.19.34.56 1194 udp
</connection>
<connection>
remote 198.19.34.56 443 tcp
</connection>
<connection>
remote 198.19.34.56 443 tcp
http-proxy 192.168.0.8 8080
http-proxy-retry
</connection>
[...]
An OpenVPN client will try each connection profile sequentially until it achieves a successful connection.
--remote-random can be used to initially "scramble" the connection list.
add a comment |
I never did that but as far as i understand the openvpn manual you can write multiple remote <vpn-server-ip>
lines in your .ovpn
config file. When combined with –remote-random
the software openvpn
will choose one for you, otherwise it will select the first remote server that is specified in the list.
I do not know if this will work with NetworkManager but it should work when you run the command from termial likesudo openvpn my.config.file.ovpn
.
Quote form the maual:
--remote host [port] [proto]
Remote host name or IP address. On the client, multiple --remote options may be specified for redundancy, each referring to a different OpenVPN server. Specifying multiple --remote options for this purpose is a special case of the more general connection-profile feature.
See the <connection>
documentation below.
The OpenVPN client will try to connect to a server at host:port in the order specified by the list of --remote options. proto indicates the protocol to use when connecting with the remote, and may be "tcp" or "udp".
The client will move on to the next host in the list, in the event of connection failure. Note that at any given time, the OpenVPN client will at most be connected to one server.
[...]
<connection>
Define a client connection profile.
Client connection profiles are groups of OpenVPN options that describe how to connect to a given Open‐VPN server. Client connection profiles are specified within an OpenVPN configuration file, and each profile is bracketed by <connection>
and </connection>
.
Here is an example of connection profile usage:
client
dev tun
<connection>
remote 198.19.34.56 1194 udp
</connection>
<connection>
remote 198.19.34.56 443 tcp
</connection>
<connection>
remote 198.19.34.56 443 tcp
http-proxy 192.168.0.8 8080
http-proxy-retry
</connection>
[...]
An OpenVPN client will try each connection profile sequentially until it achieves a successful connection.
--remote-random can be used to initially "scramble" the connection list.
I never did that but as far as i understand the openvpn manual you can write multiple remote <vpn-server-ip>
lines in your .ovpn
config file. When combined with –remote-random
the software openvpn
will choose one for you, otherwise it will select the first remote server that is specified in the list.
I do not know if this will work with NetworkManager but it should work when you run the command from termial likesudo openvpn my.config.file.ovpn
.
Quote form the maual:
--remote host [port] [proto]
Remote host name or IP address. On the client, multiple --remote options may be specified for redundancy, each referring to a different OpenVPN server. Specifying multiple --remote options for this purpose is a special case of the more general connection-profile feature.
See the <connection>
documentation below.
The OpenVPN client will try to connect to a server at host:port in the order specified by the list of --remote options. proto indicates the protocol to use when connecting with the remote, and may be "tcp" or "udp".
The client will move on to the next host in the list, in the event of connection failure. Note that at any given time, the OpenVPN client will at most be connected to one server.
[...]
<connection>
Define a client connection profile.
Client connection profiles are groups of OpenVPN options that describe how to connect to a given Open‐VPN server. Client connection profiles are specified within an OpenVPN configuration file, and each profile is bracketed by <connection>
and </connection>
.
Here is an example of connection profile usage:
client
dev tun
<connection>
remote 198.19.34.56 1194 udp
</connection>
<connection>
remote 198.19.34.56 443 tcp
</connection>
<connection>
remote 198.19.34.56 443 tcp
http-proxy 192.168.0.8 8080
http-proxy-retry
</connection>
[...]
An OpenVPN client will try each connection profile sequentially until it achieves a successful connection.
--remote-random can be used to initially "scramble" the connection list.
answered Feb 10 at 15:02
AlexOnLinuxAlexOnLinux
473110
473110
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1114105%2fis-there-a-way-to-randomize-my-selected-openvpn-servers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown