This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: IP ADDRESS OF MACHINE
- From: snodx at hotmail dot com
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 28 Feb 2002 16:19:17 +0530
- Subject: Re: IP ADDRESS OF MACHINE
OK After reading Mr Rupert Wood's post I decided that enough is enough
and decided to test whether a NetWork Card is installed on my system or
not.
So I connected an Internet Router to my Linux computer. If there is a
NetWork Card installed on my computer then I should be able to access
the Internet.
And voila, there is a NetWork Card installed on my system.
I had already set the Computer's TCP/IP Address to 192.168.0.2. The
Internet router's address was set to 151.137.54.204
So by accessing the internet I was able to confirm that there is indeed a
NetWork Card on my computer.
But I decided to explore a bit further. I came across a command /bin/netstat
I ran this command /bin/netstat --route
This was the output that I got:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.2 * 255.255.255.255 UH 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 151.137.54.204 0.0.0.0 UG 0 0 0 eth0
I am now slowly able to understand some of the Jargon that Mr Rupert wood was using.
He talked about interfaces and I understand now that there is a EtherNet Interface
eth0 installed on my system.
So now this is the final-most-precise-version of my question:
I have a EtherNet Interface eth0 installed on my system. The TCP/IP Address of
my computer has been set to 192.168.0.2.
I wish to develop a C/C++ program that can retrieve the local computer's TCP/IP Address.
I DONT WANT THE PROGRAM TO SEARCH IN THE /etc/hosts FILE WHICH IS I BELIEVE USED FOR
A DIFFERENT PURPOSE.
In short I am looking for a program like /bin/netstat --route only this program is to be
much much much simpler. It just needs to retrieve the TCP/IP Address 192.168.0.2 and display
it.
Thanx for everybody's inputs here.
Awaiting a final reply.
SNODX