Hi, I’m Eric. I’m technical director @enginsightcom with deep interest in it security.
Eric Range

Tor Country Codes

Eric Range
Eric Range
Sep 17, 2022
Hi, I’m Eric. I’m technical director @enginsightcom with deep interest in it security.

Entry and exit nodes can be configured in Tor on a country-by-country basis. This allows Tor to use certain servers in other countries, so you can bypass web restrictions in your own region. Keep in mind that not all countries allow you to use Tor, which means that certain countries will not work with the entry and exit options.

TORRC

Modify your “torrc” file to add the follwoing line to ensure Tor will only use Germany based exit nodes:

ExitNodes {de} StrictNodes 1

Please note that in all of these examples, we must enable StrictNodes. This example will use either Germany, Uganda, South Korea, or Ireland as an exit:

ExitNodes {de},{ug},{kp},{ie} StrictNodes 1

Blacklisting

You can also use this as a defensive measure. If you think there is some kind of geocentric threat in Uganda, you can configure Tor not to use these exit nodes.

ExcludeExitNodes {ua}

You can exclude all node types for a specific country as well – exits, relays, entry, and bridge nodes.

ExcludeNodes {us}

You have the option to whitelist all node types, i.e. you can make sure that your entire Tor circuit only uses a specific country. Of course, this is NOT recommended. An ideal circuit will cross countries and legal jurisdictions.

The “??” Country

Tor uses Maxmind’s geo-ip lookup system for this feature. Some of the versions of their database contain a “??” country code. This is reserved for IPs they either don’t know or aren’t willing to share. (Tor is making some changes to compensate for this in the future).

Knowing this can be useful in two ways. First, you might think that you don’t want to use the land if you don’t know which land you will use as a node. This is probably a legitimate thought without having more information about why an IP has a “??”. Second, and more interesting, some (poorly configured) firewalls will automatically reject connections from certain countries. Administrators will say, “Screw it, block China. Hacking problem solved!” and ask for a raise. Maxmind is a very popular database for geographic searches, and you can imagine that all the security services built into those fancy corporate firewalls are most likely using it when they do geographic searches. While many of these administrators have policies on how to handle “us,” “cn” and “de,” I’ve found that many have problems with a country code that reads “??”. In one case, I found a system that blocked all outbound nodes except those coming from a “??” country.

List of country codes for Tor

Use the following table to find your country codes for the torrc configuration.

CountryCode
ASCENSION ISLAND{ac}
AFGHANISTAN{af}
ALAND{ax}
ALBANIA{al}
ALGERIA{dz}
ANDORRA{ad}
ANGOLA{ao}
ANGUILLA{ai}
ANTARCTICA{aq}
ANTIGUA AND BARBUDA{ag}
ARGENTINA REPUBLIC{ar}
ARMENIA{am}
ARUBA{aw}
AUSTRALIA{au}
AUSTRIA{at}
AZERBAIJAN{az}
BAHAMAS{bs}
BAHRAIN{bh}
BANGLADESH{bd}
BARBADOS{bb}
BELARUS{by}
BELGIUM{be}
BELIZE{bz}
BENIN{bj}
BERMUDA{bm}
BHUTAN{bt}
BOLIVIA{bo}
BOSNIA AND HERZEGOVINA{ba}
BOTSWANA{bw}
BOUVET ISLAND{bv}
BRAZIL{br}
BRITISH INDIAN OCEAN TERR{io}
BRITISH VIRGIN ISLANDS{vg}
BRUNEI DARUSSALAM{bn}
BULGARIA{bg}
BURKINA FASO{bf}
BURUNDI{bi}
CAMBODIA{kh}
CAMEROON{cm}
CANADA{ca}
CAPE VERDE{cv}
CAYMAN ISLANDS{ky}
CENTRAL AFRICAN REPUBLIC{cf}
CHAD{td}
CHILE{cl}
PEOPLE’S REPUBLIC OF CHINA{cn}
CHRISTMAS ISLANDS{cx}
COCOS ISLANDS{cc}
COLOMBIA{co}
COMORAS{km}
CONGO{cg}
CONGO (DEMOCRATIC REPUBLIC){cd}
COOK ISLANDS{ck}
COSTA RICA{cr}
COTE D IVOIRE{ci}
CROATIA{hr}
CUBA{cu}
CYPRUS{cy}
CZECH REPUBLIC{cz}
DENMARK{dk}
DJIBOUTI{dj}
DOMINICA{dm}
DOMINICAN REPUBLIC{do}
EAST TIMOR{tp}
ECUADOR{ec}
EGYPT{eg}
EL SALVADOR{sv}
EQUATORIAL GUINEA{gq}
ESTONIA{ee}
ETHIOPIA{et}
FALKLAND ISLANDS{fk}
FAROE ISLANDS{fo}
FIJI{fj}
FINLAND{fi}
FRANCE{fr}
FRANCE METROPOLITAN{fx}
FRENCH GUIANA{gf}
FRENCH POLYNESIA{pf}
FRENCH SOUTHERN TERRITORIES{tf}
GABON{ga}
GAMBIA{gm}
GEORGIA{ge}
GERMANY{de}
GHANA{gh}
GIBRALTER{gi}
GREECE{gr}
GREENLAND{gl}
GRENADA{gd}
GUADELOUPE{gp}
GUAM{gu}
GUATEMALA{gt}
GUINEA{gn}
GUINEA-BISSAU{gw}
GUYANA{gy}
HAITI{ht}
HEARD & MCDONALD ISLAND{hm}
HONDURAS{hn}
HONG KONG{hk}
HUNGARY{hu}
ICELAND{is}
INDIA{in}
INDONESIA{id}
IRAN, ISLAMIC REPUBLIC OF{ir}
IRAQ{iq}
IRELAND{ie}
ISLE OF MAN{im}
ISRAEL{il}
ITALY{it}
JAMAICA{jm}
JAPAN{jp}
JORDAN{jo}
KAZAKHSTAN{kz}
KENYA{ke}
KIRIBATI{ki}
KOREA, DEM. PEOPLES REP OF{kp}
KOREA, REPUBLIC OF{kr}
KUWAIT{kw}
KYRGYZSTAN{kg}
LAO PEOPLE’S DEM. REPUBLIC{la}
LATVIA{lv}
LEBANON{lb}
LESOTHO{ls}
LIBERIA{lr}
LIBYAN ARAB JAMAHIRIYA{ly}
LIECHTENSTEIN{li}
LITHUANIA{lt}
LUXEMBOURG{lu}
MACAO{mo}
MACEDONIA{mk}
MADAGASCAR{mg}
MALAWI{mw}
MALAYSIA{my}
MALDIVES{mv}
MALI{ml}
MALTA{mt}
MARSHALL ISLANDS{mh}
MARTINIQUE{mq}
MAURITANIA{mr}
MAURITIUS{mu}
MAYOTTE{yt}
MEXICO{mx}
MICRONESIA{fm}
MOLDAVA REPUBLIC OF{md}
MONACO{mc}
MONGOLIA{mn}
MONTENEGRO{me}
MONTSERRAT{ms}
MOROCCO{ma}
MOZAMBIQUE{mz}
MYANMAR{mm}
NAMIBIA{na}
NAURU{nr}
NEPAL{np}
NETHERLANDS ANTILLES{an}
NETHERLANDS, THE{nl}
NEW CALEDONIA{nc}
NEW ZEALAND{nz}
NICARAGUA{ni}
NIGER{ne}
NIGERIA{ng}
NIUE{nu}
NORFOLK ISLAND{nf}
NORTHERN MARIANA ISLANDS{mp}
NORWAY{no}
OMAN{om}
PAKISTAN{pk}
PALAU{pw}
PALESTINE{ps}
PANAMA{pa}
PAPUA NEW GUINEA{pg}
PARAGUAY{py}
PERU{pe}
PHILIPPINES (REPUBLIC OF THE){ph}
PITCAIRN{pn}
POLAND{pl}
PORTUGAL{pt}
PUERTO RICO{pr}
QATAR{qa}
REUNION{re}
ROMANIA{ro}
RUSSIAN FEDERATION{ru}
RWANDA{rw}
SAMOA{ws}
SAN MARINO{sm}
SAO TOME/PRINCIPE{st}
SAUDI ARABIA{sa}
SCOTLAND{uk}
SENEGAL{sn}
SERBIA{rs}
SEYCHELLES{sc}
SIERRA LEONE{sl}
SINGAPORE{sg}
SLOVAKIA{sk}
SLOVENIA{si}
SOLOMON ISLANDS{sb}
SOMALIA{so}
SOMOA,GILBERT,ELLICE ISLANDS{as}
SOUTH AFRICA{za}
SOUTH GEORGIA, SOUTH SANDWICH ISLANDS{gs}
SOVIET UNION{su}
SPAIN{es}
SRI LANKA{lk}
ST. HELENA{sh}
ST. KITTS AND NEVIS{kn}
ST. LUCIA{lc}
ST. PIERRE AND MIQUELON{pm}
ST. VINCENT & THE GRENADINES{vc}
SUDAN{sd}
SURINAME{sr}
SVALBARD AND JAN MAYEN{sj}
SWAZILAND{sz}
SWEDEN{se}
SWITZERLAND{ch}
SYRIAN ARAB REPUBLIC{sy}
TAIWAN{tw}
TAJIKISTAN{tj}
TANZANIA, UNITED REPUBLIC OF{tz}
THAILAND{th}
TOGO{tg}
TOKELAU{tk}
TONGA{to}
TRINIDAD AND TOBAGO{tt}
TUNISIA{tn}
TURKEY{tr}
TURKMENISTAN{tm}
TURKS AND CALCOS ISLANDS{tc}
TUVALU{tv}
UGANDA{ug}
UKRAINE{ua}
UNITED ARAB EMIRATES{ae}
UNITED KINGDOM (no new registrations){gb}
UNITED KINGDOM{uk}
UNITED STATES{us}
UNITED STATES MINOR OUTL.IS.{um}
URUGUAY{uy}
UZBEKISTAN{uz}
VANUATU{vu}
VATICAN CITY STATE{va}
VENEZUELA{ve}
VIET NAM{vn}
VIRGIN ISLANDS (USA){vi}
WALLIS AND FUTUNA ISLANDS{wf}
WESTERN SAHARA{eh}
YEMEN{ye}
ZAMBIA{zm}
ZIMBABWE{zw}