I want to monitor the status of running Tor instances.
I am already able to get information via a TCP connection to the control ports. E.g. "GETINFO stream-status" returns data, but I am not able to determine the IP address of the currently chosen exit node.
It would be possible to simply request something like whatismyip.org, but that is too slow and does not scale well.
So what is the best way to get the exit node IP address of a Tor connection?
You can use tor control api. But I don't see the point.
You know the exit node
id~name
, you know the ip address that it is listening on. You don't know what network interface and what ip address it will use to process your query.I've just checked that about 5% of tor exit nodes uses unpublished ipv4 addresses.
The world is moving to ipv6. These ip addresses are cheap. Each exit node can have a bag of ipv6 unpiblished addresses.
This is a great question! Here's a short script for doing it using stem...
Thanks for the question. I've added this to our FAQ.
According to the Tor control protocol spec, the correct syntax is "GETINFO address", which should render
the best guess at our external IP address
. If we have no guess, return a 551 error. (Added in 0.1.2.2-alpha)".