<p>There have been recently some improvements to make sure <code>onlynet</code> is respected, most importantly <a href="https://github.com/bitcoin/bitcoin/pull/22834" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/pull/22834</a> which has been part of bitcoin core since v23.1.</p>
<p>It has been reported before that older versions of Bitcoin Core would in some situations not respect <code>-onlynet=onion</code>, see e.g. the discussion in <a href="https://github.com/bitcoin/bitcoin/issues/22647" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/issues/22647</a>.</p>
<p>Another issue, that sometimes during initial peer bootstrap (empty peers.dat) DNS seeds would be queried violating the -onlynet option, was fixed in <a href="https://github.com/bitcoin/bitcoin/pull/25678" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/pull/25678</a> (which will be contained in v 24.x).</p>

CC BY-SA 4.0
2022-12-02T18:36:40.717Z
So it would help to know which version of Bitcoin core you are using?
Lightlike
CC BY-SA 4.0
2022-12-03T14:52:05.757Z
So, after upgrading to 23, was using 22, all my connections are now onion. I've also noticed there is 14 connections now in comparison to 10 in previous versions and "cjdns" as new type. Gonna explore that more. Thanks to Pieter for explaining stuff and Lightlike for upgrade idea. I'm not sure how to close this request or if it needs closing. Seems I can't cast vote yet, however thanks for your time guys.
son_of_satoshi
CC BY-SA 4.0
2022-12-02T18:36:22.723Z
2022-12-02T18:36:22.723Z
Lightlike
<p>I've followed all these steps
<a href="https://bitcoin.stackexchange.com/questions/70069/how-can-i-setup-bitcoin-to-be-anonymous-with-tor">How can I setup Bitcoin to be anonymous with Tor?</a></p>
<p>I've added <code>onlynet</code> line in my conf file, but all my peers come with ipv4 connection. When I run <code>getnetworkinfo</code> I get ipv4, ipv6 and onion all as reachable. Only unreachable is i2p. How do I force my node to use tor and not ipv4 and ipv6.</p>
<p>UPDATE
After deleting peers.dat file, ipv4 and ipv6 would become unreachable under <code>getnetworkinfo</code>. However after some time, not sure if caused by reboot or smth else, it would turn back to reachable and in <code>peerinfo</code> half of the peers would be through ipv4.</p>
<p><strong>Conf file</strong></p>
<pre><code>datadir=/mnt/blockchain/.bitcoin/
txindex=1
server=1
daemon=1
rpcport=8332
rpcbind=0.0.0.0
rpcallowip=127.0.0.1
rpcallowip=10.0.0.0/8
rpcallowip=172.0.0.0/8
rpcallowip=192.0.0.0/8
zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333
zmqpubhashblock=tcp://0.0.0.0:28334
whitelist=127.0.0.1
rpcauth=bitcoin:#########hashed_out_for_security_reasons##########
proxy=127.0.0.1:9050
listen=1
bind=127.0.0.1
onlynet=onion
</code></pre>

CC BY-SA 4.0
2022-12-01T18:58:30.143Z
Can you paste your exact bitcoin.conf file into your question?
Pieter Wuille
CC BY-SA 4.0
2022-12-01T19:07:10.970Z
Hey Pieter, thanks for quick reply. I think I solved it tho. I've tried lots of things. Seems like deleting peers.dat file helped. Currently have 8 peers, all onion.https://media.tenor.com/d-51Xsn5N3AAAAAd/oignon-onion.gif
son_of_satoshi
CC BY-SA 4.0
2022-12-02T14:09:41.650Z
`onlynet=...` only controls outbound connections. Are you just seeing *inbound* connections through IPv4 and IPv6?
Pieter Wuille
CC BY-SA 4.0
2022-12-02T14:17:14.527Z
At the moment I have 9 onion connections, from which 8 are "outbound full relay" and 1 is "block relay only", and 1 ipv4 connection that is "block relay only". I'm not sure if that describes inbound and outbound connections. If not can you please point me to how to check that. Thanks
son_of_satoshi
CC BY-SA 4.0
2022-12-02T14:21:54.570Z
Can you paste the output of `getpeerinfo` in your answer?
Pieter Wuille
CC BY-SA 4.0
2022-12-02T14:30:56.367Z
Actually, "block relay only" implies it's outbound, so no need.
Pieter Wuille
CC BY-SA 4.0
2022-12-02T14:31:33.167Z
Try deleting `anchors.dat` ?
Pieter Wuille
CC BY-SA 4.0
2022-12-02T14:36:50.780Z
So full relay is both in and out, and block relay is outbound? Is there any benefit from security perspective to have all your connections through tor, or it is important to have just outbound through tor? Do not have {anchors.dat} in my .bitcoin.
son_of_satoshi
CC BY-SA 4.0
2022-12-02T15:48:32.830Z
All connections are bidirectional in terms of communication. "inbound" and "outbound" just refers to which node initiated the connection. From a security perspective, it's much better to have a mix of Tor and non-Tor connections, especially for outbound. Tor-only is mostly something you'd want for privacy reasons.
Pieter Wuille
CC BY-SA 4.0
2022-12-02T16:08:53.437Z
Thanks for explaining. So how would I make all the connections over Tor, if that is possible? I don't seem to have that anchors file.
son_of_satoshi
CC BY-SA 4.0
2022-12-02T16:16:18.423Z
Perhaps can you still provide the output of `getpeerinfo`?
Pieter Wuille
CC BY-SA 4.0
2022-12-02T16:28:50.377Z
https://pastebin.com/srmZ6M6w      Seems all of them are onion now. Haven't done anything.
son_of_satoshi
CC BY-SA 4.0
2022-12-02T16:31:44.510Z
https://pastebin.com/2a8p5gCx     This is `getnetworkinfo`         Seems ipv4 and ipv6 are unreachable again.
son_of_satoshi
<tor><connection>
How to force node to use tor connections, onlynet=onion already
son_of_satoshi
# How to force node to use tor connections, onlynet=onion already

(Asked by: username_0 on 2022-12-01)

I've followed all these steps
How can I setup Bitcoin to be anonymous with Tor?
I've added onlynet line in my conf file, but all my peers come with ipv4 connection. When I run getnetworkinfo I get ipv4, ipv6 and onion all as reachable. Only unreachable is i2p. How do I force my node to use tor and not ipv4 and ipv6.
UPDATE
After deleting peers.dat file, ipv4 and ipv6 would become unreachable under getnetworkinfo. However after some time, not sure if caused by reboot or smth else, it would turn back to reachable and in peerinfo half of the peers would be through ipv4.
Conf file
datadir=/mnt/blockchain/.bitcoin/
txindex=1
server=1
daemon=1
rpcport=8332
rpcbind=0.0.0.0
rpcallowip=127.0.0.1
rpcallowip=10.0.0.0/8
rpcallowip=172.0.0.0/8
rpcallowip=192.0.0.0/8
zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333
zmqpubhashblock=tcp://0.0.0.0:28334
whitelist=127.0.0.1
rpcauth=bitcoin:#########hashed_out_for_security_reasons##########
proxy=127.0.0.1:9050
listen=1
bind=127.0.0.1
onlynet=onion

**Tags:** tor, connection

> **Comments:**
> **username_1**: Can you paste your exact bitcoin.conf file into your question?  
> **username_0**: Hey Pieter, thanks for quick reply. I think I solved it tho. I've tried lots of things. Seems like deleting peers.dat file helped. Currently have 8 peers, all onion.https://media.tenor.com/d-51Xsn5N3AAAAAd/oignon-onion.gif  
> **username_1**: `onlynet=...` only controls outbound connections. Are you just seeing *inbound* connections through IPv4 and IPv6?  
> **username_0**: At the moment I have 9 onion connections, from which 8 are "outbound full relay" and 1 is "block relay only", and 1 ipv4 connection that is "block relay only". I'm not sure if that describes inbound and outbound connections. If not can you please point me to how to check that. Thanks  
> **username_1**: Can you paste the output of `getpeerinfo` in your answer?  
> **username_1**: Actually, "block relay only" implies it's outbound, so no need.  
> **username_1**: Try deleting `anchors.dat` ?  
> **username_0**: So full relay is both in and out, and block relay is outbound? Is there any benefit from security perspective to have all your connections through tor, or it is important to have just outbound through tor? Do not have {anchors.dat} in my .bitcoin.  
> **username_1**: All connections are bidirectional in terms of communication. "inbound" and "outbound" just refers to which node initiated the connection. From a security perspective, it's much better to have a mix of Tor and non-Tor connections, especially for outbound. Tor-only is mostly something you'd want for privacy reasons.  
> **username_0**: Thanks for explaining. So how would I make all the connections over Tor, if that is possible? I don't seem to have that anchors file.  
> **username_1**: Perhaps can you still provide the output of `getpeerinfo`?  
> **username_0**: https://pastebin.com/srmZ6M6w      Seems all of them are onion now. Haven't done anything.  
> **username_0**: https://pastebin.com/2a8p5gCx     This is `getnetworkinfo`         Seems ipv4 and ipv6 are unreachable again.  

---

## 1 answers

### Answer by username_2 on 2022-12-02. Score: 1

There have been recently some improvements to make sure `onlynet` is respected, most importantly <https://github.com/bitcoin/bitcoin/pull/22834> which has been part of bitcoin core since v23.1.

It has been reported before that older versions of Bitcoin Core would in some situations not respect `-onlynet=onion`, see e.g. the discussion in <https://github.com/bitcoin/bitcoin/issues/22647>.

Another issue, that sometimes during initial peer bootstrap (empty peers.dat) DNS seeds would be queried violating the -onlynet option, was fixed in <https://github.com/bitcoin/bitcoin/pull/25678> (which will be contained in v 24.x).

> **Comments:**
> **username_2**: So it would help to know which version of Bitcoin core you are using?  
> **username_0**: So, after upgrading to 23, was using 22, all my connections are now onion. I've also noticed there is 14 connections now in comparison to 10 in previous versions and "cjdns" as new type. Gonna explore that more. Thanks to Pieter for explaining stuff and username_2 for upgrade idea. I'm not sure how to close this request or if it needs closing. Seems I can't cast vote yet, however thanks for your time guys.  

---

