There can be several reasons that you need or want to know the IP address of a computer. Some reasons may be more legitimate than others. Maybe you're a network administrator and need to know the address to run some checks or to do some network configuration. You may also have something else in mind. Toy mau want to ask yourself first : You can ask a girl for her telephone number, so you can call her and ask her out or so. You can also try all kinds of sneaky tricks to find out who she is, where she lives and what her telephone number is. And then when you have her phone number, are you really going to call her - and maybe have to explain just how you got her number ? You may well have spoiled your chances, haven't you ?
Each computer with TCP/IP set up has an IP address : 127.0.0.1, the 'localhost' or 'loopback' address.
When a computer is connected to a network, be it a Local Area Network or the internet, it has an IP address that identifies it on the network. The operating system usually offers a command that shows this IP address :
DOS TCP/IP users may try 'SET' to view environment variables, or look up the configuration files. See DOS TCP/IP.
Ping is a useful command to find if a given IP address is 'online', and it will resolve names (computer names, URL's) to IP addresses when used like this :
ping (computer name), e.g. ping SERVER01
ping a fully qualified domain name, e.g. ping www.playboy.com or ping pop3.africaonline.com
with 'netstat', you can see the active connections of your computer.
netstat has options to show either names or addresses, and you can give an interval to refresh, so that it checks and shows connections every , say, 12 seconds. Like this ;
netstat -a -n 12
'netstat /?' will show more options
So if you're computer has an active connection with another computer, e.g. by communication software or file exchange software such as netmeeting, ICQ, Kazaa and other peer-to-peer applications, ... netstat will show that computer's IP address, and the TCP port it is using to communicate with your computer.
Of course, when the communication passes trough a server (eg MSN chat), you'll only see the IP address of that server.
When you receive an email message, a "Received from" line has been added to it by every server it passes. The 'received from' at the bottom of the list indicates the IP address of the computer the message was sent from. Most e-mail programs hide these message headers, but have an option to show them.
Received: from mailagent0.ientrymail.com (220.127.116.11) by mail.tiscali.be (6.7.015) id 3E9BA434502780F8 for firstname.lastname@example.org; Mon, 21 Apr 2003 2:37:49 Received: from agent3.ientrymail.com (18.104.22.168) by mailagent0.ientrymail.com (PowerMTA(TM) v1.5)
Your operating system, or other software on your computer (a fire wall, ...) may be able to log IP addresses of incoming and outgoing connections, or attempted connections.
the tracert command (on Linux : traceroute) shows the IP addresses of all nodes (routers) between your computer and a remote computer.
c:\windows>tracert pop3.tiscali.be Tracing route to pop3.tiscali.be [22.214.171.124] over maximum 30 hops: 1 2 ms 2 ms 2 ms homepc [10.0.0.1] 2 13 ms 15 ms 14 ms D577G301.kabel.telenet.be [126.96.36.199] 3 13 ms 13 ms 13 ms 10.32.10.193 4 13 ms 13 ms 12 ms 10.31.1.97 5 15 ms 13 ms 14 ms D5E0FD91.kabel.telenet.be [188.8.131.52] 6 17 ms 39 ms 16 ms IBASSE02-SRP5-0.telenet-ops.be [184.108.40.206] 7 18 ms 17 ms 26 ms 220.127.116.11 8 18 ms 18 ms 16 ms 18.104.22.168 9 20 ms 16 ms 17 ms unknown.Level3.net [22.214.171.124] 10 18 ms 19 ms 17 ms tiscali-intl.bnix.net [126.96.36.199] 11 20 ms 17 ms 18 ms tiscali-be-1.ip.tiscali.net [188.8.131.52] 12 17 ms 18 ms 17 ms 184.108.40.206 13 18 ms 18 ms 16 ms 220.127.116.11 Trace completed
Web sites can collect certain information about the computer that is used to visit them. (here's a small example). It is possible to apply a script that reads the IP address of the visiting computer, then use a method to send this information to a given e-mail adress (like when you fill in information on a web form or when using web mail). It is therefore possible to have a web site that collects and informs you about IP addresses of visitors. As explained here . You can also collect them from your web servers logs, hit counters, etc.
The "professional" way of finding IP addresses is by querying "whois" databases. Public IP addresses are registered to companies and this information is accessible in online databases through the unix 'whois' command or with online whois services. A typical starting point is the IP address or the domain name in a website's URL. explained here.