Hi -
Actually, there are several - completely different - questions here. The answer to most of them is "Yes".
I think you're asking:
1. Are there 'C' functions or shell commands where I can find out all of my network interfaces (eth0, eth1, etc) and all of the (possibly multiple) IP addresses associated with each of these network interfaces?
But perhaps you're asking:
2. If I've established a TCP/IP connection with some other host, are there 'C' functions or shell commands where I can find out which (of possibly multiple) local IP addresses I'm actually communicating over (ie. "what is my endpoint?")?
You're probably not asking:
3. What is my localhost IP address?
A: "localhost" generally == "loopback" == 127.0.0.1.
In general, "ifconfig", "netstat -in", "netstat -a" and "lsof" are probably going to be the most useful shell commands.
As far as 'C', you can use "gethostbyname()" or look inside the internals of any active "struct sockaddr". There are lots and lots of other options as well, depending on your specific requirements.
'Hope that helps .. PSM
Last edited by paulsm4; 10-01-2005 at 12:43 PM.
|