Programmatically changing OpenVPN client server IP?
-
I've created a one-liner script which returns the least loaded ProtonVPN Plus server for an ISO country code.
!/bin/sh # Returns IP address of the least loaded server for any country # Requires 2-letter ISO country code as the first parameter # If country code is missing or not found - returns null string curl -s https://api.protonmail.ch/vpn/logicals | jq "[.LogicalServers[]|select(.Name|contains(\"$1\"))|select(.Tier==2)|{ServerName: .Name, ServerLoad: (.Load|tonumber),EntryIP: .S ervers[].EntryIP}] | sort_by(.ServerLoad)" | jq -r '.[0].EntryIP'
Example:
[2.6.0-RELEASE][root@inf-pfsense-01]/root/bin: ./proton.sh UK 146.70.96.66
Is there any way to programmatically change server IP for an OpenVPN client #X?
The client restart command is here:
#!/bin/sh /usr/local/sbin/pfSsh.php playback svc restart openvpn client 1
-
@capitanblack said in Programmatically changing OpenVPN client server IP?:
146.70.96.xx
Is that the IP proton gave you ?
If so, then no, not possible. They own a pool with addresses per VPN server, and attribute one to you.edit : disconnect, and reconnect,might work ?
-
@gertjan
You should try how the script works. It returns IP address of the LEAST loaded server in a country at this moment . The idea I have is to use cron to stop VPN client every 15 minutes, get the least loaded server IP, change it in pfSense OpenVPN client config and start the client. This way my pfSense will be "always" connected to the fastest server in a specific country.