Skip to content

Instantly share code, notes, and snippets.

@SamsungGalaxyPlayer
Created July 25, 2023 19:45
Show Gist options
  • Save SamsungGalaxyPlayer/9fe423c693ab534e9e458ca108e5938d to your computer and use it in GitHub Desktop.
Save SamsungGalaxyPlayer/9fe423c693ab534e9e458ca108e5938d to your computer and use it in GitHub Desktop.
Get all Proton VPN IP addresses and export them into a CSV file
import requests
import csv
response_data = requests.get('https://api.protonmail.ch/vpn/logicals')
response_json = response_data.json()
ip_list = []
for server in response_json['LogicalServers']:
for server_info in server['Servers']:
exit_ip = server_info['ExitIP']
ip_list.append(exit_ip)
with open('protonvpn_exit_ips.csv', mode='w', newline='') as file:
writer = csv.writer(file)
writer.writerows(zip(ip_list))
num_ips = len(ip_list)
print(f"{num_ips} exit IPs exported to protonvpn_exit_ips.csv")
@rozhasi
Copy link

rozhasi commented Mar 25, 2024

Response to my own comment:
This script exports a list of extit server IPs for Proton VPN. So, this list could be used to block incoming connections to an internet resource from the users coming through the Proton VPN service. However, this list can't be used to block users on the LAN from connecting to Proton VPN because such a list needs to have entrance (or ingress) VPN servers, not exit (or egress) VPN servers.

I would love a hint on how to obtain a list of entrance (or ingress) VPN server IPs for Proton VPN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment