473,378 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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

Oct 23 '06 #1
2 5774
Rik
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
Oct 24 '06 #2
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.
Oct 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Matthew K Jensen | last post by:
In one of my "because I can" projects, I want to be able to see the enabled network interfaces on a machine. I have no clue as to how to do this. Any suggestions?
6
by: John Walton | last post by:
Hello, everyone. I just began school, and they already assigned us science fair. Since I'm in 8th grade, I get to do demonstrations for our projects. I'm probably going to demonstrate Python's...
1
by: le dahut | last post by:
Hi, Is there a way to get network parameters (number of network interfaces, ip address(es), DNS, gateway) on a linux station using python 2.3 ? Klaas
2
by: Marc-André | last post by:
Hi, I would to know if there's a way to use a particular network interfaces to access network(programmatically c#). The problem is that if my wireless network card is working, I want my...
6
by: fabrizio | last post by:
I've to write an applications which emulates the network, so this application must write and read all the data passing on network interfaces like eth0 and tap0(virtual ethernet interface). How can...
8
by: rongchaua | last post by:
Hi all, i would like now to disable and enable network adapter programmatically with c#. I have searched but found nothing useful. There's no topic about this problem. Has someone done with this...
1
by: steve1rm | last post by:
Hello, I have a problem trying to connect a remote sql server. The error: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may...
2
by: Dave | last post by:
Hi everyone, I've got a program which sends UDP data which works perfectly on my PC but not on my laptop. The problem experienced is that sometimes on the laptop packets that I send just...
0
by: WastedsXeYouth | last post by:
Hi, i am currently revising for an exam on networks, this scenerio is one which keeps arising and im unsure as to what the layout would be and what exactly happens in part 2.... Q) The computer...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.