Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    What is the proper way to find which interface an IP routes through? (PHP)

    Development
    1
    2
    2.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      Efonnes
      last edited by

      As a part of a rewrite I'm working on for a certain part of filter.inc, it needs to know which interface would be used for connections to a given IP address outside of the router.  Is there already a defined function or other existing way of doing it?  Preferably the result should match with what the base system would decide, including if there are any additional routes that should be considered.

      This work is on 2.0, so anything available in the latest code is fair game here.

      update:

      Actually, just finding which interface it is accessed through, of the networks directly accessible, probably would be fine.

      1 Reply Last reply Reply Quote 0
      • E
        Efonnes
        last edited by

        The function guess_interface_from_ip seems to be what I was looking for.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.