# Route all your traffic through Tor! Presenting networking.tor

**URL:** https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305
**Category:** Development
**Created:** [April 29, 2026, 3:18pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305 "2026-04-29T15:18:02Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![deade1e](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@deade1e](https://discourse.nixos.org/u/deade1e)
#### Post date: [April 29, 2026, 3:18pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/1 "2026-04-29T15:18:02Z")

</div>

Hi!

During the last few weeks I’ve been developing this nix module that adds a `networking.tor` option to route all traffic through Tor.

It has two modes, `client` and `router`. Client routes all the traffic of the current machine, while router acts as a Tor gateway for other machines.

It’s very easy to use and has quite a few useful options. I use it daily and honestly it looks like internet handles well Tor now, compared to years ago, when every website was blocking it.

It handles a bunch of different use cases, like excluding VPN traffic, fwmarked packets, or simply avoid to route traffic destined to certain subnets. It doesn’t handle local traffic by choice, as if you want to block it, you can just apply another netfilter chain on top of it.

You can also enable a clearnet proxy (squid) for cases where you need to browse the internet. For example I use it with a container profile within Firefox that’s configured to use a proxy. Very handy.

Let me know if you like it.

> **[GitHub - deade1e/networking-tor: Nix module to enable full system Tor connectivity...](https://github.com/deade1e/networking-tor)**
>
> Nix module to enable full system Tor connectivity and routing on NixOS

---

<div class="post-metadata">

### Author: ![Mapybara](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@Mapybara](https://discourse.nixos.org/u/Mapybara)
#### Post date: [April 29, 2026, 8:36pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/2 "2026-04-29T20:36:13Z")

</div>

Awesome!

I love that you’ve thought of the possibility of excluding VPN traffic.

---

<div class="post-metadata">

### Author: ![deade1e](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@deade1e](https://discourse.nixos.org/u/deade1e)
#### Post date: [April 29, 2026, 9:25pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/3 "2026-04-29T21:25:45Z")

</div>

Thanks! Yes, for example you can set `fwMark` on Wireguard configuration and then add this `fwMark` to the list here alongside the wg interface and you’re good to go.

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [April 30, 2026, 3:23am UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/4 "2026-04-30T03:23:38Z")

</div>

Thank you for sharing!

Do you think this should be in Nixpkgs?

---

<div class="post-metadata">

### Author: ![deade1e](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@deade1e](https://discourse.nixos.org/u/deade1e)
#### Post date: [April 30, 2026, 7:56am UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/5 "2026-04-30T07:56:26Z")

</div>

Thank you! Well, I’d be honoured 🙂

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [April 30, 2026, 8:38am UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/6 "2026-04-30T08:38:02Z")

</div>

If you are a user of this yourself, you may benefit from upstreaming it because it’d be less likely to be broken by Nixpkgs changes without notice. Especially if it is upstreamed with some tests. Would you be interested in doing that? Of course, I can’t guarantee acceptance.

---

<div class="post-metadata">

### Author: ![deade1e](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@deade1e](https://discourse.nixos.org/u/deade1e)
#### Post date: [April 30, 2026, 9:08am UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/7 "2026-04-30T09:08:38Z")

</div>

Yes I am interested!

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [April 30, 2026, 9:23am UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/8 "2026-04-30T09:23:39Z")

</div>

Well, then, if you haven’t yet, there’s [this document](https://github.com/NixOS/nixpkgs/blob/a4f11cb2b676c5c134bff4d8fab3d086ca78b0da/CONTRIBUTING.md) that is too long but not all of it is relevant to this particular contribution. And if you have any questions, feel free to ask here. And as soon as you have a draft, link it here, as well, please. Good luck.

---

<div class="post-metadata">

### Author: ![deade1e](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@deade1e](https://discourse.nixos.org/u/deade1e)
#### Post date: [May 2, 2026, 2:17pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/9 "2026-05-02T14:17:54Z")

</div>

Hello,

I have the pull request ready. Should be formatted accordingly. There is a test too (I hope that’s correct!). The branch is not derived from `master` but from my current revision, which should be okay if I understood correctly.

> <https://github.com/deade1e/nixpkgs/commit/69730185ee12586ed3893e7efd57965dbd5f9a91>
>
> Adds the \`networking.tor\` option to transparently route traffic through
> Tor's tr…ansparent proxy feature using nftables.
> 
> There are two modes:
> Client mode \`networking.tor.client.enable\` routes all outbound traffic
> of the local machine through Tor.
> 
> Router mode \`networking.tor.router.enable\` routes forwarded traffic
> through Tor, turning the machine into a Tor gateway for other devices.
> Also accepts allowedSources to exempt specific source subnets.
> 
> Both modes can be enabled simultaneously.
> 
> Notes:
> \`networking.nftables.enable\` is set automatically.
> Router mode enables \`net.ipv4.ip\_forward\` automatically.
> Router mode opens TCP port 9040 and UDP port 9053 in the firewall.
> DNS is redirected through Tor to prevent leaks.
> Traffic from the \`tor\` and \`squid\` system users is always exempted to
> prevent routing loops.
> 
> Adds a test that verifies that once the two modes are enabled, the
> respective nftables get applied and the Tor daemon is bound accordingly.

Let me know what you think.

Thanks 🙂

EDIT: There are two commits, I just linked the second one. The first one adds myself as a maintainer.

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [May 2, 2026, 3:29pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/10 "2026-05-02T15:29:38Z")

</div>

Could you make a draft Nixpkgs PR from that, please?

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [May 2, 2026, 3:30pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/11 "2026-05-02T15:30:53Z")

</div>

Oh, wow. You have a test. That’s nice.

---

<div class="post-metadata">

### Author: ![deade1e](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@deade1e](https://discourse.nixos.org/u/deade1e)
#### Post date: [May 2, 2026, 3:58pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/12 "2026-05-02T15:58:59Z")

</div>

Here is it: [https://github.com/NixOS/nixpkgs/pull/515902](https://github.com/NixOS/nixpkgs/pull/515902)

Thank you 🙂

EDIT: I made the PR against master branch, but actually seems a bit bad because it mentions 10k+ commits.

EDIT2: Here is the one made on 25.11 branch, which is the branch I am based on for the development: [nixos/networking: add tor transparent proxy option by deade1e · Pull Request #515904 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/pull/515904)

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [May 2, 2026, 11:48pm UTC](https://discourse.nixos.org/t/route-all-your-traffic-through-tor-presenting-networking-tor/77305/13 "2026-05-02T23:48:46Z")

</div>

Awesome! I will comment there.
