Get a list of network interfaces in PHP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joshua Beall

    Get a list of network interfaces in PHP?

    Hi All,

    I've got a utility I'm working on, and I want to be able to list for
    the user all the current network interfaces on the machine. Is there a
    way to do this in PHP? PHP 5.0.3, Mandriva Linux 2005 (2.6 kernel).
    I'm not actually in front of the machine in question, and I don't
    recall the minor kernel version, or the minor version of Mandriva...

    Any thoughts? I'd prefer not to have to run the script as root,
    incidentally. I realize I could run as root and then just parse the
    output of ifconfig, but I assume there's a more intelligent way to go
    about what I'm trying to do.

    The purpose of this utility is to allow me to issue a ping, from a
    specified interface (including virtual interfaces, e.g., eth0:1), and
    test for connectivity from the webserver to the the address i am
    pinging, through the specified network interface (rather than always
    pinging from the default/primary interface of the machine).

    Any thoughts? How would I go about this? I haven't been able to come
    up with a way to do this, short of running as root and parsing
    ifconfig, as I mentioned above.

    -Josh

  • Rik

    #2
    Re: Get a list of network interfaces in PHP?

    Joshua Beall wrote:
    Hi All,
    >
    I've got a utility I'm working on, and I want to be able to list for
    the user all the current network interfaces on the machine. Is there
    a way to do this in PHP? PHP 5.0.3, Mandriva Linux 2005 (2.6 kernel).
    I'm not actually in front of the machine in question, and I don't
    recall the minor kernel version, or the minor version of Mandriva...
    >
    Any thoughts? I'd prefer not to have to run the script as root,
    incidentally. I realize I could run as root and then just parse the
    output of ifconfig, but I assume there's a more intelligent way to go
    about what I'm trying to do.
    >
    The purpose of this utility is to allow me to issue a ping, from a
    specified interface (including virtual interfaces, e.g., eth0:1), and
    test for connectivity from the webserver to the the address i am
    pinging, through the specified network interface (rather than always
    pinging from the default/primary interface of the machine).
    >
    Any thoughts? How would I go about this? I haven't been able to come
    up with a way to do this, short of running as root and parsing
    ifconfig, as I mentioned above.
    I would not use PHP for this. Perhaps C(++), far more up to the task.
    --
    Rik Wasmus


    Comment

    • Enzo Canuzzi

      #3
      Re: Get a list of network interfaces in PHP?

      Hi,
      Any thoughts? I'd prefer not to have to run the script as root,
      incidentally. I realize I could run as root and then just parse the
      output of ifconfig, but I assume there's a more intelligent way to go
      about what I'm trying to do.
      You can read in the /proc files. Try for example $cat /proc/net/dev.

      Comment

      Working...