I am looking for a way to get a complete list of all the current IP addresses for PrivateInternetAccess' servers. I need the complete list so that I can manually enter them into a killswitch for OpenVPN. I am using Adrelanos VPN Firewall for a killswitch as described here:

VPN (OpenVPN) Firewall Killswitch For Linux Users

I saw on PIA's forums that someone had asked for a list here: List of Server IPs
but since services started blocking the IPs, the only way to get them is through the hostnames. This would be extremely time consuming for me to do.

I want to know if there is perhaps a simple script that can ping the servers enough times to sort through the IPs and organize them. Any other method would be fantastic as well. It would be easy if each hostname only had one server and IP, but as of now, the Netherlands hostname alone has 278 servers. I can't spend my time pinging the server over and over again, cross out redundant IPs, then count to make sure I have all 278. I don't want just the Netherlands IP addresses either. I would prefer a method as simple as entering the hostnames in and getting results. Any advice would be great. Thanks!


I think this does what you're asking. Whipped up in 3 minutes.

wget -q  https://www.privateinternetaccess.com/pages/network/ -O - | grep -E -o '>[^.]+\.privateinternetaccess\.com<' | tr -d '[<>]'  | while read host ;do host $host ;done  | awk '{print $NF}' | sort -u > ip_list

So we fetch the webpage with all the hostnames with wget and output it to STDOUT while suppressing activity reports from wget.

wget -q  https://www.privateinternetaccess.com/pages/network/ -O -

We grep for the host names in the output.

grep -E -o '>[^.]+\.privateinternetaccess\.com<'

Then use tr to strip the angle-backets from the host names.

tr -d '[<>]'

We then loop over the host names with a bash while-loop, and resolve them.

while read host ;do host $host ;done

The advantage of using host over pinging the name is that you will get them all, without getting duplicates.

The output of the name resolution gets cleaned up with awk, and then sorted uniquely, not that I think there would be duplicates, and write the results to the file ip_list.

awk '{print $NF}' | sort -u > ip_list

In case you wonder what the awk does: it prints the last field of each line.

| improve this answer | |
  • Thank you! I just have one more question. The output file "ip_list" only came back with 433 results. I am not sure if that means that all of the servers combined only have 433 IP addresses in total or it just didn't resolve all of them. Is it safe to assume that multiple servers have the same IP address? – Jsmith93 Mar 11 '16 at 22:31
  • @Jsmith93: that's an excellent question that I don't have the time to answer :) ... feel free to play with the command-line and disect individual steps, verify that what each outputs matches your expectations/compare counts (add random wc - l statements in disecting)... – tink Mar 11 '16 at 22:35
  • @Jsmith93: I just checked a few lines, and e.g. USA California claims on the website they have 220 servers, but they only return 13 IP ... so, I'll trust DNS more than their website statements ;} – tink Mar 11 '16 at 22:39
  • Thanks! I will comment if I run into another error later on. Have a good day! – Jsmith93 Mar 11 '16 at 22:41
  • 1
    Nice solution! Just ran it from ATT Uverse in West Palm Beach and got back 466 IP addresses. It's indeed possible that different locations/networks will yield different results if PIA is using geo-distributed DNS. They may indeed want to route traffic via certain routes depending on where you're coming from. – EricWasTaken Aug 28 '17 at 13:55

You can try this Bash script Select Fastest PIA Server

The program netselect is required.

It selects the fastest server from the country of choice

Then selects the fastest IP address to that server.

| improve this answer | |

It's absolutely possible. I did it (with PHP) and published all servers on https://github.com/Lars-/PIA-servers. It does take a while since the DNS doesn't rotate every second, but it worked.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.