How do I get my external IP address from the Windows and Linux command line?
On Windows, ipconfig shows an internal network IP address, but it does not show the external one.
|
|
|||||||||
|
|
Neither Windows or Linux is aware of its external IP address, so they cannot natively let you know. So you have to use an external service to find out what the IP address is. Under linux, you can use
There are equivilent options for Windows, such as installing curl. Note that curl itself is not determining your IP address, it is simply asking an external website what IP address you appear to be coming from. However, the best way to do this is to use a dynamic DNS (DDNS) service like no-ip.com. Here you can dynamically register your external IP address into DNS. So instead of using an IP address, you can use a domain address, such as Most domestic routers support updating DDNS automatically when the external address changes, and if not, there are clients for Windows and linux (ddclient). |
|||||||||||||||
|
|
A Google search for What's my IP address works quite well.
You can also get some information about your network to give you a good idea about what is going on. Using tools like netstat, traceroute, ssh or telnet you can figure out how you are getting on the puplic network of the Internet. There are the public and private IP address. If you know which is the private IP address ranges then you can guess which IP address you are using on the outside network. As soon as
a Private network (Wikipedia)
I would start by finding my default gateway. In Linux:
In Windows:
Which should show you something like
Notice the default at the bottom, that should be your last step before going out into the public world. Now a Linux:
Windows:
Which should give you some thing like this
The step after my default route was onto our outside network. The Google search differed from the
What might help here is to know that one device the router has all three IP addresses. The private one, 172.16.0.2 (default route), and the internal one provided buy our ISP ##.###.###.178 and the external one ##.###.###.177 our ISP uses to connect to the Internet. So if I know how to remotely connect to the router using Telnet/ssh I can use query the router directly to get this information using the command line. Different routers and ISP's have different ways of managing this. Most home DSL modems are quite easy to get ssh into as you have the password and login information but if the ISP has put in a router at your office, they probably won't give you access to their router. |
||||
|
|
|
You can use the lynx tool to get the external ip. lynx --dump http://whatismyip.org |
|||||||
|
|
Your machine doesn't know your external address. You have to use an external service and fetch the results (e.g., checkip.dyndns.org). You can use any command line HTTP clients as wget or curl:
wget is available on both Windows and GNU/Linux |
|||
|
|
|
ifconfig.me is a site you can visit in the browser to get nearly all the information you need. You can also use Eg:
|
|||
|
|