Title:BitTorrent Local Tracker Discovery Protocol
Version: 023256c7581a4bed356e47caf8632be2834211bd
Last-Modified:Thu Jan 12 12:29:12 2017 -0800
Author: David Harrison <>, Stanislav Shalunov <>, Greg Hazel <>
Status: Deferred
Type:Standards track


Some Internet Service Providers (ISPs) may wish to localize traffic to reduce transit costs, reduce internal traffic, and improve user experience by speeding up downloads.

With this extension, BitTorrent clients are able to discover a tracker nearby on the network, and via this tracker discover nearby caches or peers. A cache may simply be a fast peer in the middle of the network. It might also have substantial disk space. The client communicates with a cache using the normal BitTorrent protocol.

When a cache is present, the user benefits from having a high capacity peer from which the user's client downloads and to which it can delegate seeding. When a cache inside the user's ISP network seeds on behalf of the client, it frees upstream capacity in the user's access network benefiting the user and those that share the access network. When subsequent peers transfer from their ISP's cache, the ISP experiences less transit traffic.

The scope of this BEP is limited to the local tracker discovery process. Extensions to the BitTorrent protocol suite to delegate seeding or improve cache performance are beyond the scope of this BEP.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in IETF RFC 2119 [5].

Client implementation of local tracker discovery is OPTIONAL. Clients MUST NOT announce private torrents to a local tracker. It is RECOMMENDED that clients provide a user option for turning off local tracker discovery. Local tracker discovery MAY be off by default. Clients MAY automatically turn off caching if the performance benefit is not obvious. Determining obviousness is beyond the scope of this BEP.

The Discovery Mechanism

To find the tracker for its ISP, a BitTorrent client performs a reverse DNS lookup on its external IP address and then obtains the BitTorrent SRV resource record associated with the host's domain name. For example, a host with address obtains the PTR record at

The client's host IP address may not match the host's IP address as seen outside the client's private network. We address this in Section Network Address Translators.

The PTR resource record returned for this example contains domain name

The client then looks up the SRV records at

If no SRV record is found, one or more subsequent queries take place as described in Iterative Queries.

The target field in each returned SRV resource record contains the domain name of a tracker and the port on which the tracker runs. This tracker is called a local tracker, but the protocol to talk to this tracker is no different from the standard BitTorrent tracker protocol described in [1].

When the BitTorrent client joins a swarm it announces to one or more of the trackers referenced in the .torrent file and announces to the local tracker. The local tracker returns peers which may be caches or other peers that announced the same file to the local tracker.

A client MAY treat nearby peers or caches preferentially.

Reverse DNS lookups are described in RFC 1034 [4]. The SRV resource record type is described in RFC 2782 [6].

Iterative Queries

The domain name returned from the reverse DNS lookup is specific to the querying host. In the naive implementation in DNS, there would be one SRV resource record for every querying host. This would work but is burdensome. A natural, seemingly less burdensome, but incorrect solution is to use a wildcard of the form:


If wildcards are implemented according to the algorithm in section 4.3.2 in [4] then all subdomains of that do not have an exact label match will match the wildcard. Thus unless there is an exact match then queries for


both match * and all SRV resource records with owner * would be returned with the name set to the name in the query. Thus it would be impossible to disambiguate Jabber from BitTorrent SRV records without further information. This behavior is implemented with BIND 9.4.1.

Another natural but incorrect solution is to specify domain names of the type


Section 4.3.3 in [4] specifies that wildcards only appear as the first label in a domain name. This restriction was lifted in [7], but not with semantics applicable to our use case. An asterisk not at the beginning of a domain name is not treated like a wildcard. Only a lookup for the exact domain name



We propose an alternative that avoids wildcards and allows suborganizations to override SRV records provided by parent organizations: the peer starts by querying using its fully-qualified domain name returned from the reverse DNS lookup, and if this fails then it queries again after removing the most specific (leftmost) label in the domain name. For example, if no SRV records are returned when querying for

then the client queries for

and then

The search removes one label at a time terminating when one or more resource records are found or before querying the root domain or top-level domains that are not ccTLDs, e.g., .com, .org, .net. We avoid querying the root or top-level domains given the low likelihood that caches would be defined globally, and thus clients would unnecessarily burden the root domain name servers with queries generating negative results. We considered stopping before querying country-level domains, but a country providing public infrastructure might choose to provide caches.

Network Address Translators

Many hosts on the Internet sit in private networks that connect to the Internet via a Network Address Translator (NAT). Such hosts may have an IP address allocated from one of the private IP address ranges defined by IANA, e.g., ranges with prefixes 10/8, 172.16/12, and 192.168/16. When communicating with hosts outside the private network, the NAT translates the private IP to a globally-routable IP address. This globally-routable address is the host's external IP address.

The BitTorrent client must use its host's external IP address. A BitTorrent client MAY obtain its host's external IP either from the external ip key returned from a tracker implementing BEP 24 [3] or from peers implementing the yourip extension defined for the Extension Protocol proposed in [2].


In our example, we use AT&T's PacBell network. AT&T could implement tracker discovery by adding the following lines to the zone file for,

; name                                ttl  cls rr  pri weight port target 600  IN  SRV 5   0      6969 tracker

Now when a client performs tracker discovery, it performs three DNS queries removing labels before reaching the domain name, at which point the SRV record is returned and the client queries to obtain the domain names of caches.

In Python, the local tracker's port and domain can be obtained using PyDNS using the following code:

import DNS

tlds = ["com", "net", "org"]  # add more TLDs here.

name = DNS.revlookup( "" )
names = name.split('.')
while names and names[0] not in tlds:
   name = "_bittorrent-tracker._tcp." + ".".join(names)
   req = DNS.Request( name=name, qtype="SRV", protocol="udp")
   response = req.req()
   if response.answers:
   del names[0]

print "response=",

which might generate output like

response= ; <<>> 1.0 <<>> SRV
;; options: recurs
;; got answer:
;; ->>HEADER<<- opcode 0, status NOERROR, id 0
;; flags: qr aa rd ra; Ques: 1, Ans: 1, Auth: 2, Addit: 3
;;, type = SRV, class = IN

;; ANSWERS:    600    SRV     (5, 0, 6969, '')

;; AUTHORITY RECORDS:             86400   NS             86400   NS

;; ADDITIONAL RECORDS:       86400   A         86400   A         86400   A

;; Total query time: 0 msec
;; To SERVER: localhost
;; WHEN: Mon May 19 16:00:12 2008

The answer above is fictional since AT&T does not at this time implement SRV records for BitTorrent trackers.

In Microsoft Windows, the port and domain name of the server can be obtained using WinDNS (Dnsapi.lib) using DnsQuery(). In Unix, the relevant call is res_query() from libresolv.


[1]BEP_0003. The BitTorrent Protocol Specification, Cohen.
[2]BEP_0010. Extension Protocol. Norberg, Strigeus, Hazel.
[3]BEP_0024. Tracker Returns External IP. Harrison.
[4](1, 2, 3) RFC-1034. DOMAIN NAMES - CONCEPTS AND FACILITIES. Mockapetris, November 1987.
[6]RFC-2782. A DNS RR for specifying the location of services (DNS SRV). Gulbrandsen, Vixie, Esibov. February 2000.
[7]RFC-4592. The Role of Wildcards in the Domain Name System. Lewis.