0

If I'm setting up an exit relay, how do you specify the geo location or 2-letter country code of my exit relay? or how does the authority server know the geo location of a new exit relay?

It is my understanding that when using tor as a client, you can use ExitNodes in the tor configuration file to specify the country code of the location you want the exit relay to be. So if I want the exit relay to be in the united state only, I would specify 'ExitNodes {us}'. I just don't know how tor clients know the location of my new exit relay.

I found a file which contains IP blocks and 2-letter country codes for each block in /usr/share/tor/geoip. How does tor uses this file?

Thank you!

0

Edit: An earlier version of this answer was incorrect, and has been updated.

You can't specify the country code of your relay since your relay does not publish this. Instead, other tor clients/relays derive this information from your relay's IPv4 address. When a client/relay downloads a copy of the consensus, it will look up each relay's country code in its local geoip database. This geoip map from IP addresses to country codes is shipped as part of tor's source code and since it is not possible to modify this map for other relays/clients, you cannot modify the country code that they assign to you.

When a client/relay downloads a consensus, it build/updates its nodelist in nodelist_set_consensus(ns). Within this function, it calls node_set_country(node) to update the country code for each node in the consensus. This is where the lookup in the geoip database occurs.

If you're running a local Chutney network and you have control of every client/relay, you can try modifying each of their geoip files to your own custom maps. Tor/Chutney don't support assigning country codes, but here's an idea: I haven't tried this, you could try modifying chutney to bind each relay's OR port on a different local address (for example the first node on 127.0.0.1, the second on 127.0.0.2, etc), and modify the geoip map to map these addresses to different countries. For example replace the contents of the geoip file with the values:

2130706433,2130706433,US
2130706434,2130706434,UK
etc

where 2130706433 is the decimal representation of 127.0.0.1, etc.

5
  • Hi Steve, is there any way to check the consensus and see the country code it assigned for a tor exit relay? Assuming that I do have access to my own directory authorities (using chutney not the real ones) Dec 11 '20 at 23:20
  • @carloscarbajal Wait oh no, I just looked through the dir spec again and I think my answer is wrong. Updating the answer...
    – Steve
    Dec 11 '20 at 23:30
  • @carloscarbajal Sorry about that, I updated the answer. I couldn't answer your new question directly, but I added an idea to try.
    – Steve
    Dec 11 '20 at 23:56
  • so you are right about modifying the /usr/share/tor/geoip file. I added the decimal representation of the IP address of my tor exit relay and set the country code for it. But it only works on if I make the changes to the geoip file for the client. If I make the changes only in the geoip files of the directory authority, the client won't know connect to that exit relay when I specify the country code. Again, this is all being tested with chutney by standing up local authority servers and exit relays and a local tor client. Dec 12 '20 at 1:39
  • Right, that was a mistake in my original answer. The tor clients actually compute the country code themselves from the geoip file, so you have to modify the geoip files of the clients too.
    – Steve
    Dec 12 '20 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.