wikiroute

networking recipes

User Tools

Site Tools


who_is_using_this_ip_address

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
who_is_using_this_ip_address [2014/02/09 00:24] samerwho_is_using_this_ip_address [2014/02/15 23:31] (current) samer
Line 1: Line 1:
 ====== Who is Using This IP Address? ===== ====== Who is Using This IP Address? =====
  
-A frequent question that faces network administrators or application developers consists in identifying //who is using a specific public IP address//. This information can be utilized for instance to perform user localization and enable location-based services or user access control. In this context, a main technical challenge is to associate the IP address or prefix with its corresponding Autonomous System (AS).+A frequent question that faces network administrators or application developers consists in identifying //who is using a specific public IP address//. This information can be utilized for instance to perform user localization and enable location-based services or user access control. In this context, a main technical challenge is to associate an IP address or prefix with its corresponding Autonomous System (AS).
  
 ===== -- Limitations of the whois Information ===== ===== -- Limitations of the whois Information =====
Line 18: Line 18:
 An alternative method for identifying the AS that announces a specific IP prefix consists in studying the BGP routing information. Typically, each BGP speaking router stores in a BGP table the routing announcements received for each prefix together with some protocol attributes such as the AS-PATH. This attribute contains the list of ASes traversed by the BGP announcement, with the first AS being the origin AS for the IP prefix! Therefore, the problem boils down to parsing the BGP routing information, matching the IP address or prefix, and then extracting the origin AS from the AS-PATH attribute. Such process is obviously optimal when the router has a global view of the Internet: this is the case for routers participating in the Default Free Zone (DFZ) where the BGP tables contain //all the prefixes// announced in the Internet. As of 2014, these routers have around 500 000 active BGP entries according to the latest statistics. An alternative method for identifying the AS that announces a specific IP prefix consists in studying the BGP routing information. Typically, each BGP speaking router stores in a BGP table the routing announcements received for each prefix together with some protocol attributes such as the AS-PATH. This attribute contains the list of ASes traversed by the BGP announcement, with the first AS being the origin AS for the IP prefix! Therefore, the problem boils down to parsing the BGP routing information, matching the IP address or prefix, and then extracting the origin AS from the AS-PATH attribute. Such process is obviously optimal when the router has a global view of the Internet: this is the case for routers participating in the Default Free Zone (DFZ) where the BGP tables contain //all the prefixes// announced in the Internet. As of 2014, these routers have around 500 000 active BGP entries according to the latest statistics.
  
-[{{ :bgp-table.png?direct&600 | Figure 1. Active BGP entries}}]+[{{ :bgp-table.png?direct&400 | Figure 1. Active BGP entries}}]
  
 However, having access to a DFZ BGP router is not easy in practice. Alternatively, it is possible to find similar routing information on looking glasses or route servers that are made public by network operators (see for example a list of servers on www.routeserver.org). Such devices are originally deployed in order to contribute to the monitoring or the tracking of BGP anomalies in the Internet. However, having access to a DFZ BGP router is not easy in practice. Alternatively, it is possible to find similar routing information on looking glasses or route servers that are made public by network operators (see for example a list of servers on www.routeserver.org). Such devices are originally deployed in order to contribute to the monitoring or the tracking of BGP anomalies in the Internet.
Line 45: Line 45:
        Community: 15290:3356 15290:64995 15290:65050 15290:65506        Community: 15290:3356 15290:64995 15290:65050 15290:65506
  
-Despite its availability, this method remains cumbersome, especially if you want to quickly look up something or if you have a large number of prefixes that you want to analyse with a script. Fortunately, RIPE NCC and Team Cymru have already answered these questions: they provide solutions that combine the versatility of the whois protocol with the accuracy of the BGP information. In other words, you keep on using the legacy whois command but you get BGP-based results. Let us examine these solutions: +Despite its availability, this method remains cumbersome, especially if you want to quickly look up something or if you have a large number of prefixes that you want to analyse with a script. Fortunately, RIPE NCC and Team Cymru have already answered these requirements: they provide solutions that combine the versatility of the whois protocol with the accuracy of the BGP information. In other words, you keep on using the legacy whois command but you get BGP-based results. 
  
 ==== -- Team Cymru whois Server ==== ==== -- Team Cymru whois Server ====
Line 68: Line 68:
  
 ==== -- Riswhois Server ==== ==== -- Riswhois Server ====
-RIPE NCC implements a similar whois service named RISwhois by providing a higher level view over the most recently collected set of routing tables from the Remote Route Collectors (RRCs) at different [[http://www.ripe.net/data-tools/stats/ris/ris-peering-policy | locations]] in the world. Given an IPv4 or IPv6 prefix, RISwhois will tell which prefixes and origin ASes on which RRCs match that particular IP.+RIPE NCC implements a similar whois service named RISwhois. This service provides a higher level view over the most recently collected set of routing tables from the Remote Route Collectors (RRCs) at different [[http://www.ripe.net/data-tools/stats/ris/ris-peering-policy | locations]] in the world. Given an IPv4 or IPv6 prefix, RISwhois will tell which prefixes and origin ASes on which RRCs match that particular IP.
  
 <WRAP info> <WRAP info>
Line 74: Line 74:
 </WRAP> </WRAP>
  
-In the following, a simple example shows the output of a Riswhois query: ''203.178.141.194'' is originated by AS ''2500'' as seen by 16 RRCs.+In the following, a simple example shows the output of a Riswhois query: as seen by 16 RRCs, the IP address ''203.178.141.194'' is originated by AS ''2500''.
  
 <code> <code>
Line 89: Line 89:
  
 <WRAP round important> <WRAP round important>
-Note RRCs may receive different information for the same IP prefix.  +Due to BGP policies between ASes in the Internet, RRCs may receive different BGP information for the same IP prefix. Therefore, Riswhois provides multiple matchings for the IP prefix, as in the following example. In such casesa longest prefix matching may help in choosing a single originating AS.    
-that Riswhois may provide multiple matchings for IP addresses. In such caseRRCs   +
 </WRAP> </WRAP>
  
Line 114: Line 113:
 </code> </code>
 ===== -- A Do-It-Yourself BGP Query Service ===== ===== -- A Do-It-Yourself BGP Query Service =====
 + 
 +When accessing the online servers (Riswhois, Cymru or legacy whois servers) is not possible or not recommended, an autonomous implementation of an equivalent server is possible. This can be the case when service availability constraints are very tight or when the Internet connection is not permanent. 
 +Here are some hints and recipes to implement a server that maps IP prefixes with AS numbers based on BGP information. 
  
-Start by downloading multiple routing tables for routeviews or RIPE RIS servers. Transform these tables into parsable format bu using bgpdump. Use any scripting language to perform a best prefix match and output the origin AS of your desired IP prefix.+==== -- Basic Steps ==== 
 + 
 +Start by downloading raw BGP data collected by RIPE NCC servers from http://www.ripe.net/data-tools/stats/ris/ris-raw-data. For example, the latest data file from RRC0 (Amsterdam) is always available on http://data.ris.ripe.net/rrc00/latest-bview.gz. 
 + 
 +<code> 
 +$ wget http://data.ris.ripe.net/rrc00/latest-bview.gz  
 +</code> 
 + 
 +As raw data is written in MRT format, you need to install [[https://bitbucket.org/ripencc/bgpdump/wiki/Home | bgpdump]] in order to parse it easily 
 + 
 +<code> 
 +$ zcat latest-bview.gz | bgpdump -m - > latest-bview-parsed.txt 
 +</code>  
 + 
 +Here is a typical line in the dumped file, where you can see the prefix ''148.60.0.0/16'' and the AS-PATH ending by the originating AS ''2200'': 
 +<code> 
 +TABLE_DUMP2|1389513606|B|85.132.60.10|29049|148.60.0.0/16|29049 1273 2200|IGP|85 
 +.132.60.10|0|0|1273:12250 2200:1000 2200:2200|NAG|| 
 +</code> 
 + 
 +Now you can use your favorite scripting language to extract IP to AS mappings and perform a best prefix match
 + 
 +==== -- Software Tools ==== 
 + 
 +Fortunately, existing software tools may help you in the process of implementing you own BGP-based IP to AS mapping service. Consider taking a look at: 
 +  - [[http://cpansearch.perl.org/src/TPODER/Net-NfDump-0.12/examples/download_asn_db | Net-NfDump]]: a perl library that makes use of the [[http://search.cpan.org/~tpoder/Net-IP-LPM-0.02/ | Net::IP::LPM]] implementation of Longest Prefix Match algorithm.  
 +  - [[https://github.com/CIRCL/IP-ASN-history | IP-ASN-history]]: a client/server (with a client web interface) software to store efficiently the history of BGP announces and quickly lookup IP addresses origins. 
 +  - [[http://pwhois.org/server.who | pwhois]]: a client/server software that makes use of a PostgreSQL database to store routing information. FIXME Did not succeed to install it on Mac OS X 10.9.1 
who_is_using_this_ip_address.1391901867.txt.gz · Last modified: 2014/02/09 00:24 by samer