Configure Tor to use a specific country as an exit node

Martin Brinkmann
Jan 29, 2008
Updated • Nov 9, 2017
Internet
|
48

Many Internet services offer access to their services only if you are visiting the websites or applications from certain countries.

System IP addresses and sometimes additional information such as the system time, are checked when a user wants to access a country restricted service. If the IP is located in an allowed country access is allowed, otherwise it is rejected.

Many workarounds exist that help users access these restricted services even if they are currently residing in a different country. This articles look at how you can configure the anonymization client Tor to have the exit node of the network in a specific country.

Tor offers lots of so called nodes which are servers in a specific country running the Tor software. If you just run the software, an exit node is picked for you automatically. What most users don't know is that it is possible to customize the selection.

I'm using Vidalia, a package that contains all necessary programs, to explain how a specific country can be selected when using Tor. Note that it is included as part of the Tor Browser which you can download here.

Download The Tor browser and install/run the software afterwards. The main program interface looks like the one on the screenshot below when you run Vidalia for the first time.

The control panel displays the current status of Tor. Additional information is displayed which we are going to use to find servers located in the country that we need an IP address from. A click on view the network displays a visual representation of all Tor servers but only if Tor is running.

Servers can be sorted by country flag and do have a performance indicators next to them as well. Write down some server names with the best performance and leave the menu again. We need to add those servers as exit nodes to the Tor configuration. A click on Settings and there on the advanced tab displays a menu where you find the entry Tor Configuration Menu.

A click on browse opens the browse for files dialog. Left-click on the file "torrc" and choose edit from that menu. Now add the following two lines to the configuration, just paste it at the beginning for instance:

ExitNodes server1, server2, server3
StrictExitNodes 1

Replace server1, server 2 and so on with the server names that you have written down in the network display window. Stop and restart Tor afterwards and the changes should have been made.

Note: the following step is not required if you are using the Tor Browser bundle directly. If you plan to use a different browser, it needs to be made.

Now we have to add a http proxy to our browser. Firefox users click on Tools > Options > Advanced Network and there on the button Settings. Select Manual Proxy Configuration and enter localhost and port 8118 there.

You can test if everything is working fine by visiting my IP lookup script which should display a IP from the country that you have selected the servers from.

Summary
Configure Tor to use a specific country as an exit node
Article Name
Configure Tor to use a specific country as an exit node
Description
How to configure Tor to only use select exit nodes that you specify and not all exit nodes the anonymity service offers.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. Debby said on June 29, 2018 at 3:01 pm
    Reply

    For information, the TOR country code list is available here -> http://startup-bootcamp.fr/liste-des-codes-des-pays-tor/

    This article is in French, but the list is the right.

  2. majid said on October 13, 2014 at 6:52 pm
    Reply

    Guys. how can I connect to an Iran’s server so that my IP will be detected as if I am connected in Iran (I am leaving abroad now)?

  3. Hans said on January 12, 2014 at 5:05 pm
    Reply

    I use a much easier way: In TorK, you can click on “Be from…” and select a country. When done, you can reset the state as easily. It’s a pity that this tool seems more or less unmaintained (although still available in the latest openSUSE distro) and is KDE-centric. But it shouldn’t be too hard to make it work elsewhere since it’s open source software.

  4. dave said on December 10, 2013 at 6:29 am
    Reply

    why don’t they just make the network map double-clickable to change exit node? because it would be too convenient? you get these brilliant minds at work and they develop a stupid flaw in their program. how does that happen? I don’t understand server node this and that.. I just want to click and connect.

  5. Danny said on November 8, 2013 at 2:27 am
    Reply

    Whenever I add the two lines below to my Windows 7 torrc file, my Tor Browser Bundle on complains that the proxy server is refusing connections.
    StrictExitNodes 1
    ExitNodes {US}

    Specifically, I get the error below:
    The proxy server is refusing connections. Firefox is configured to use a proxy server that is refusing connections. Check the proxy settings to make sure that they are correct. Contact your network administrator to make sure the proxy server is working.

    My Tor Browser Bundle is the latest update, it works just fine WITHOUT the two lines added of:
    StrictExitNodes 1
    ExitNodes {US}

    So, there isn’t enough information in this blog to actually perform the task well enough to actually work.

    To help determine the problem,
    I first tried to load a torrc.txt (instead of a torrc), so, thinking that was the problem, I changed the setting back to torrc.

    However, that changed nothing. I then noticed the existing line:
    StrictNodes 1

    This line was in addition to the two lines added:
    StrictExitNodes 1
    ExitNodes {US}

    Do you think we should remove the “StrictNodes” line?
    Do you think the ONLY file name usable is “torrc” ?

  6. Dolce said on June 21, 2013 at 2:43 pm
    Reply

    ** Update **

    ExitNodes now is a problem with Tor.. They’re working on it. Cause everytime every ip ends in the middle of the sea. And de StrictExitNodes has changed into StrictNodes

  7. p said on June 5, 2013 at 8:13 pm
    Reply

    Awesome!!! Thanks

  8. ToolsRUs said on April 24, 2013 at 6:52 am
    Reply

    People, this works, even today. View my date posted up above. See, it worked for me . . . even today.

    If you’re getting an error at line 1 a simple Google search may explain why.

    But just in case, and because I’m not a du . . . arrogant buttwipe prick, (for the devout and youngins reading this) it was solved by simply deleting the comment lines at the top of the file. Notice how the first line says that you cannot save comments. Those top two lines are comment lines. They’re causing your error. Delete them, and it should save just fine and even work too.

    Not sure if the step of setting up a proxy is still necessary though since the Tor bundle comes with it’s own modified Firefox browser that is already set up to use the Tor network. This last step may be outdated and come from a time when Firefox literally did need to be set up to use the Tor network. I’m not using it, but I’m also still a noob at this, so I could be wrong.

    1. Anonymous said on November 10, 2013 at 4:06 am
      Reply

      thankyou – Nice clear instruction with all info!…. respect

  9. Khattak said on April 21, 2013 at 11:44 pm
    Reply

    ExitNodes solved my problem to use any specfic IP at my choice. Thanks for your article. I liked it 10/10

  10. Enaus said on April 18, 2013 at 5:06 am
    Reply

    i have the same problem:

    The proxy server is refusing connections
    Firefox is configured to use a proxy server that is refusing connections.
    How did you fix it?
    by

  11. Sharan said on March 16, 2013 at 3:15 am
    Reply

    Please ignore my previous comment regarding the proxy settings. I had made a mistake which I finally realised and then fixed. It works just fine now. Thanks so much.

    1. Pat said on June 20, 2013 at 4:41 pm
      Reply

      Please Sharan, how did you fix it?
      I think i made the same mistake, but I can’t find it :(

  12. Sharan said on March 16, 2013 at 2:08 am
    Reply

    After making these settings, when I click on the “IP lookup” hyperlink, I get this error message:

    The proxy server is refusing connections
    Firefox is configured to use a proxy server that is refusing connections.

    I wonder if any other changes are to be made. The devil is in the details.

  13. badtz said on March 3, 2013 at 2:17 pm
    Reply

    Trying this with either

    ExitNodes server1, server2, server3
    StrictExitNodes 1

    or

    ExitNodes {US}

    results in an error message; “Error at line 1: “” when I try to save the changes, once I remove the added lines I still get the ertror and have to cancel out, do I have to change the parameter for vidalia 0.2.21/tor 0.2.3.25?

  14. Lerome said on November 16, 2012 at 9:28 pm
    Reply

    Delete the first line of your file (StrictExitNodes 1).

    Just use ExitNodes {US}

  15. RambleC said on November 16, 2012 at 7:53 pm
    Reply

    So, this isn’t working for me. I’m using the country code US in my torrc like so:

    StrictExitNodes 1
    ExitNodes {US}

    But I’m still getting exit nodes from Western Europe and the US. I’m using the Vidalia bundle, though I’m starting Tor and Polipo from the command line programmatically and executing HTTP requests that way. Any thoughts? I really, really need the exit nodes to only be from the US.

    1. Sharan said on March 16, 2013 at 2:12 am
      Reply

      I wonder if it will help to reverse the order of those two lines. Put the StrictExitNodes line last (follow the order given in the instructions). Just something to try out. I really don’t know if the order matters.

    2. RambleC said on November 16, 2012 at 10:03 pm
      Reply

      Nevermind: Tor wasn’t using the torrc file I thought it was using. I forced it to use the edited one by adding the “-f” argument to the command line when I start it.

  16. Frumoasa said on September 12, 2012 at 1:52 pm
    Reply

    Big big thanks for useful info

  17. Chris said on July 31, 2012 at 12:04 pm
    Reply

    Thanks Lerome, great hint. Works with the TOR browser-package as well, just don’t forget to activate your flash-player extension if you intend to watch tv abroad..

  18. David said on July 15, 2012 at 9:39 am
    Reply

    Just edit the file and save it. The comments will be deleted (you don’t need those) and the new file will replace the old one, which will be renamed, as it says.

  19. wonne said on July 14, 2012 at 10:09 am
    Reply

    it says this

    # This file was generated by Tor; if you edit it, comments will not be preserved
    # The old torrc file was renamed to torrc.orig.1 or similar, and Tor will ignore it

    what should i do

  20. JACK said on May 18, 2012 at 1:00 pm
    Reply

    This methods does not work for the latest version of vidalia bundle as of 18/05/2012

    1. Jill said on July 10, 2012 at 2:04 am
      Reply

      Jack – it works for me as of 9Jul2012. But once done, I can’t seem to restore it to its factory setting of randomly picking an exit node country.

  21. Lerome said on August 4, 2011 at 1:53 pm
    Reply

    I need to access a UK web site while in France. The site blocks non-UK IP addresses. I simply added the following line of code to the torrc file (do this by going to Settings in the Vidalia Control Panel, then selecting Advanced. Then hit the button that says Edit current torc. Add this in a new line immediately after the end:

    ExitNodes {gb}

    Best to copy and paste it!

    The country abbreviation is in brackets – in this case gb is Great Britain. Try the appropriate abbreviation for your own country.

    I have found that this works reliably. It is simple to check by going to View the Network in the Vidalia Control Panel. The connections will be shown in a box. By left-clicking on one of the connections, its details will be show so that you can check the country.

    1. Alan Aversa said on September 7, 2013 at 6:46 pm
      Reply

      Does, e.g., “ExitNodes {gb}”, etc., still work in the recent Tor? I don’t think it does.

    2. Tarya said on March 7, 2012 at 10:28 pm
      Reply

      @Lerome : It works! Thank u!!

    3. James said on December 22, 2011 at 2:57 pm
      Reply

      Thank you.

    4. Matt said on December 7, 2011 at 2:00 am
      Reply

      You are amazing. Thank you.

  22. stakoz said on June 10, 2011 at 3:04 pm
    Reply

    thanks very much worked as described on Mc Os with vidalia and firefox 5

  23. Anonymous said on March 22, 2011 at 12:29 pm
    Reply

    I followed instructions to edit the exit nodes, but they keep getting overwritten and replaced by :

    # This file was generated by Tor; if you edit it, comments will not be preserved
    # The old torrc file was renamed to torrc.orig.1 or similar, and Tor will ignore it

    Any advice welcome

  24. PATRICKRL said on May 18, 2010 at 6:29 pm
    Reply

    I’ll make sure to give back the bandwidth I take then

  25. click preview said on May 2, 2010 at 7:10 pm
    Reply

    Thanks, it works for just the first 3 server I chose for one country, But when I stop tor and change to another different 3 server from the same country, tor refuse to start. Do you have any advise?

  26. Billy said on March 5, 2010 at 4:31 am
    Reply

    Many youtube videos are blocked in various countries. Tor is possibly the simplest way for these people to access them, so although it is bad in that it degrades the entire network by hogging bandwidth, it’s also understandable why people would still choose to do it. I do not think it is something that will stop, it will only become worse.

  27. Beginners Guitar Lessons said on January 22, 2010 at 10:30 am
    Reply

    I can’t find that “Browse” button, is it the settings button you mean?

  28. Torment said on September 14, 2009 at 9:47 am
    Reply

    Thanks!

    I agree with the concern about leeching TOR bandwidth for inefficient services, like video streaming or downloads etc.

    In the end it will only degrade TOR for everyone.

  29. zugu said on September 5, 2009 at 1:05 pm
    Reply

    I understand that a lot of people use Tor to access streaming services. Please, understand that the Tor network is run by volunteers and is already slow. Using it for video streaming puts a heavy strain on the few existing exit nodes, thereby deteriorating speeds for users who, for example, would like to access Wikipedia or other site banned in their country.

    Thank you.

  30. Misterzeb said on April 29, 2009 at 6:40 am
    Reply

    Thanks friend, great advice and worked great! I now listen to last.fm for free!!!

  31. jughead said on January 5, 2009 at 12:44 am
    Reply

    The same problem. Tor won’t start after making the adjustments above. tor.pa goes to “www.pandora.com” so thats useless. Anyone have a proxy in an a rated place?

  32. Sami_L said on July 23, 2008 at 2:18 am
    Reply

    I had to use this config file to get the browser to use the exitnodes I entered in the torcc file:

    http://openpandora.googlepages.com/tor.pac

    Just save it in any folder you want and enter the path (file:///c: …) in the last box of the connections settings page which was mentioned in this article.

  33. Alexis said on February 22, 2008 at 3:37 pm
    Reply

    i am in ksa and i want to open some sites which are blocked. i am using tor but can not access such

    thanks

  34. CurrentUser said on January 29, 2008 at 11:18 pm
    Reply

    Nice article but unfortunately I can’t get this to work. I keep getting a local IP address.

    1. Alvaro said on March 20, 2014 at 10:43 am
      Reply

      Tor Proxy Software Tutorial – Get an IP in a Specific Country
      http://www.youtube.com/watch?v=5iLCgRHp_2k

    2. fool said on July 25, 2011 at 5:20 am
      Reply

      fools how can u cay it is nice if its not working

      1. Andy said on October 25, 2011 at 7:43 pm
        Reply

        Ha ha ha! It reminds me of a guy who one day told my co-worker (looking at her screen) “That’s wonderful!”. Then he added “What is it?”.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.