On GNU/Linux, the easiest way would be grabbing the IP address from the output of ifconfig, which could be something like this (if the interface is ppp0):
/sbin/ifconfig | grep -A1 ppp0 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "

If were talking about ppp, another way of doing it is getting the address from the ip-up script. On RedHat it is located in /etc/ppp/, but it might differ across distributions. I recommend creating a script called ip-up.local and have it output it's arguments somewhere. This script will be run automagically from ip-up that'll pass the IP address to it.

/etc/ppp/ip-up.local is passed the arguments interface, device, linespeed, IP address, remote IP address and for some reason the interface again. (I guess the last is an alias or something)

This would send an e-mail to root containing the IP address whenever a ppp-interface is up:


echo "IP address:$4" | mail -s "Woohoo" root@localhost
Noether mentioned that the variable $LOCALIP in ip-up contains the address, but I like the above solution better, as ip-up.local won't be overwritten when you upgrade the ppp package and ip-up will. But then, it's probably different on other distros.

You could also put DEBUG=yes in ifcfg-ppp0 (or whatever interface) and look in /var/log/messages.

To find your IP address in Windows NT, including Windows 2000, use a command-line program called ipconfig.

From the Command Prompt, enter ipconfig. This gives the IP address for each active connection.

For more detailed information, use ipconfig /all.

Assuming you only have one interface, that is.

Windows 9x has the winipcfg command which gives plenty of information about various configured interfaces. In a nice GUI no less! Windows NT or 2000 users can find the information from the "network" section of the control panel. The path is:

Proticols tab
TCP/IP Protocol ->Properties->IP Address

(It's been pointed out to me that this doesn't work if you have a DHCP assigned IP address. If you're using DHCP, use the ipconfig /all method as described above)

If you're more adventurous, pop up a command prompt and type 'route print' and look in the column labelled 'interface' for the most common address.

Any UNIX system will give you information on IP addresses with this command:

ifconfig -a

Go to www.whatismyipaddress.com .

While there are other websites that do the same thing, this is the only one I know of with a URL that is easy to remember, and pronounce. This is what to do if you're troubleshooting a computer over the phone and need to know its IP address.

Websites like these will give you the IP address of the computer that actually connects to the server and fetches the page. This is not necessarily the computer that the web browser is running on. If you're using a proxy, it will be the ip address of the proxy. If you're on a network with cascaded proxies, it will be the one furthest down the chain. If you're using NAT, it will be the IP address of the NAT machine. If you're on something more complicated, such as transparent proxying, it could be anything.

Other services like this include:

  1. https://www.everything2.com/index.pl?node=ipfrom
  2. http://www.everything2.com/index.pl?node=ipfrom
  3. http://checkip.dyndns.org
URL 1 is special - it uses SSL, so the communication with the server is encrypted. This means that transparent proxies can't intercept it. It is very likely that the results of URL 1 are the IP address of the computer the browser is running on. If you suspect a transparent proxy, visit urls 1 and 2, and if they come up with different numbers, you're stuck behind one.

As an aside, computers don't have IP addresses, IP hosts do. There may be more than one host per network device, and more than one network device per computer. This is how your IP address can be, and all at the same time. If you're running linux, you have full control over the mapping of IP addresses to network devices. Most distributions ship such that are all valid loopbacks. being the loopback is only a standard on the Internet. On your own LAN/WAN you can set your IP addresses any odd way you like.

On Mac OS X, you can use the aforementioned shell tools inside Terminal, or for those among us who prefere a GUI, your IP address will be under:

System Preferences > Network > Whichever port you use > TCP/IP Tab

You can also use a little toy called FruitMenu to make OS X show your IP in the Apple menu.

Log in or register to write something here or to contact authors.