A rust library to provide a virtual utun interface to Tor
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Cargo.toml Updated dependencies, replaced try!() with ?, rustfmt (#10) Dec 21, 2017



Build Status

tun2tor is a Rust library that creates a utun (userspace tunnel) interface, and connects it to to a stream-based proxy like tor. It is primarily intended to be embedded in the iCepa project, but it can also be used as a standalone utility.

Currently, only macOS and iOS are supported, although Linux support is almost there.

tun2tor uses tokio for async IO and LwIP for its TCP implementation (for now).

API Documentation


Running tun2tor as a standalone utility is primarily useful for debugging at the moment. Here is how to get it running:

$ git clone --recursive https://github.com/iCepa/tun2tor.git
$ cd tun2tor
$ cargo build
$ sudo target/debug/tun2tor
$ tor --DnsPort 12345

Running it requires root privileges in order to create a utun interface. tun2tor is currently hardcoded in main.rs to create an interface with an IP address of, look for a SOCKS proxy at, and look for a DNS server at

In order to route traffic through the interface, you need to modify the route table:

$ sudo route add
$ dig @ facebookcorewwwi.onion