#35027 net: add -outboundbind option for outgoing source address

full analysis

https://github.com/bitcoin/bitcoin/pull/35027 · 8144225309 · +559/-8 in 10 files, 3 commits · labels: P2P

Goal

  • Allow node operators to choose which local IP address is used for outgoing clearnet P2P connections
  • Prevents multi-homed hosts from routing outbound traffic through unintended network interfaces

Adds a `-outboundbind=<addr>` configuration option to specify the local source IP address for outgoing clearnet (IPv4/IPv6) connections. Connections over Tor, I2P, and CJDNS, as well as connections routed through a SOCKS proxy, are untouched. The option performs a trial bind at startup to detect misconfigurations early, fails closed if the local source address cannot be bound at connect time, and adds corresponding unit and functional test coverage.

Problem: On multi-homed hosts with multiple IP addresses or interfaces, outgoing P2P connections default to operating system routing decisions, which may route traffic through an unintended interface or IP address. Node operators wanting their outgoing connections bound to a specific IP had no configuration option to do so.

Category: P2P (#34 of 65)

P3 · new feature

  • P3 because it adds clear configuration control for multi-homed node operators
  • Solves long-standing issue #6476 without affecting network security or liveness

Clear use case and real value for node operators running multi-homed servers, resolving long-standing feature request #6476. As vasild noted, introducing a dedicated option leaving defaults to the OS avoids regressions while cleanly fulfilling operator needs. It is reasonably deferrable as it does not address a security vulnerability or network liveness flaw.

Membership: Modifies P2P connection establishment in src/net.cpp and src/netbase.cpp to bind sockets to a specific source address before initiating outgoing connections.

Factors: security/stability 0, bug 0, performance 0, user value 2, leverage 0

Reviewability: Ready

  • Ready for review with passing CI, no conflicts, and prior feedback addressed

The PR has passing CI, no merge conflicts, and addresses all prior review comments.

Author status: active; addressed all reviewer feedback in August 2026

Resolved concerns:

  • Initial design modified `-bind` semantics to affect outbound connections, which luke-jr and gmaxwell pointed out would break local LAN and bridge routing setups; the author resolved this by keeping `-bind` unchanged and adding a dedicated `-outboundbind` option.
  • vasild requested startup trial validation, strict bare-address parsing without ports, and test updates, all of which the author implemented in subsequent force-pushes.

Agreement: Strong

  • Consensus on dedicated option after dropping earlier plan to overload -bind (luke-jr, gmaxwell)
  • Approach approval following validation and parsing improvements (vasild)
  • Approach approval on the latest revision (winterrdog)
  • Concept approval without stated reasons (frankomosh)

Concept and approach accepted by vasild, winterrdog, and frankomosh after resolving the initial -bind scope concern

The proposal addresses long-standing issue #6476. Early architectural feedback against overloading `-bind` was adopted cleanly with a dedicated `-outboundbind` flag, and subsequent reviews have been approach ACKs.

  • luke-jr and gmaxwell argued against overloading -bind for outbound connections.
  • vasild provided Concept ACK and Approach ACK after the separate option was introduced.
  • frankomosh provided Concept ACK.
  • winterrdog provided Approach ACK on the latest revision.

Review verdicts (DrahtBot): 0

Files

391 lines under test/bench/ci.

  • src/test/net_tests.cpp +202/-0
  • test/functional/feature_bind_outgoing.py +184/-0
  • src/netbase.cpp +62/-3
  • src/init.cpp +48/-0
  • src/net.h +28/-0
  • src/netbase.h +19/-2
  • doc/release-notes-35027.md +7/-0
  • src/net.cpp +4/-3
  • src/test/util/net.h +4/-0
  • test/functional/test_runner.py +1/-0

Card

Adds the -outboundbind=<addr> option to bind outgoing clearnet connections to a specific local source IP address per address family. This solves routing and interface selection challenges for operators of multi-homed nodes, closing long-standing issue #6476. The design avoids changing existing -bind behavior and fails closed if local socket binding fails. The approach has received Concept and Approach ACKs from vasild, frankomosh, and winterrdog, with comprehensive unit and functional test coverage in place.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:51, confidence high, input hash b8f6108e0d051afe