User Tools

Site Tools


Tor client


  • This guide describes how to configure OpenWrt to run Tor client.
  • It makes your router provide access to the dark net for LAN clients.
  • Tor is limited to DNS and TCP traffic, use VPN to protect all traffic.


  • Provide anonymous communication via onion routing.
    • Access the dark net and Tor hidden services.
  • Encrypt your internet connection to enforce security and privacy.
    • Prevent data leak and traffic spoofing on the client side.
  • Bypass regional restrictions using public relay providers.
    • Escape client side content filters and internet censorship.


1. Tor client

Install and configure Tor client.

# Install packages
opkg update
opkg install tor
# Configure Tor client
sed -i -e "
\$a AutomapHostsOnResolve 1
\$a VirtualAddrNetworkIPv4
\$a VirtualAddrNetworkIPv6 fc00::/7
\$a DNSPort
\$a DNSPort [::]:9053
\$a TransPort
\$a TransPort [::]:9040
" /etc/tor/torrc
service tor restart

2. Firewall

Configure firewall to intercept DNS and TCP traffic.

# Intercept DNS and TCP traffic
uci -q delete firewall.tordns
uci set firewall.tordns="redirect"
uci set"Intercept-DNS"
uci set firewall.tordns.src="lan"
uci set firewall.tordns.src_dport="53"
uci set firewall.tordns.dest_port="9053"
uci set"ipv4"
uci set firewall.tordns.proto="udp"
uci set"DNAT"
uci -q delete firewall.tortrans
uci set firewall.tortrans="redirect"
uci set"Intercept-TCP"
uci set firewall.tortrans.src="lan"
uci set firewall.tortrans.src_dport="!22"
uci set firewall.tortrans.dest_port="9040"
uci set"ipv4"
uci set firewall.tortrans.proto="tcp"
uci set firewall.tortrans.extra="--syn"
uci set"DNAT"
uci commit firewall
service firewall restart

3. NAT6

If using dual-stack mode, enable NAT6 to process IPv6 traffic.

# Enable NAT6
opkg update
opkg install kmod-ipt-nat6
cat << EOF > /etc/firewall.nat6
iptables-save --table="nat" \
| sed -e "/\s[DS]NAT\s/d;/\sMASQUERADE$/d" \
| ip6tables-restore --table="nat"
uci -q delete firewall.nat6
uci set firewall.nat6="include"
uci set firewall.nat6.path="/etc/firewall.nat6"
uci set firewall.nat6.reload="1"
uci commit firewall
service firewall restart


Verify that you are using Tor.

Check your client public IP addresses.

Make sure there is no DNS leak on the client side.


Collect and analyze the following information.

# Restart the services
service log restart; service tor restart
# Log and status
logread -e Tor; netstat -l -n -p | grep -e tor
# Runtime configuration
pgrep -f -a tor
ip addr show; ip route show; ip rule show; iptables-save
ip -6 addr show; ip -6 route show; ip -6 rule show; ip6tables-save
# Persistent configuration
grep -v -e "^#" -e "^$" /etc/tor/torrc
docs/guide-user/services/tor/client.txt · Last modified: 2019/04/28 02:36 by vgaetera