Skip to content

Fails to bind on specific IPv4 and IPv6 #49

Description

@dzlabing

Command line:

./nettest -s -L 213.208.152.31:443 -L [2a01:190:15ff:4::beef:31]:443 -k server.key -c server.crt

  • Binding on IPv4 works when only the IPv4 is included, as soon as IPv6 is included it fails.
  • why does the code even scan interfaces like lo or bond0 when an address is given?
  • address already in use is wrong, there is no service on this IP.
  • why does it attempt to multicast on other IPs (join multicast group V4 on wanp0 addr 213.208.152.32)?

To me this looks rather broken.

Log:
2026-01-27 18:26:27 [INFO] - Failed to bind TCP V6 listener: Address already in use (os error 98)
2026-01-27 18:26:27 [INFO] - Failed to bind TCP V4 listener: Address already in use (os error 98). On linux it can be because of IPv4-mapped addresses
2026-01-27 18:26:27 [INFO] - TLS Server will listen on V6 [::]:443
2026-01-27 18:26:27 [INFO] - Failed to bind TLS listener: Address already in use (os error 98)
2026-01-27 18:26:27 [INFO] - TLS Server will listen on [2a01:190:15ff:4::beef:31]:443
2026-01-27 18:26:27 [INFO] - MIO TLS Server will listen on [2a01:190:15ff:4::beef:31]:443
2026-01-27 18:26:27 [DEBUG] - Worker 0: starting
2026-01-27 18:26:27 [DEBUG] - Worker 1: starting
2026-01-27 18:26:27 [DEBUG] - Worker 2: starting
2026-01-27 18:26:27 [DEBUG] - Worker 3: starting
2026-01-27 18:26:27 [DEBUG] - Worker 4: starting
2026-01-27 18:26:27 [DEBUG] - Worker 5: starting
2026-01-27 18:26:27 [DEBUG] - Worker 6: starting
2026-01-27 18:26:27 [DEBUG] - Worker 8: starting
2026-01-27 18:26:27 [DEBUG] - Worker 7: starting
2026-01-27 18:26:27 [DEBUG] - Worker 9: starting
2026-01-27 18:26:27 [DEBUG] - Worker 10: starting
2026-01-27 18:26:27 [DEBUG] - Worker 11: starting
2026-01-27 18:26:27 [DEBUG] - Worker 12: starting
2026-01-27 18:26:27 [DEBUG] - Worker 13: starting
2026-01-27 18:26:27 [DEBUG] - Worker 14: starting
2026-01-27 18:26:27 [DEBUG] - Worker 15: starting
2026-01-27 18:26:27 [DEBUG] - Worker 16: starting
2026-01-27 18:26:27 [DEBUG] - Worker 18: starting
2026-01-27 18:26:27 [DEBUG] - Worker 17: starting
2026-01-27 18:26:27 [DEBUG] - Worker 19: starting
2026-01-27 18:26:27 [DEBUG] - Worker 20: starting
2026-01-27 18:26:27 [DEBUG] - Worker 22: starting
2026-01-27 18:26:27 [DEBUG] - Worker 21: starting
2026-01-27 18:26:27 [DEBUG] - Worker 23: starting
2026-01-27 18:26:27 [DEBUG] - Worker 24: starting
2026-01-27 18:26:27 [DEBUG] - Worker 25: starting
2026-01-27 18:26:27 [DEBUG] - Worker 26: starting
2026-01-27 18:26:27 [INFO] - server_config.server_registration: false
2026-01-27 18:26:27 [DEBUG] - Worker 28: starting
2026-01-27 18:26:27 [INFO] - Starting mDNS service for local network discovery...
2026-01-27 18:26:27 [DEBUG] - Worker 27: starting
2026-01-27 18:26:27 [DEBUG] - mDNS service disabled (use -mdns flag to enable)
2026-01-27 18:26:27 [DEBUG] - Worker 29: starting
2026-01-27 18:26:27 [INFO] - Starting mDNS service...
2026-01-27 18:26:27 [INFO] - TLS available on port 443, will be included in mDNS TXT records
2026-01-27 18:26:27 [INFO] - mDNS TXT properties: {"version": "2.0.0", "tls_port": "443", "tcp_port": "443"}
2026-01-27 18:26:27 [INFO] - IP address: 213.208.152.31
2026-01-27 18:26:27 [INFO] - Announcing service: _nettest._tcp.local. on nettest.local.:443 (TCP port in SRV, TLS port in TXT if available)
2026-01-27 18:26:27 [INFO] - mDNS service started successfully. Service will be discoverable in local network.
2026-01-27 18:26:27 [INFO] - Clients can query for '_nettest._tcp' to get server configuration.
2026-01-27 18:26:27 [DEBUG] - join multicast group V4 on lo addr 127.0.0.1
2026-01-27 18:26:27 [DEBUG] - join multicast group V4 on wanp0 addr 213.208.152.31
2026-01-27 18:26:27 [DEBUG] - join multicast group V4 on wanp0 addr 213.208.152.32
2026-01-27 18:26:27 [DEBUG] - failed to join multicast: 213.208.152.32: PKT join multicast group on addr 213.208.152.32: Address already in use (os error 98). Skipped.
2026-01-27 18:26:27 [DEBUG] - join multicast group V4 on wanp0 addr 213.208.152.33
2026-01-27 18:26:27 [DEBUG] - failed to join multicast: 213.208.152.33: PKT join multicast group on addr 213.208.152.33: Address already in use (os error 98). Skipped.
2026-01-27 18:26:27 [DEBUG] - join multicast group V4 on lan addr 172.21.5.4
2026-01-27 18:26:27 [DEBUG] - mDNS service is active and responding to queries
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on lo addr ::1 with index 1
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on wanp0 addr 2a01:190:15ff:4::beef:33 with index 8
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on wanp0 addr 2a01:190:15ff:4::beef:32 with index 8
2026-01-27 18:26:27 [DEBUG] - failed to join multicast: 2a01:190:15ff:4::beef:32: PKT join multicast group on addr 2a01:190:15ff:4::beef:32: Address already in use (os error 98). Skipped.
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on wanp0 addr 2a01:190:15ff:4::beef:31 with index 8
2026-01-27 18:26:27 [DEBUG] - failed to join multicast: 2a01:190:15ff:4::beef:31: PKT join multicast group on addr 2a01:190:15ff:4::beef:31: Address already in use (os error 98). Skipped.
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on wanp0 addr fe80::1270:fdff:fedf:a5ae with index 8
2026-01-27 18:26:27 [DEBUG] - failed to join multicast: fe80::1270:fdff:fedf:a5ae: PKT join multicast group on addr fe80::1270:fdff:fedf:a5ae: Address already in use (os error 98). Skipped.
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on bond0 addr fe80::7415:19ff:fed2:18f1 with index 10
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on lan addr fda1:d2f4:a4a6:1::4 with index 11
2026-01-27 18:26:27 [DEBUG] - join multicast group V6 on lan addr fe80::7415:19ff:fed2:18f1 with index 11
2026-01-27 18:26:27 [DEBUG] - failed to join multicast: fe80::7415:19ff:fed2:18f1: PKT join multicast group on addr fe80::7415:19ff:fed2:18f1: Address already in use (os error 98). Skipped.
2026-01-27 18:26:27 [DEBUG] - register service ServiceInfo { ty_domain: "_nettest._tcp.local.", sub_domain: None, fullname: "nettest._nettest._tcp.local.", server: "nettest.local.", addresses: {213.208.152.31}, port: 443, host_ttl: 120, other_ttl: 4500, priority: 0, weight: 0, txt_properties: TxtProperties { properties: [TxtProperty {key: "version", val: Some("2.0.0")}, TxtProperty {key: "tls_port", val: Some("443")}, TxtProperty {key: "tcp_port", val: Some("443")}] }, addr_auto: false, status: {}, requires_probe: true, supported_intfs: [All], is_link_local_only: false }
2026-01-27 18:26:27 [DEBUG] - prepare_announce (ipv4: true): no valid addrs on interface lo
2026-01-27 18:26:27 [DEBUG] - prepare_announce (ipv4: false): no valid addrs on interface lo
2026-01-27 18:26:27 [DEBUG] - prepare to announce service nettest._nettest._tcp.local. on [213.208.152.31]
2026-01-27 18:26:27 [DEBUG] - new probe of nettest._nettest._tcp.local.
2026-01-27 18:26:27 [DEBUG] - insert record TYPE_SRV into probe of nettest._nettest._tcp.local.
2026-01-27 18:26:27 [DEBUG] - insert record TYPE_TXT into probe of nettest._nettest._tcp.local.
2026-01-27 18:26:27 [DEBUG] - new probe of nettest.local.
2026-01-27 18:26:27 [DEBUG] - insert record TYPE_A into probe of nettest.local.
2026-01-27 18:26:27 [DEBUG] - prepare_announce (ipv4: false): no valid addrs on interface wanp0
2026-01-27 18:26:27 [DEBUG] - prepare_announce (ipv4: true): no valid addrs on interface bond0
2026-01-27 18:26:27 [DEBUG] - prepare_announce (ipv4: false): no valid addrs on interface bond0
2026-01-27 18:26:27 [DEBUG] - prepare_announce (ipv4: true): no valid addrs on interface lan
2026-01-27 18:26:27 [DEBUG] - prepare_announce (ipv4: false): no valid addrs on interface lan
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest.local.': Equal
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest._nettest._tcp.local.': Equal
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest.local.': Equal
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest._nettest._tcp.local.': Equal
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest.local.': Equal
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest._nettest._tcp.local.': Equal
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest.local.': Equal
2026-01-27 18:26:27 [DEBUG] - tiebreaking 'nettest._nettest._tcp.local.': Equal
2026-01-27 18:26:28 [DEBUG] - tiebreaking 'nettest.local.': Equal
2026-01-27 18:26:28 [DEBUG] - tiebreaking 'nettest._nettest._tcp.local.': Equal
2026-01-27 18:26:28 [DEBUG] - tiebreaking 'nettest.local.': Equal
2026-01-27 18:26:28 [DEBUG] - tiebreaking 'nettest._nettest._tcp.local.': Equal
2026-01-27 18:26:28 [DEBUG] - probe of 'nettest.local.' finished: move 1 records to active. (1 waiting services)
2026-01-27 18:26:28 [DEBUG] - probe of 'nettest._nettest._tcp.local.' finished: move 2 records to active. (1 waiting services)
2026-01-27 18:26:28 [DEBUG] - prepare to announce service nettest._nettest._tcp.local. on [213.208.152.31]
2026-01-27 18:26:28 [DEBUG] - found active record TYPE_SRV nettest._nettest._tcp.local.
2026-01-27 18:26:28 [DEBUG] - found active record TYPE_TXT nettest._nettest._tcp.local.
2026-01-27 18:26:28 [DEBUG] - found active record TYPE_A nettest.local.
2026-01-27 18:26:28 [DEBUG] - prepare_announce (ipv4: false): no valid addrs on interface wanp0
2026-01-27 18:26:28 [DEBUG] - wake up: announce service nettest._nettest._tcp.local. on wanp0
2026-01-27 18:26:29 [DEBUG] - prepare to announce service nettest._nettest._tcp.local. on [213.208.152.31]
2026-01-27 18:26:29 [DEBUG] - found active record TYPE_SRV nettest._nettest._tcp.local.
2026-01-27 18:26:29 [DEBUG] - found active record TYPE_TXT nettest._nettest._tcp.local.
2026-01-27 18:26:29 [DEBUG] - found active record TYPE_A nettest.local.
2026-01-27 18:26:29 [DEBUG] - prepare_announce (ipv4: false): no valid addrs on interface wanp0
2026-01-27 18:26:29 [DEBUG] - resend: announce service nettest._nettest._tcp.local. on wanp0
2026-01-27 18:26:37 [INFO] - TLS connection added to global queue (queue size: 1)
2026-01-27 18:26:37 [INFO] - Worker 10: taking connection from global queue (queue size after: 0)
2026-01-27 18:26:37 [INFO] - Worker 10: processing connection
2026-01-27 18:26:37 [DEBUG] - Loading certificates from server.crt
2026-01-27 18:26:37 [DEBUG] - Successfully parsed 2 certificates
2026-01-27 18:26:37 [DEBUG] - Loading private key from server.key
2026-01-27 18:26:37 [DEBUG] - Successfully loaded private key: Pkcs8(PrivatePkcs8KeyDer("[secret key elided]"))
2026-01-27 18:26:37 [INFO] - RustlsServerStream created
2026-01-27 18:26:37 [INFO] - Worker 10: registering connection
2026-01-27 18:26:37 [INFO] - Worker 10: handle_greeting_receive_connection_type
2026-01-27 18:26:37 [DEBUG] - decided upon suite TLS13_AES_256_GCM_SHA384
2026-01-27 18:26:37 [DEBUG] - Processed new packets 0
2026-01-27 18:26:37 [DEBUG] - Processed new packets 0
2026-01-27 18:26:37 [DEBUG] - WouldBlock 1
2026-01-27 18:26:37 [DEBUG] - mDNS service is active and responding to queries
2026-01-27 18:26:37 [DEBUG] - Processed new packets 95
2026-01-27 18:26:37 [DEBUG] - Worker 10: is_websocket: false
2026-01-27 18:26:37 [DEBUG] - Worker 10: writing upgrade response
2026-01-27 18:26:37 [DEBUG] - Worker 10: wrote 72 bytes HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: RMBT

2026-01-27 18:26:37 [DEBUG] - Worker 10: reregistering stream
2026-01-27 18:26:37 [INFO] - Worker 10: handshake done
2026-01-27 18:26:37 [DEBUG] - Worker 10 registered new connection with token Token(1) (total connections: 1)
2026-01-27 18:26:37 [DEBUG] - handle_greeting_send_version for client [2a01:4f9:5a:1258:deef::1]:46204
2026-01-27 18:26:37 [DEBUG] - handle_greeting_send_version version: RMBTv1.5.0

2026-01-27 18:26:37 [DEBUG] - handle_greeting_send_accept_token
2026-01-27 18:26:37 [DEBUG] - Wrote handle_greeting_send_accept_token 18
^C2026-01-27 18:26:39 [INFO] - Ctrl+C received, shutting down server...
2026-01-27 18:26:39 [INFO] - Shutdown signal received, stopping server...
2026-01-27 18:26:39 [INFO] - Server stopping...
2026-01-27 18:26:39 [INFO] - Starting graceful shutdown...
2026-01-27 18:26:39 [INFO] - Server shutdown complete
2026-01-27 18:26:39 [INFO] - Server stopped
2026-01-27 18:26:39 [DEBUG] - MIO TCP Server shutting down

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions