Question: Anyone knows where I can get list of Autonomous system number users by country ? 
If it is not possible to get it by country, any kind of list will suffice. 
thnx

Answer: 
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

```
You can get all AS-numbers registered to a given country using the services on [cc2asn.com](http://www.cc2asn.com). Input a two-letter country code (ISO 3166-1 Alpha-2), and all ASNs are returned. Options available to get IPv4 or IPv6 prefixes. Examples:

Using **whois** to get all ASNs for Sweden:

```
whois -h cc2asn.com SE

```

Will output 

```
AS1755
AS1878
AS1879
AS1880
AS1881
AS1882
...

```

Or you can use **curl** to get the same data:

```
curl www.cc2asn.com/data/se_asn

```

You can also get the entire database, for offline lookups:

```
wget www.cc2asn.com/data/db.tar.gz

```

This database is updated on a daily basis (the frequency of the RIRs updating their delegations files).

Source code available on github: <http://github.com/toringe/cc2asn>