non-default ports for automatic connections in Bitcoin P2P network

non-default ports for automatic connections in Bitcoin P2P network
2022-02-02 13:30 ` Vasil Dimov
  
From: Prayank @ 2022-01-29 22:02 UTC (permalink / raw)
  To: Bitcoin Dev

[-- Attachment #1: Type: text/plain, Size: 2660 bytes --]

## Using non-default ports for automatic connections in Bitcoin P2P network


ISPs can block default port 8333 used by Bitcoin nodes. One example:
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2015-September/010798.html

While it would still be possible for crawlers and scanners to know about bitcoin nodes listening on non-default ports using other methods, it can be helpful in lot of countries that use basic things to block: domain, port etc.

In October 2021 a [pull request][1] was merged in Bitcoin Core in which lot of contributors
agreed to allow non default ports for automatic connections. It did not implement everything,
was limited to discussing the concept and allow AddrMan to support multiple ports per IP.

It was followed by another [pull request][2] in November 2021 which is still open and makes most
of the changes required for non-default ports to work with automatic connections.

I could not find any major issues with the changes however had some nits including a discussion on
mailing list which was even requested by a few other reviewers.


===Things that I found during my review, research and testing===

1.One user had posted about issues with default port 8333 on [bitcointalk][3] in July 2010. VMWare server
also used port 8333 so an option was requested to change port. This option was added in [May 2011][4] by Gavin Andresen. Gavin has discussed this option and related issues in detail with others on [bitcointalk][5].

2.I tried running signet for 1 hour v22.0 and 1 hour PR branch with debug=net. v22.0 had only 38333 port with different IPs in debug.log for connections. PR branch had 2 feeler connections with non-default ports 38331 and 13833.

Note: Default ports used in Bitcoin Core are 8333(mainnet), 18333(testnet), 18444(regtest) and 38333(signet)

3.Wrote a [PowerShell script][6] and tested it on v22.0 and PR branch which bans all peers every 100 seconds using default port. It works as expected and I could see one peer using port 3111 on signet.

4.I am not sure about the 'bad ports' list in Bitcoin Core added in PR #23542


8333 in leet becomes 'beee' in plain text. Not sure if this was considered by Satoshi to hardcode 8333 for Bitcoin.


  [1]: https://github.com/bitcoin/bitcoin/pull/23306
  [2]: https://github.com/bitcoin/bitcoin/pull/23542
  [3]: https://bitcointalk.org/index.php?topic=322.0
  [4]: https://github.com/bitcoin/bitcoin/pull/221
  [5]: https://bitcointalk.org/index.php?topic=589.0
  [6]: https://github.com/prayank23/bitcoin-ps-scripts/blob/main/Scripts/Node/ban_default_peers.ps1

-- 
Prayank

A3B1 E430 2298 178F

[-- Attachment #2: Type: text/html, Size: 3889 bytes --]

 permalink raw reply	[|nested]
2022-01-29 22:02 [bitcoin-dev] non-default ports for automatic connections in Bitcoin P2P network Prayank

  
From: Vasil Dimov @ 2022-02-02 13:30 UTC ( / )
  To: Prayank via bitcoin-dev



Prayank, thanks for taking the time to inform the wider community.

I just want to clarify to avoid confusion that this is about whether to
open automatic outgoing connections to a peer at addr:port if port is
not 8333. Right now, Bitcoin Core has a very very strong preference
towards peers that listen on port 8333. So, if one listens on !=8333
then he is practically not getting any incoming connections (from
Bitcoin Core).

See the PR for details and justifications:
https://github.com/bitcoin/bitcoin/pull/23542.

-- 
Vasil Dimov
gro.DSBeerF@dv
%
Diplomacy is the art of telling people to go to hell in such a way that
they ask for directions.
                -- Winston Churchill