Bypassing the <ExcludeNodes> list for specific IP blocks

I have my torrc file configured to block everything but Iran, I may open it up in the future, but I stood it up just to help them out, since it’s so bad over there.

I was hoping there would be an variable, but the manual didn’t have anything, I found.

I want to include all the Starlink IP blocks, now that Elon opened up free internet for Iran.

The only thing I could think of was modifying the geoip file, as a one-off, and whitelisting them that way.

Anyone have any ideas how I can get this done, and Thanks!!

What exactly does that mean? Maybe I could help with this.

Where are these Starlink IP blocks and what format is needed for your whitelist.
There are too many things I can imagine about this.

The geoip file looks like something like this: 37290752,37291007,IR
and that translates to 2.57.3.0/24

After talking to Grok:

“However, Starlink users—especially in restricted regions like Iran—often appear with IPs from other countries (e.g., US, neighboring POPs), since Starlink isn’t officially licensed there and routes through global ground stations.” (POP There is Point of Presence)

I decided to white list the surrounding countries, but removing them from the list:

{AZ} Azerbaijan

{TM} Turkmenistan

{AM} Armenia

{IQ} Iraq

{KW} Kuwait

{AF} Afghanistan

{PK} Pakistan

{TR} Turkey

I am looking to edit the geoip file, with IP assigned to the AS14593 being listed as {IR}.

I don’t know if placing the starlink CIRD blocks higher in the file would be sufficient (I am not sure if the Tor Engine processes them in order, or alphabetically).

I tried converting the entries on Windows calc, and it seemed like they were rounded down?

Here is the list (partial) of currently assigned Starlink IP blocks:

2.58.56.35/32
2.58.56.43/32
2.58.56.220/32
5.2.67.226/32
5.2.72.110/32
5.45.98.162/32
5.45.102.93/32
5.45.104.176/32
5.104.86.6/32
5.255.97.221/32
5.255.98.23/32
5.255.98.151/32
5.255.98.198/32
5.255.99.5/32
5.255.100.26/32
5.255.103.235/32
5.255.104.202/32
5.255.117.56/32
5.255.118.218/32
5.255.125.196/32
23.137.253.109/32
23.137.253.254/32
23.184.48.78/32
23.236.122.193/32
27.255.75.198/32
31.129.22.65/32
31.133.0.210/32
31.133.0.235/32
35.0.127.52/32
37.187.5.192/32
45.11.59.28/32
45.12.3.80/32
45.66.35.20/31
45.66.35.22/32
45.66.35.35/32
45.80.158.27/32
45.83.104.137/32
45.84.107.55/32
45.84.107.76/32
45.84.107.101/32
45.84.107.182/32
45.84.107.198/32
45.84.107.222/32
45.88.186.92/32
45.95.169.110/32
45.128.133.242/32
45.132.246.245/32
45.134.225.36/32
45.138.16.42/32
45.138.16.76/32
45.138.16.222/32
45.138.16.231/32
45.138.16.239/32
45.138.16.240/32
45.138.16.248/32
45.141.215.61/32
45.141.215.95/32
45.141.215.97/32
45.141.215.110/32
45.141.215.114/32
45.141.215.169/32
45.145.93.133/32
46.232.251.191/32
51.81.222.62/32
62.182.84.146/32
66.146.193.33/32
66.220.242.222/32
71.19.144.106/32
72.14.179.10/32
72.235.129.116/32
77.81.247.72/32
78.142.18.219/32
80.67.167.81/32
80.67.172.162/32
80.94.92.92/32
80.241.60.207/32
81.16.33.42/32
81.17.28.95/32
82.221.128.191/32
82.221.131.5/32
83.97.20.77/32
84.239.46.144/32
85.93.218.204/32
87.118.116.12/32
87.118.116.90/32
87.118.116.103/32
87.118.122.30/32
87.118.122.51/32
88.80.26.2/31
88.80.26.4/32
89.58.26.216/32
89.58.41.156/32
89.147.108.90/32
89.147.110.118/32
89.147.110.154/32
89.147.111.87/32
91.92.109.43/32
91.92.109.126/32
91.132.144.59/32
91.202.5.104/32
91.203.144.194/32
91.203.145.116/32
91.206.26.26/32
91.208.75.3/32
91.208.75.4/32
91.208.75.153/32
91.208.75.156/32
91.208.75.178/32
91.208.75.239/32
91.219.236.101/32
92.243.24.163/32
93.95.228.125/32
93.95.231.14/32
93.95.231.88/32
93.99.104.18/32
93.99.104.40/32
93.99.104.194/32
93.123.12.112/32
94.102.51.15/32
94.142.241.194/32
94.142.244.16/32
94.230.208.147/32
94.230.208.148/32
95.128.43.164/32
97.90.239.170/32
98.128.173.33/32
102.130.113.9/32
102.130.117.167/32
103.109.101.105/32
103.164.54.199/32
104.192.3.74/32
104.244.78.162/32
104.244.78.232/32
107.189.2.108/32
107.189.13.180/32
107.189.13.254/32
107.189.29.184/32
108.61.189.136/32
109.70.100.1/32
109.70.100.2/31
109.70.100.4/30
109.70.100.8/30
109.70.100.12/31
109.169.33.163/32
114.35.245.150/32
121.78.28.166/32
123.253.35.32/32
124.198.131.108/32
124.198.131.190/32
124.198.131.253/32
124.198.132.172/32
130.193.15.186/32
136.244.111.163/32
138.59.18.110/32
139.99.8.57/32
139.99.172.11/32
146.59.231.4/32
149.202.79.129/32
160.119.249.240/32
162.216.18.62/32
162.251.5.152/32
165.73.242.163/32
171.25.193.20/32
171.25.193.25/32
171.25.193.77/32
171.25.193.78/31
171.25.193.80/32
171.25.193.234/31
172.81.131.156/32
172.81.132.94/32
172.104.182.84/32
172.234.228.174/32
173.255.198.243/32
176.58.121.177/32
176.97.114.202/32
178.218.144.18/32
178.218.144.51/32
178.218.144.96/32
178.218.144.99/32
179.43.159.78/32
179.43.159.194/31
179.43.159.196/30
179.43.159.200/31
179.43.182.58/32
179.43.182.232/32
185.34.33.2/32
185.35.202.222/32
185.42.170.203/32
185.56.171.94/32
185.82.219.109/32
185.100.85.132/32
185.100.87.41/32
185.100.87.136/32
185.100.87.174/32
185.106.102.102/32
185.112.146.167/32
185.129.62.62/31
185.130.47.58/32
185.154.110.17/32
185.154.110.142/32
185.165.169.239/32
185.165.171.84/32
185.170.114.25/32
185.181.61.203/32
185.183.157.214/32
185.191.204.254/32
185.195.71.244/32
185.207.107.130/32
185.207.107.216/32
185.220.101.32/27
185.225.69.203/32
185.225.69.232/32
185.227.134.106/32
185.235.146.29/32
185.241.208.71/32
185.241.208.81/32
185.241.208.82/32
185.241.208.115/32
185.241.208.139/32
185.243.218.225/32
185.243.218.226/32
185.243.218.229/32
185.243.218.230/32
185.244.192.175/32
185.244.192.184/32
185.246.84.179/32
185.246.128.161/32
185.246.188.73/32
185.246.188.74/32
185.246.188.149/32
185.246.189.99/32
188.68.41.191/32
188.68.49.235/32
188.68.52.231/32
188.239.191.25/32
190.103.179.98/32
190.120.229.98/32
190.211.254.97/32
192.42.116.173/32
192.42.116.174/31
192.42.116.176/29
192.42.116.184/31
192.42.116.186/32
192.42.116.191/32
192.42.116.192/29
192.42.116.200/30
192.42.116.208/29
192.42.116.216/30
192.76.153.253/32
192.159.99.21/32
193.26.115.43/32
193.26.115.61/32
193.36.132.21/32
193.105.134.150/32
193.105.134.155/32
193.200.229.243/32
194.15.112.133/32
194.15.115.212/32
194.26.192.77/32
195.47.238.178/32
195.80.151.242/32
195.88.74.206/32
195.176.3.23/32
195.176.3.24/32
198.58.107.53/32
198.96.155.3/32
198.98.48.33/32
198.98.51.189/32
198.98.57.74/32
198.98.62.158/32
199.195.251.119/32
199.195.253.124/32
200.122.181.2/32
204.8.156.142/32
204.85.191.7/32
204.85.191.8/32
204.137.14.92/32
204.137.14.104/31
204.137.14.106/32
205.185.116.34/32
205.185.117.149/32
205.185.121.170/32
205.185.123.93/32
205.185.124.176/32
209.141.32.181/32
209.141.32.198/32
209.141.46.203/32
209.141.51.180/32
209.141.55.26/32
212.21.66.6/32
212.38.189.186/32
212.69.167.80/32
212.73.134.204/32
216.73.159.101/32
217.12.221.131/32

Have you read the documentation for the torrc config file? I think you don’t understand what this option does.

ExcludeNodes prevents your tor client from using relays to build its circuits. This shouldn’t have an effect on relay usage.

1 Like

I’m trying to Whitelist Starlink IP Address Blocks.

If Iran is blocking all traffic to the exterior, I wonder if what you are doing is really working. Are there really Tor relays in IR?? They would know them. Also how would letting in the surrounding areas work, like KW, if they block all traffic outside of IR.

I tested some of those /32 blocks and a lot of them are in FR, NL, DE, and others.

Remember that the geoip files are local to you and faking those blocks to point to IR should not fool the censor gang.

In any case I’m sure I can convert the /32 blocks to the geoip format. I know the formula but would they clash with what is there already.

Will get back on that later.

I still see traffic from IR and RU and TM (but less) on the Snowflake proxy I operate.

What exactly is your goal? The way i understand your post is that you are trying to limit the users connecting to your relay to Iran and users coming from starlink.

And my question is what format do you need for the whitelist. Since you mentioned geoip I’m assuming something like the following for the first 3 blocks you gave above. I’m validating the code I used. It’s a 9 line awk file. I assume you run a relay and assume it is Linux and AWK is on Linux. I can post the file here after my validations.
37369891,37369891,IR
37369899,37369899,IR
37370076,37370076,IR

I’m running the Relay on Windows, as I am more familiar with that environment.

That format looks correct; the native format of the geoip file is what I’m after.

Thanks,

From man tor:

ExcludeNodes node,node,...
A list of identity fingerprints, country codes, and address patterns of nodes
to avoid when building a circuit. Country codes are 2-letter ISO3166 codes, and
must be wrapped in braces; fingerprints may be preceded by a dollar

Note also that if you are a relay, this (and the other node selection options below) 
only affects your own circuits that Tor builds for you.
Clients can still build circuits through you to any node. 
Controllers can tell Tor to build circuits through any node.

The ExcludeNodes option only affects the circuits build for your own use. You can’t limit users of your relay this way. So if you manage to build your modified geoip file you limit the circuits build for your use to relays from Iran and starlink.

If you want to help users from Iran specifically maybe research which circumvention method currently works best for them and run a standalone snowflake proxy with open nat or a bridge.

1 Like

So am I. I did not know you could run a relay in Windows.
Then you will need a copy of AWK. It’s a standalone Win32 program with no dependencies.
Reassemble this link. Just get the binaries and extract awk.exe
https : // gnuwin32 . sourceforge . net / packages/gawk.htm
• Binaries Zip 1448542 10 February 2008 f875bfac137f5d24b38dd9fdc9408b5a

It makes no sense for me to run it and then post the results here.
awk -f cidr.awk starlink.txt >starlink.geoip.txt

Now which entry will take precedence. The first 3 entries you gave
2.58.56.35/32
2.58.56.43/32
2.58.56.220/32

are part of this block in geoip which translates to 2.58.56.0/24
37369856,37370879,NL

If before will it override the geoip because it is first or because it is more specific /32 or wiil the general /24 entry be used.
Same logic if at the end.

The script is not dummy proof. It does no validation nor does error checking so no leading or trailing whitespace. I call it cidr.awk
The last time I posted a script the forum screwed it up a bit. So I will wait until it is approved and copy it back to see.

# https://forum.torproject.org/t/bypassing-the-excludenodes-list-for-specific-ip-blocks/21069/9
# awk -f cidr.awk inputfile >outputfile
# will only work with cidr values /31 and /32
# 45.66.35.20/31
# 45.66.35.22/32
#
BEGIN {
#RS = "\r\n"			#comment out if running on Linux and processing Windows-style line endings (CRLF). Windows does not care.
}
{
cidrblock = $0                        #whole input line
n = split(cidrblock, ip4, "/")        #you could check if n returns 2
cidrvalue = ip4[2]
n = split(ip4[1], parts, ".")         #you could check if n returns 4
hexstring = sprintf("%02x%02x%02x%02x", parts[1], parts[2], parts[3], parts[4])
if (cidrvalue == "32") print strtonum("0x" hexstring) "," strtonum("0x" hexstring) ",IR"
if (cidrvalue == "31") print strtonum("0x" hexstring) "," (1 + strtonum("0x" hexstring)) ",IR"
}