Skip to content

Missing a way to get local IP address for received UDP message #1649

Description

@GlenTiki

This is a duplicate of nodejs/node-v0.x-archive#8788

Basically: I have a udp server listening on a port on multiple interfaces - when I get a message on this port, I would like to be able to detect what interface the message was received from.

Activity

  1. added
    dgramIssues and PRs related to UDP and the dgram module.
    feature requestIssues requesting new Node.js features.
    on May 7, 2015
  2. bnoordhuis commented on May 7, 2015

    @bnoordhuis
    Member

    Also nodejs/node-v0.x-archive#6589. There are valid use cases and I think it would make a good addition.

    However, different platforms have different quirks and there may be performance implications to consider. It's not really clear to me what the best way forward is.

  3. kanongil commented on Jun 12, 2015

    @kanongil
    Contributor

    I just encountered this issues when working on a multicast receiver, which is a slightly different case.

    Essentially, it is impossible to only receive packets on a specific multicast address when the port number is otherwise used on the host.

    1. Process 1 registers and listens to traffic for 239.254.1.1:1234.
    2. Process 2 registers and listens to traffic for 239.254.1.2:1234.

    Now both will have bound to port 1234 and receive all packets on that interface.

    To fix this, we need to filter on the destination address, either manually using an exposed destination property, or through a new bind option.

    Edit: My issue can be fixed by binding to the multicast address.

  4. nickdesaulniers commented on Dec 14, 2015

    @nickdesaulniers

    This would be helpful for my ICE agent since I need to create sockets for each address accessible from the network. I have to do some funky iteration through os.networkInterfaces and also can't seem to bind to specific ipv6 addresses.

  5. added
    libuvIssues and PRs related to the libuv dependency or the uv binding.
    help wantedIssues that need assistance from volunteers or PRs that need help to proceed.
    on Jun 8, 2016
  6. added
    stalledIssues and PRs manually marked as stalled and scheduled for automatic closure.
    on Jul 7, 2017
  7. 6 remaining items

  8. JKRhb commented on Aug 21, 2023

    @JKRhb

    If I see it correctly, this issue has not really been resolved yet, right?

  9. bnoordhuis commented on Aug 22, 2023

    @bnoordhuis
    Member

    It's never been implemented because of irreconcilable platform differences. The last attempt was almost 10 years ago but I don't think the situation has materially improved.

  10. JKRhb commented on Aug 22, 2023

    @JKRhb

    I see, thank you for your feedback on this! Since the issue remains unresolved, would make it sense to reopen it, though..?

  11. bnoordhuis commented on Aug 22, 2023

    @bnoordhuis
    Member

    Only if there is some way forward but that's not the case here. If it can't be made to work, it can't be made to work.

  12. oxygen commented on Aug 22, 2023

    @oxygen

    For broadcast UDP messages I just listened on the broadcast address of each subnet of each interface. Don't listen on 255.255.255.255.

    This should work for unicast too (by listening on specific addresses).

    Normally you won't find two interfaces with overlapping subnets. If you do, then problably it has something to do with those platform differences and you surely already have bigger problems like NodeJS not allowing binding/restricting the socket to a specific interface.

    So, in short, you shouldn't need Node telling you the destination IP address of the received packet, you can figure it out.

    Also, by listening on specific broadcast addresses and specific IPs you can automatically rule out interfaces you're not suposed to listen on. A big security plus as a default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dgramIssues and PRs related to UDP and the dgram module.feature requestIssues requesting new Node.js features.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.libuvIssues and PRs related to the libuv dependency or the uv binding.stalledIssues and PRs manually marked as stalled and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions