У меня недавно была подобная проблема.
В Вашем freetds.conf файле Вы захотите запись, подобную следующему:
[DataSourceName]
host = <IP Address>
port = <databaseport>
#version 8.0 seems to work with sql server 2005
tds version = 8.0
client charset = UTF-8
клиентский набор символов является важным битом здесь.
Я делал это с Perl из Linux, я ожидаю, что UTF-8 является лучшим выбором здесь также, учитывая Perl Клиент
One good list can be found at: http://bgp.potaroo.net/cidr/autnums.html
Its harder to get them sorted by "country" since lots of organisations span several continents and might use the same AS globally, but the world is split up into regional registries so you can see atleast what region gave out the specific AS number. So for Europe, for example, you have RIPE. A list of AS numbers and what region they were given out to can be found at:
http://www.iana.org/assignments/as-numbers/as-numbers.xml
If you want to do some manual processing you can get information from this file too:
ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
Fields are split by |
. The second field is country code, the third field type (asn for AS number) and the fourth field the actual AS number. Since its a text file you can easily import it in Excel and search around, or if you have access to command line utilities you can query it that way. An example from Linux with awk to list all AS numbers delegated to Sweden.
awk -F\| '{if ($2 == "SE" && $3 == "asn" ) print $4}' < delegated-ripencc-latest
To search for Russia replace SE with RU.
A bit more advanced from a Linux prompt, to download the RIPE database file, to sort out all AS numbers from russia, then prepare an input file for an AS number lookup service (from Team Cymru), then send the request file and save the output to asn.ru you you can do something like this, line by line into your Linux shell:
wget ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
awk -F\| '{if ($2 == "RU" && $3 == "asn" ) print $4}' < delegated-ripencc-latest > output.txt
sed -i -e 's/^/AS/' output.txt
(echo begin;echo verbose;cat output.txt;echo end) > input.txt
nc whois.cymru.com whois < input.txt > asn.ru
Then your asn.ru will output something like this:
Bulk mode; whois.cymru.com [2012-01-18 19:09:55 +0000]
2118 | RU | ripencc | 1993-02-17 | RELCOM-AS OOO _NPO Relcom_
2122 | RU | ripencc | 2000-06-30 | JSC PIOGLOBAL Asset Management, www.pioglobal.ru
2587 | RU | ripencc | 1995-03-23 | FREE-NET-AS2587 OOO FREEnet Group
Вы можете получить все AS-номера, зарегистрированные в данной стране, воспользовавшись услугами на cc2asn.com. Введите двубуквенный код страны (ISO 3166-1 Alpha-2), и все ASN будут возвращены. Доступны опции для получения префиксов IPv4 или IPv6. Примеры:
Использование whois для получения всех ASN для Швеции:
whois -h cc2asn.com SE
Выводит
AS1755
AS1878
AS1879
AS1880
AS1881
AS1882
...
Или вы можете использовать curl для получения одних и тех же данных:
curl www.cc2asn.com/data/se_asn
Вы также можете получить всю базу данных, для автономного поиска:
wget www.cc2asn.com/data/db.tar.gz
Эта база данных обновляется на ежедневной основе (частота обновления файлов делегаций RIR).
Исходный код доступен на github: http://github.com/toringe/cc2asn
Отчеты по странам ipinfo.io включают перечень всех ASN для каждой страны. На скриншоте ниже показаны данные по Бразилии, которые доступны по адресу http://ipinfo.io/countries/br