
I faced a task — to determine the geolocation of proxies as well as check their IP addresses. Static proxy servers do not require determining the external IP address since we can see it in the proxy itself. My task was to determine these parameters for dynamic mobile proxies.
The solution also had to meet minimum requirements:
- bulk proxy checking;
- secure checking, no data leaks;
- ease of use.
After searching for a proxy checker, I concluded that none of the ones I found met my requirements.
I decided to write a bash script on Linux using the ipinfo.io service.
Output data for each proxy:
- IP address;
- ASN (unique autonomous system number of the provider);
- provider;
- city.
First, register at ipinfo.io and get a token. The free plan allows 50k requests per month, which is more than enough.
Create the script checkip.sh
I use the nano text editor
nano checkip.sh
Open the config and paste the following content
#!/bin/sh
mv ip.list ip.list.old
n=1
token=*******
for i in `cat proxy.list`; do
CUR1=`curl -s --connect-timeout 5 --proxy $i ipinfo.io/ip`
CUR2=`curl -s --connect-timeout 5 --proxy $i -u $token: ipinfo.io/org`
CUR3=`curl -s --connect-timeout 5 --proxy $i -u $token: ipinfo.io/city`
echo "$n ${CUR1} ${CUR2} ${CUR3}" >> ip.list
((n+=1))
done
Enter your token
Save the script and make it executable
chmod +x checkip.sh
Create a proxy.list file and paste your proxies in login:pass@ip:port format, one per line.
All that is left is to run the script
bash checkip.sh
All data will be saved to the ip.list file in approximately the following format:
1 176.59.4.11 AS15378 T2 Mobile LLC Centralniy
2 217.118.92.139 AS16345 Public Joint Stock Company Vimpel-Communications St Petersburg
3 217.118.92.143 AS16345 Public Joint Stock Company Vimpel-Communications St Petersburg
4 31.173.80.42 AS25159 PJSC MegaFon Moscow
5 31.173.86.215 AS25159 PJSC MegaFon Moscow
6 31.173.84.239 AS25159 PJSC MegaFon Moscow
7 31.173.87.6 AS25159 PJSC MegaFon Moscow
8 31.173.80.231 AS25159 PJSC MegaFon Moscow
P.S. This is how Yandex determines location, and probably others too...
