# SocksPolicy scenario

**URL:** https://forum.torproject.org/t/sockspolicy-scenario/11381
**Category:** Core Tor
**Created:** [January 31, 2024, 9:36pm UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381 "2024-01-31T21:36:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hack3rcon](https://forum.torproject.org/user_avatar/forum.torproject.org/hack3rcon/32/3606_2.png) [@hack3rcon](https://forum.torproject.org/u/hack3rcon)
#### Post date: [January 31, 2024, 9:36pm UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381/1 "2024-01-31T21:36:50Z")

</div>

Hello,  
In a network, the Wi-Fi address range is `172.19.0.0/22` and the internal network is `172.16.0.0/16`. I want only IP address `172.20.1.254` from the range of internal network and Wi-Fi addresses and all other addresses to be able to connect to Tor. I wrote the following SocksPolicy. is it right?

```auto
SocksPolicy accept 172.19.0.0/22, accept 172.20.1.254, reject 172.16.0.0/16, accept * 
```

Thank you.  
​

---

<div class="post-metadata">

### Author: ![BobbyB](https://forum.torproject.org/user_avatar/forum.torproject.org/bobbyb/32/5456_2.png) [@BobbyB](https://forum.torproject.org/u/BobbyB)
#### Post date: [February 1, 2024, 11:19am UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381/2 "2024-02-01T11:19:23Z")

</div>

I’m not sure I completely understand the specs of the question as stated.

As specified I read it that you want all addresses (of the world) except the internal network (172.16.0.0/16) to have access to Tor.

Presuming the rules are evaluated from left to right then (reject 172.16.0.0/16, accept \*) does it all

172.20.1.254 does not match rule 1 (reject 172.16.0.0/16) and would match rule 2 (accept \*)  
WiFi 172.19.0.0/22 does not match rule 1 (reject 172.16.0.0/16) and would match rule 2 (accept \*)  
internal 172.16.0.0/16 would match rule 1 (reject 172.16.0.0/16) and rule 2 need not be evaluated  
Any other IP (of the world) does not match rule 1 (reject 172.16.0.0/16) and would match rule 2 (accept \*)

Are you sure you did not mean 172.16.0.0/12 which is how the second class of private IPs is expressed. If so then it changes a lot.  
SocksPolicy accept 172.19.0.0/22, accept 172.20.1.254, reject 172.16.0.0/12, accept \*

---

<div class="post-metadata">

### Author: ![hack3rcon](https://forum.torproject.org/user_avatar/forum.torproject.org/hack3rcon/32/3606_2.png) [@hack3rcon](https://forum.torproject.org/u/hack3rcon)
#### Post date: [February 2, 2024, 5:41pm UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381/3 "2024-02-02T17:41:21Z")

</div>

Hello,  
Thank you so much for your reply.  
I just want the IP address `172.20.1.254`, all devices connected to Wi-Fi and other IP addresses other than the range `172.16.0.0/12` to be able to connect to the Tor.

---

<div class="post-metadata">

### Author: ![BobbyB](https://forum.torproject.org/user_avatar/forum.torproject.org/bobbyb/32/5456_2.png) [@BobbyB](https://forum.torproject.org/u/BobbyB)
#### Post date: [February 3, 2024, 3:06am UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381/4 "2024-02-03T03:06:14Z")

</div>

I already gave that solution in my previous post which is:  
accept 172.19.0.0/22, accept 172.20.1.254, reject 172.16.0.0/12, accept \*

172.20.1.254 matches rule 2 (accept 172.20.1.254)  
WiFi matches rule 1 (accept 172.19.0.0/22)  
All IPs left in the range 172.16.0.0/12 match rule 3 (reject 172.16.0.0/12)  
You said “and other IP addresses other than the range 172.16.0.0/12 to be able to connect to the Tor”  
This matches rule 4 (accept \*)

What is your understanding of 172.16.0.0/12 or 172.19.0.0/22

I’m starting to wonder if I’m talking to a bot.

---

<div class="post-metadata">

### Author: ![hack3rcon](https://forum.torproject.org/user_avatar/forum.torproject.org/hack3rcon/32/3606_2.png) [@hack3rcon](https://forum.torproject.org/u/hack3rcon)
#### Post date: [February 3, 2024, 1:38pm UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381/5 "2024-02-03T13:38:06Z")

</div>

Hi,  
Thanks again.  
So, my rule was correct:

```auto
SocksPolicy accept 172.19.0.0/22, accept 172.20.1.254, reject 172.16.0.0/16, accept * 
```

---

<div class="post-metadata">

### Author: ![BobbyB](https://forum.torproject.org/user_avatar/forum.torproject.org/bobbyb/32/5456_2.png) [@BobbyB](https://forum.torproject.org/u/BobbyB)
#### Post date: [February 4, 2024, 4:18am UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381/6 "2024-02-04T04:18:45Z")

</div>

No, it was not

---

<div class="post-metadata">

### Author: ![system](https://forum.torproject.org/uploads/default/original/2X/d/d3424bed34f4ec18b2e99178c2801ba6dfb655d6.png) [@system](https://forum.torproject.org/u/system)
#### Post date: [February 5, 2024, 4:19am UTC](https://forum.torproject.org/t/sockspolicy-scenario/11381/7 "2024-02-05T04:19:42Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
