Skip to content

Tor & I2P

How to add Tor and/or I2P to your Monero node

Assumptions

You possess:

  • Basic understanding of Linux administration
  • Root access to a Linux distribution
  • A Monero Node

Some commands assume Ubuntu but you can trivially translate them to your distribution.

Why use anonymity networks?

Why use anonymity networks? You will be able to connect your desktop and mobile Monero wallets to your own trusted Monero node, in a secure and private way over Tor or I2P.

Tor and I2P hidden services for wallet interface are useful for wallet users because it bypasses NAT and also works to mitigate MITM risks (which are very real). Hidden service connections are end-to-end encrypted and private by default.

Onion and I2P for P2P network is useful for other nodes as it allows them to relay transactions to your node (using --tx-proxy option).

Node Configuration

The end goal

To enable the following services:

  • yourlongv3onionaddress.onion:18084 - onion P2P service (for other onion nodes)
  • yourlongv3onionaddress.onion:18089 - onion RPC service (for wallets connecting over Tor)

Onion service for P2P network is useful for other full node users as it allows them to broadcast transactions over Tor (using --tx-proxy option).

Onion service for wallet interface is useful for wallet users connecting over Tor because it mitigates Clearnet and Tor exit node MiTM risks (which are very real). By connecting wallet to an onion service, no MiTM attack is realistic because onion connections are end-to-end encrypted.

Why different P2P ports for clearnet and onion?

A: The data served by the Onion p2p port differs from clearnet P2P. A different port is required.

  1. Elevate to root:
    sudo su -
    
  2. 🔗 Install Tor

  3. Add the following lines to /etc/tor/torrc:

    HiddenServiceDir /var/lib/tor/monerod
    HiddenServicePort 18089 127.0.0.1:18089    # interface for wallet ("RPC")
    HiddenServicePort 18084 127.0.0.1:18084    # interface for P2P network
    

  4. Enable Tor service:
    systemctl enable tor
    systemctl restart tor
    
  5. View/Copy your new Onion Address:
    cat /var/lib/tor/monerod/hostname
    
  6. Copy the result into your Monero config file 🔗, enabling these options:
    anonymous-inbound=yourlongv3onionaddress.onion:18084,127.0.0.1:18084
    tx-proxy=tor,127.0.0.1:9050,disable_noise
    
    Replace yourlongv3onionaddress.onion with your onion address.
  7. The node is now available on Tor. You can check that the service is working by using curl:
    curl -x socks5h://127.0.0.1:9050 http://yourlongv3onionaddress.onion:18089/get_info
    
Backup Onion keys

You may want to backup your keys folder (/var/lib/tor/monerod) to secure control over your onion address.

How Tor onion services work?

A fresh onion address and corresponding key pair were created for you in /var/lib/tor/monero/.
This happens on restart whenever you add a new HiddenServiceDir to the /etc/tor/torrc config file.
The tor daemon will forward traffic from a virtual onion port to an actual localhost port, where some service is listening (in our case, this will be monerod).
A single onion address can offer multiple services at various virtual ports.

The end goal

To enable the following services:

  • yourlongb32i2paddress.b32.i2p:18085 - I2P P2P service (for other I2P nodes)
  • yourlongb32i2paddress.b32.i2p:18089 - I2P RPC service (for wallets connecting over I2P)
Why different P2P ports for clearnet and I2P?

A: The data served by the I2P P2P port differs from that of clearnet P2P. A different port is required.

  1. Elevate to root:
    sudo su -
    
  2. Install i2pd:
    apt install apt-transport-https
    wget -q -O - https://repo.i2pd.xyz/.help/add_repo | bash -s -
    apt update
    apt install i2pd
    
  3. Create a server tunnel for the Monero P2P and RPC ports:
    cat << EOF > /etc/i2pd/tunnels.conf.d/monero-mainnet.conf
    [monero-node]
    type = server
    host = 127.0.0.1
    # Anonymous inbound port
    port = 18085
    inport = 0
    keys = monero-mainnet.dat
    
    [monero-rpc]
    type = server
    host = 127.0.0.1
    # Restricted RPC port
    port = 18089
    keys = monero-mainnet.dat
    EOF
    
  4. Restart i2pd:
    systemctl restart i2pd
    
  5. Find the new Base32 address of the node:

    curl -s http://127.0.0.1:7070/?page=i2p_tunnels | grep -Eo "[a-zA-Z0-9./?=_%:-]*" | grep "18089"
    

    Go to the web console at 127.0.0.1:7070 -> I2P tunnels page.
    Look for Server tunnels and you will see an address like yourlongb32i2paddress.b32.i2p next to monero-node.

  6. Copy the result into your Monero config file 🔗, enabling these options:

    anonymous-inbound=yourlongb32i2paddress.b32.i2p,127.0.0.1:18085
    tx-proxy=i2p,127.0.0.1:4447,disable_noise
    

    Replace yourlongb32i2paddress.b32.i2p with your Base32 address.

  7. The node is now available on I2P. You can check that the service is working by using curl:

    curl -x socks5h://127.0.0.1:4447 http://yourlongb32i2paddress.b32.i2p:18089/get_info
    

(Optional) Register a short and memorable .i2p domain on reg.i2p

The end goal

To enable the following services:

  • yourlongb32i2paddress.b32.i2p:18085 - I2P P2P service (for other I2P nodes)
  • yourlongb32i2paddress.b32.i2p:18089 - I2P RPC service (for wallets connecting over I2P)
Why different P2P ports for clearnet and I2P?

A: The data served by the I2P P2P port differs from that of clearnet P2P. A different port is required.

  1. Install I2P Java, start router

    Follow these instructions to install I2P Java on your system, then start the router:

    sudo systemctl start i2p.service
    

    Alternatively, if you downloaded a binary:

    ./i2p/i2prouter start
    

  2. Create a SOCKS tunnel

    The SOCKS proxy tunnel is not enabled by default in I2P Java. Open the tunnel manager at http://127.0.0.1:7657/i2ptunnel/, click on Tunnel Wizard, select a client tunnel, select type SOCKS 4/4a/5, and set the port to 4447.

  3. Create server tunnels for P2P and RPC

    You will need to add two server tunnels to allow for inbound P2P and RPC connections for your node. Use ports 18085 and 18089 respectively.

    From the same tunnel manager, click on Tunnel Wizard again, choose a server tunnel of type Standard, set the target host to 127.0.0.1, and the target port to the desired number. Repeat this for both tunnels and save, then start each tunnel.

    This will create hidden service keys under your I2P config directory, usually ~/.i2p/ for a user install or /var/lib/i2p/i2p-config/ for a system service install; you may want to back these up.

    Get the hostname of your hidden service node from the tunnel list once the tunnel has started, under "I2P Hidden Services" (this can take a couple of minutes on first startup).

  4. Modify the config file

    Copy the result into your Monero config file 🔗, enabling these options:

    anonymous-inbound=yourlongb32i2paddress.b32.i2p,127.0.0.1:18085
    tx-proxy=i2p,127.0.0.1:4447,disable_noise
    

    Replace yourlongb32i2paddress.b32.i2p with your Base32 address.

  5. The node is now available on I2P. You can check that the service is working by using curl:

    curl -x socks5h://127.0.0.1:4447 http://yourlongb32i2paddress.b32.i2p:18089/get_info
    

(Optional) Register a short and memorable .i2p domain on reg.i2p

(Optional) Publish the node on monero.fail

Wallet Setup

To connect Monero nodes, you have to configure the wallet software:

  1. Navigate to: Settings -> Interface -> Socks5 proxy and set the values to IP Address = 127.0.0.1 and Port = 9050
  2. Navigate to: Settings -> Node -> Add remote node and set the values to Address = http://yourlongv3onionaddress.onion and Port = 18089

🔗 Monero GUI

Add the flags --proxy=127.0.0.1:9050 --daemon-address=http://yourlongv3onionaddress.onion:18089 --trusted-daemon

🔗 Monero CLI

  1. Navigate to: Settings -> Interface -> Socks5 proxy and set the values to IP Address = 127.0.0.1 and Port = 4447
  2. Navigate to: Settings -> Node -> Add remote node and set the values to Address = http://yourlongb32i2paddress.b32.i2p and Port = 18089

🔗 Monero GUI

Add the flags --proxy=127.0.0.1:4447 --daemon-address=http://yourlongb32i2paddress.b32.i2p:18089 --trusted-daemon

🔗 Monero CLI