Onlynet=ipv4 disables Tor advertisements #25336

issue kroese openend this issue on June 11, 2022
  1. kroese commented at 3:08 am on June 11, 2022: none

    I want my node to accept inbound IPv4 and Tor connections, but not make any outbound Tor connections. So I set:

    0listen=1
    1server=1
    2onlynet=ipv4
    3onion=x.x.x.x:9050
    4externalip=x.x.x.x
    5externalip=xxx.onion
    

    I expect that onlynet will limit the outgoing connections to IPv4 only, and onion combined with externalip allow for Tor incoming connections.

    Actual behavior

    Tor gets completely disabled:

    0    {
    1      "name": "onion",
    2      "limited": true,
    3      "reachable": false,
    4      "proxy": "x.x.x.x:9050"
    5    }
    

    Limited is true and reachable is false. Also it does not advertise the onion address, just the IPv4:

    0  "localaddresses": [
    1    {
    2      "address": "x.x.x.x",
    3      "port": 8333,
    4      "score": 270
    5    }
    6    ]
    

    As soon as I remove the onlynet flag, Tor starts working and the address gets advertised.

    It seems this behaviour is conflicting with the documentation (which state that onlynet affects outbound only).

    So is this a bug and if not, how can I reach my goal of limiting outbound to non-tor addresses?

  2. kroese added the label Bug on Jun 11, 2022
  3. kroese renamed this:
    Onlynet=ipv4 disables incoming Tor
    Onlynet=ipv4 disables Tor
    on Jun 11, 2022
  4. fjahr commented at 4:28 pm on July 24, 2022: member
    @kroese Have you checked that there are really no incoming connections from onion peers? I think this should be already working as you would like it to, but the RPC responses that you are seeing may be confusing. “reachable” false means only not reachable in the context of outbound, I think. And that the onion address is not in “localaddresses” seems to be the same issue noted in #25669.
  5. vasild commented at 11:51 am on July 28, 2022: member

    onion= is only used to specify the SOCKS5 proxy for making outgoing connections to the Tor network. Because you do not want that you do not need to specify this option.

    Just -externalip should suffice to achieve your goal (or -externalip plus -torcontrol and -torpassword but I guess you already have those or the defaults work for you).

    There are two ways to create a Tor service (for accepting incoming connections on the Tor network):

    1. Automatically using the Tor control API, I guess this is already happening in your case because you say “Tor starts working…”. If bitcoind cannot find the Tor control, you would need to specify -torcontrol and -torpassword. See Automatically create a Bitcoin Core onion service in doc/tor.md.
    2. Manually, by configuring the Tor daemon, described in Manually create a Bitcoin Core onion service.

    And finally - you have found a bug! It will hopefully be resolved by #24835. -onlynet is supposed to only affect outgoing connections, but subtly, it also affects -externalip in a way that addresses supplied to -externalip are ignored if -onlynet is given and does not list the network of those addresses. @fjahr is right - the RPC output is confusing because reachable is only in the context of outbound. You should be able to get incoming Tor connections even now, but your Tor address is not advertised to the network, so nobody knows about it, which could be a reason why you do not see any incoming Tor connections.

  6. kroese renamed this:
    Onlynet=ipv4 disables Tor
    Onlynet=ipv4 disables Tor advertisements
    on Jul 28, 2022
  7. kroese commented at 12:31 pm on July 28, 2022: none

    @vasild Thanks for the confirmation. I described the issue not right, because I didn’t mean to say that it disables the incoming Tor connections (which would be impossible, because the tor proxy is a seperate process), but just that onlynet disables the address advertisements for Tor, which was unexpected because onlynet should only affect outbound connections. Good to hear that this bug is on the list to be resolved.

    For the other issue (limiting outbound to IPv4) I agree with you that it would make much more sense if I just leave out the onion= line. That would have made it unnecessary to use onlynet in the first place. @fjahr That issue seems very similar. Only in my case Im setting onion= explicitly, and still have my externaladdress ignored. But it could be that because onlynet is set, the end-result is the same is not setting onion= at all. In that case my issue is a duplicate of #25669

  8. vasild commented at 1:45 pm on July 28, 2022: member

    if I just leave out the onion= line

    If bitcoind manages to find the Tor control, it will ask it where is the SOCKS5 proxy and will enable outgoing connections to Tor peers via it. To prevent that you need to either set -onion=0 or -onlynet=...values.other.than.onion...

  9. kroese commented at 1:47 pm on July 28, 2022: none

    If bitcoind manages to find the Tor control, it will ask it where is the SOCKS5 proxy and will enable outgoing connections to Tor peers via it. To prevent that you need to either set -onion=0 or -onlynet=...values.other.than.onion...

    Thanks, but I was not using torcontrol= at all (but a manually configured service).


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-17 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me