I have been trying to get the IP address of the tor
exit node from a bash
script. I have tried torify
ing the usual methods found in various posts in forums for getting one's local IP address. For example:
torify wget -qO- http://ipecho.net/plain ; echo
torify curl -s https://check.torproject.org/ | grep "Your IP address appears to be:" | grep -o '\(\d\{1,3\}\.\)\{3\}\d\{1,3\}'
All these methods return a different IP address than that given by check.torproject.org
or any IP identifying site from the browser configured to use tor
as a proxy.
I modified the stem
script from https://stackoverflow.com/a/17130011 to get the exit relays and compare the results with that given by the bash
shell command:
#!/usr/bin/python
from stem import Signal
import os
import time
from stem import CircStatus
from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM) # get new tor identity
time.sleep(5)
print
print "Exit relays:"
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
for circ in controller.get_circuits():
if circ.status != CircStatus.BUILT:
continue
exit_fp, exit_nickname = circ.path[-1]
exit_desc = controller.get_network_status(exit_fp, None)
exit_address = exit_desc.address if exit_desc else 'unknown' # get relay IP
print exit_address
print
print "wget:"
os.system("torify wget -qO- http://ipecho.net/plain ; echo")
os.system("open 'https://check.torproject.org/'")
print
and I find that the first address is usually the correct address of the exit node and the second address is usually that given by the bash
command:
Exit relays:
178.63.97.34
5.104.224.5
188.138.1.229
128.204.203.103
wget:
5.104.224.5
Exit relays:
91.109.244.104
31.172.30.4
wget:
31.172.30.4
Exit relays:
193.14.16.36
128.204.203.103
89.248.168.6
91.109.244.104
31.172.30.4
wget:
128.204.203.103
Exit relays:
46.182.106.190
178.32.181.96
217.14.208.233
188.226.194.35
wget:
178.32.181.96
So is the address gotten by wget
or curl
the entry node or what…, and why? How can I get the EXIT node from bash?
-q
=--quiet
and-O-
=--output-document=stdout
.iftop
? Is there any way to show only port9050
traffic? What exact command did you use? As for direct connections totorify wget
IP,stem
does report them as shown in my examples.