Asname

ASName #

The asname handler will return the AS Name for a provided AS Number.

exists will only be true if a name exists for the provided AS number. If exists is False, it could either be that the number is not assigned, or it currently has no name attatched to it.
c = bgpstuff.Client()

c.get_as_name(3356)
if c.as_name:
    print(f"The ASNAME for 3356 is {c.as_name}")
The ASNAME for 3356 is LEVEL3

If checking a lot of AS names, it’s more efficient to grab all AS names and then check individual names. When get_all_as_names() is called, an internal dictionary is created of all known mappings. A call to each specific get_as_name(x) after will only check the internal dictionary and not reach out to the server. Not only is this quicker, but you won’t be subject to rate limits either.

# Requires python-bgpstuff.net 1.0.7+
c = bgpstuff.Client()

c.get_as_names()
for i in range(10):
    c.get_as_name(i+1)
    if c.as_name:
         print(f"{i+1} =  {c.as_name}")
1 =  LVLT-1
2 =  UDEL-DCN
3 =  MIT-GATEWAYS
4 =  ISI-AS
5 =  SYMBOLICS
6 =  BULL-HN
7 =  DSTL
8 =  RICE-AS
9 =  CMU-ROUTER
10 =  CSNET-EXT-AS
c := bgpstuff.NewBGPClient()
name, ok, err := c.GetASName(tc.asn)
if err != nil {
    return err
}
if ok {
    fmt.Printf("The AS name for 3356 is %s\n", name)
}

The AS name for 3356 is LEVEL3

If checking a lot of AS names, it’s more efficient to grab all AS names and then check individual names. When GetASNames() is called, an internal map of all known mappings is created. A call to each specific GetASName will check the internal map and not reach out to the server. This is quicker, and it also not rate limited as each specific ASN checked is checking the internal state of the client.

c := bgpstuff.NewBGPClient()
c.GetASNames()

for i := 1; i <= 10; i++ {
    name, ok, err := c.GetASName(i)
    if err != nil {
        return err
    }
    if ok {
        fmt.Printf("The AS name for AS%d is %s\n", i, name)
    }
}

The AS name for AS1 is LVLT-1
The AS name for AS2 is UDEL-DCN
The AS name for AS3 is MIT-GATEWAYS
The AS name for AS4 is ISI-AS
The AS name for AS5 is SYMBOLICS
The AS name for AS6 is BULL-HN
The AS name for AS7 is DSTL
The AS name for AS8 is RICE-AS
The AS name for AS9 is CMU-ROUTER
The AS name for AS10 is CSNET-EXT-AS