11

I read here that:

127.0.0.1 is the IP (IPv4) address of your local computer, synonymous with localhost.

When I run the command ipconfig what I actually see is some other IP address. So I’ve pasted my questions below:

C:\Users\Dhiwakar>ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection* 9:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::6089:2937:e839:26ec%10
   IPv4 Address. . . . . . . . . . . : 192.168.1.36
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1
  1. Which is my IPv4 address of my local computer? Is it 127.0.0.1 (as mentioned in the article) or is it 192.168.1.36?

  2. Is the IPv4 used to uniquely identify my computer/machine in the world or my domain or only restricted the my LAN i.e within the set of computers that use the same gateway?

  • 2
    127.0.0.1 is a special address which every IPv4-capable computer can use to talk to itself. 192.168.1.36 is the address that other computers on your LAN will use to talk to it. Because that address is in the 192.168.x.x range, it is only meaningful within your LAN; a server that accepts connections from the whole world will have an address in a different range. – zwol Apr 5 '15 at 0:48
  • 5
    Your first line "I read here that:" seems to indicate that your name is "I". So is your name "Dhiwakar" or is it "I"? 127.0.0.1 isn't an IP address, it is the same as "I". – gnasher729 Apr 5 '15 at 0:52
  • Possible duplicate of Difference between localhost and the ip address – Rick Sep 9 at 18:22
27

There's nothing called "address of the local computer". IP addresses bind with network interfaces. If you have 5 LAN/Wifi cards (network adapters) in your computer then you can have 5 IPs for those interfaces.

Here what you see is the adapter named "Local Area Connection" with IP address 192.168.1.36, while 127.0.0.1 is the address of the loopback adapter in each PC.

There are many types of IP. Things like 10.x.x.x or 192.168.x.x are private addresses which is used to identify your computer inside the local network. Outsiders cannot see what's inside the local network because they have been hidden after NAT. Each local network will connect with WAN via a router and have a public IP address with the interface facing WAN of the router. If your computer is connected directly with public internet, which is extremely unlikely in an IPv4 network due to the limit in the address range and the high price of static IPs, then you'll have WAN (public) IP address too.

  • starting to understand better :) , "Each local network will connect with WAN via a router and have a public IP address with the interface facing WAN of the router". Is the router also the gateway or are they two different entities ? Also the loopback adapter can be used to test TCP/IP stack but not much else right ? – Dhiwakar Ravikumar Apr 4 '15 at 13:05
  • yes. it's a gateway. – phuclv Apr 4 '15 at 13:12
  • 3
    You can also have multiple addresses on an interface, FWIW. – cpast Apr 4 '15 at 13:50
9

Your system can have many ip addresses, and many adaptors, physical or virtual.

Typically you have a loopback adaptor (assigned 127.0.0.1, tho there's actually a block of these) and one or a few more.

In this case, Q1: Yes Q2 No

There's a few things that need to communicate internally with a system - a simple example would be that you'd use 127.0.0.1 (or ::1 in ipv6) to access a website running from the same system.

In the typical home network you'd have a single externally routable/non rfc 1918 address ipv4, with NAT being used to send packets to the appropriate internal host, and RFC 1918 addresses allocated to each internal host. Your 192.168.1.X address is unique to your computer in your lan, but not globally. You'd use this to reach your system from computers in your lan, but not externally. If your machine has multiple interfaces, you can tell 'services' to listen to specific ones. In a typical home lan, I might use 192.168.1.1 to contact my router, but this wouldn't work elsewhere. Likewise, I could use 192.168.1.38 from 192.168.1.39 but not outside

If your PC was the only device, directly connected to a modem or similar device (as opposed to a consumer router) or has a public IP address as part of an organization/ISP that has a block of them, and assigns/routes them for you, you'd have a globally routable IP address. My ISP gives me one ipv4 address and a block of ipv6 addresses, with multiple ipv6 addresses per interface.

Where you have multiple interfaces, you could have a mix of private and public IPs - typically VPS providers do this, so you can access another VPS on the same provider without using your external data quota.

All of them are my ip address from different perspectives. My RFC 1918 address is valid from inside my lan, my external ip address with a port forward is valid externally, and my ipv6 address is valid anywhere there is ipv6.

6

Question 1:

  • The IPv4 address of your computer is, as the ipconfig command reports, 192.168.1.36.
  • As for the 127.0.0.1 address, that is what is called a “loopback” address - it is a special IP address that you can send traffic to that will just go right back to yourself.
  • As you mentioned, on a typical computer, 127.0.0.1 is the same as localhost. If you open up the C:\Windows\System32\drivers\etc\hosts file in Notepad, you can see where the mapping comes from. (And you can change it if you want, but this generally isn't recommended.)
  • What is the loopback address used for? Various things. For example, if you wanted to work on a webpage that you were building but for some reason your computer didn't have any Ethernet or wireless NICs, then you would still be able to get to the website by using a browser to connect to http://127.0.0.1/.

Question 2:

  • The 192.168.1.36 IPv4 address is NOT used to uniquely identify your computer to the world. That is your LAN IP address. Only computers behind your router cam directly access your LAN IP address.
  • If you want to find the address that uniquely identifies you, simply visit http://www.whatismyip.com/.
5

To provide you with a more simple answer than the other textbook answers I see :

127.0.0.1 does not actually send traffic to your router and then back to your computer. Do not get the term "loopback" confused. All that a loopback address does is check your TCP/IP stack. This is the de facto troubleshooting step to test if your TCP/IP stack is configured correctly and if your Network Interface Card is acting properly.

Your IP address is what is actually presented by your router to other computers / servers.

Did you know you can ping 127.0.0.1 without being connected to a network? True story.

  • 1
    Good simple answer. To add a bit more: Use localhost or 127.0.0.1 when you want to use your computer’s network stack but without actually going out to the network. Using either localhost or 127.0.0.1 means you want one piece of software to talk to another piece of software on the same computer. For example, a database client app talking to a database server running on the same computer. Or a web browser talking to a web server on the same computer. When using either that name or that number, you can be certain you are connecting within this same computer and not some other box. – Basil Bourque Apr 5 '15 at 5:58
4
  1. Which is my IPv4 address of my local computer? Is it 127.0.0.1 (as mentioned in the article) or is it 192.168.1.36?

The addresses of 127.0.0.1 and 192.168.1.36 are both for your local computer use, and the 192.168.1.36 is for potential LAN network use. Read on.

  1. Is the IPv4 used to uniquely identify my computer/machine in the world or my domain or only restricted the my LAN i.e within the set of computers that use the same gateway?

The only address that would be used for your larger LAN is 192.168.1.36. The 127.0.0.1 address—and the hostname localhost connected to it—is considered a local loopback address mainly used by the system for testing and local network diagnostics only. Meaning the only way to reach that address is to be logged into your machine directly to begin with.

For what it’s worth, every computer in the world is assigned 127.0.0.1/localhost you cannot remotely connect from one machine to another by accessing 127.0.0.1/localhost. So for the average user, the chances of you ever needing to consciously access 127.0.0.1/localhost is slim to none.

That said, the 192.168.1.36 address is the address most any other computer on your LAN network would use to identify and reach you if your computer is setup to allow for network services. And that would only be applicable if you enable server-like connections to your machine on 192.168.1.36. And this means that if you were logged into 192.168.1.36 and then wanted to “connect to yourself” for testing, yes you could do that to. But traditionally, local system testing uses the 127.0.0.1/localhost adapter.

As for the rest of the world outside of your LAN—also known as the WAN connection—the 192.168.1.36 cannot be connected to remotely outside of your LAN unless you explicitly set your router to do so via port forwarding or something similar. But that concept is beyond the scope of this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.