Understanding Network Interfaces: Loopback, Local IPs, and Public IPs

Many computer users have likely encountered scenarios where they use localhost, 127.0.0.1, or directly input the local machine's IP address. At first glance, these three methods all seem to access the local machine, but why do these three different forms exist? What are the differences between them? While they may appear similar, the distinctions are actually quite significant. Additionally, you may be confused about the relationship between public and private networks, network interface cards (NICs), and IP addresses. The following explanations will clarify these topics. Local Machine IP Our computer motherboards come with multiple built-in network interface cards (NICs), generally classified into the following types: Virtual NIC (Loopback) Note: This is a virtual network interface, not a physical one. It is also referred to as the local loopback address (or interface), typically using 127.0.0.1 as the local loopback address. Wired NIC / Ethernet Card This is used for Ethernet (local area networks). When people refer to a network card, they usually mean this type, which connects to the network via a cable. Wireless NIC (WLAN) This type of network card is used for wireless local area networks (WLAN). Laptops commonly have built-in wireless NICs, which use radio technology and do not require a physical cable like Ethernet cards. Each of these network interfaces is assigned a local machine IP address. localhost is a Special Domain Name First and foremost, localhost is not an IP address; rather, it is a special domain name (without a suffix). By default, it resolves to the local IP address (127.0.0.1). The resolution of localhost is managed via the local hosts file. If desired, you can configure localhost to resolve to a public IP address or any other IP address (this can be modified using the hosts file). However, in most cases, it resolves to: IPv4: 127.0.0.1 IPv6: [::1] Location of the hosts file: C:\Windows\System32\drivers\etc 127.0.0.1 is a Reserved Private IP Address for the Local Machine 127.0.0.1 is a private IP address that represents the local loopback address. Essentially, it is an IP address bound to the virtual NIC (loopback interface). What is a Loopback Address? A loopback address is a special address used by a host to communicate with itself (i.e., a special destination address). When two services on the same host use the loopback address instead of the assigned machine address, they can bypass the lower layers of the TCP/IP protocol stack. This means the communication does not need to go through the link layer, physical layer, or Ethernet; instead, it can be directly processed within the network and transport layers. The address block with a network number of 127 is not an actual network address. Any IP packet sent to an address in this range will not be transmitted to an external network interface—it remains within the host. Therefore, 127.0.0.1 is one of the reserved addresses frequently used for testing the local TCP/IP stack. If you can successfully ping this address, it indicates that your network interface card (NIC) and IP protocol stack are correctly installed, regardless of whether the machine is connected to a network. In fact, IPv4 reserves the entire 127.0.0.0/8 subnet for loopback testing (with a couple of exceptions). 127.0.0.1 is just one of the addresses in this range. You can ping any address within this range or enter any such address in a web browser to access local web services. Another commonly confused IP address is 0.0.0.0. Unlike 127.0.0.1, 0.0.0.0 represents the machine itself in a different way and is used in different contexts. Example Use Case: Suppose a computer has two NICs: One uses a public IP to connect to the Internet. The other uses a private IP to connect to a local network. If the computer hosts a web service and wants to allow access from both external (Internet) and internal (LAN) sources, it can configure the server to listen on 0.0.0.0. Differences Between localhost, Local Machine IP, and 127.0.0.1 Network Requirements localhost and 127.0.0.1 do not require an active network connection. Even if the machine is completely offline, accessing these addresses will still resolve to the local system. Local machine IPs (wired and wireless network IPs) require an active network connection. These are the IP addresses that allow external access to the machine. Access Scope localhost is used only for local access. 127.0.0.1 is also only for local access. Local machine IPs can be used for both local and external access. Domain vs. IP Address localhost is a domain name and, by default, resolves to 127.0.0.1. A local machine IP is the actual IP address assigned to the machine’s physical NIC, which allows external devices to access it. Usage in a Local Network Within a local area network (LAN

Feb 6, 2025 - 19:27
 0
Understanding Network Interfaces: Loopback, Local IPs, and Public IPs

Cover

Many computer users have likely encountered scenarios where they use localhost, 127.0.0.1, or directly input the local machine's IP address. At first glance, these three methods all seem to access the local machine, but why do these three different forms exist? What are the differences between them? While they may appear similar, the distinctions are actually quite significant.

Additionally, you may be confused about the relationship between public and private networks, network interface cards (NICs), and IP addresses. The following explanations will clarify these topics.

Local Machine IP

Our computer motherboards come with multiple built-in network interface cards (NICs), generally classified into the following types:

Virtual NIC (Loopback)

Note: This is a virtual network interface, not a physical one. It is also referred to as the local loopback address (or interface), typically using 127.0.0.1 as the local loopback address.

Wired NIC / Ethernet Card

This is used for Ethernet (local area networks). When people refer to a network card, they usually mean this type, which connects to the network via a cable.

Wireless NIC (WLAN)

This type of network card is used for wireless local area networks (WLAN). Laptops commonly have built-in wireless NICs, which use radio technology and do not require a physical cable like Ethernet cards.

Each of these network interfaces is assigned a local machine IP address.

localhost is a Special Domain Name

First and foremost, localhost is not an IP address; rather, it is a special domain name (without a suffix). By default, it resolves to the local IP address (127.0.0.1). The resolution of localhost is managed via the local hosts file. If desired, you can configure localhost to resolve to a public IP address or any other IP address (this can be modified using the hosts file). However, in most cases, it resolves to:

  • IPv4: 127.0.0.1
  • IPv6: [::1]

Location of the hosts file:

C:\Windows\System32\drivers\etc

127.0.0.1 is a Reserved Private IP Address for the Local Machine

127.0.0.1 is a private IP address that represents the local loopback address. Essentially, it is an IP address bound to the virtual NIC (loopback interface).

What is a Loopback Address?

A loopback address is a special address used by a host to communicate with itself (i.e., a special destination address).

When two services on the same host use the loopback address instead of the assigned machine address, they can bypass the lower layers of the TCP/IP protocol stack. This means the communication does not need to go through the link layer, physical layer, or Ethernet; instead, it can be directly processed within the network and transport layers.

The address block with a network number of 127 is not an actual network address. Any IP packet sent to an address in this range will not be transmitted to an external network interface—it remains within the host.

Therefore, 127.0.0.1 is one of the reserved addresses frequently used for testing the local TCP/IP stack. If you can successfully ping this address, it indicates that your network interface card (NIC) and IP protocol stack are correctly installed, regardless of whether the machine is connected to a network.

In fact, IPv4 reserves the entire 127.0.0.0/8 subnet for loopback testing (with a couple of exceptions). 127.0.0.1 is just one of the addresses in this range. You can ping any address within this range or enter any such address in a web browser to access local web services.

Another commonly confused IP address is 0.0.0.0. Unlike 127.0.0.1, 0.0.0.0 represents the machine itself in a different way and is used in different contexts.

Example Use Case:

Suppose a computer has two NICs:

  • One uses a public IP to connect to the Internet.
  • The other uses a private IP to connect to a local network.

If the computer hosts a web service and wants to allow access from both external (Internet) and internal (LAN) sources, it can configure the server to listen on 0.0.0.0.

Differences Between localhost, Local Machine IP, and 127.0.0.1

Network Requirements

  • localhost and 127.0.0.1 do not require an active network connection. Even if the machine is completely offline, accessing these addresses will still resolve to the local system.
  • Local machine IPs (wired and wireless network IPs) require an active network connection. These are the IP addresses that allow external access to the machine.

Access Scope

  • localhost is used only for local access.
  • 127.0.0.1 is also only for local access.
  • Local machine IPs can be used for both local and external access.

Domain vs. IP Address

  • localhost is a domain name and, by default, resolves to 127.0.0.1.
  • A local machine IP is the actual IP address assigned to the machine’s physical NIC, which allows external devices to access it.

Usage in a Local Network

  • Within a local area network (LAN), computers in the same subnet can use the machine’s assigned IP address (private IP) to connect to it. This does not apply to localhost or 127.0.0.1, which are only for local use.

Network Interface (NIC) Address & IP Address

NIC Address (MAC Address)

A NIC (network interface card) address, also known as a MAC address (Media Access Control), is a physical or hardware address used to uniquely identify a network device.

In the OSI model:

  • The Network Layer (Layer 3) is responsible for IP addresses.
  • The Data Link Layer (Layer 2) is responsible for MAC addresses.

Each MAC address is unique and assigned to a device’s NIC. It is globally unique, similar to how an ID card number uniquely identifies a person.

IP Address

An IP address (Internet Protocol Address) is a logical address used in networking. Unlike MAC addresses, IP addresses can be changed and are assigned based on network configurations.

Summary

  • MAC Address: A fixed, unique physical address assigned to a NIC.
  • IP Address: A changeable logical address assigned to a NIC.

To check your IP and MAC addresses, use the command:

ipconfig /all

Public IP vs. Private IP

Accessing Devices via IP Addresses

  • 127.0.0.1 → Accesses the local machine.
  • Private IP → Accesses other devices within the LAN.
  • Public IP → Accesses other devices on the Internet.

Public IP Address (Internet IP)

To set up a corporate network with Internet access, a company needs to obtain a broadband connection from an Internet Service Provider (ISP). The ISP assigns a public IP address, allowing devices within the corporate network to access the Internet.

  • Public IP addresses are allocated and managed by Internet NICs (Internet Network Information Centers).
  • Devices with public IPs can be accessed directly from the Internet.
  • Public IPs are part of wide area networks (WANs).

Private IP Address (LAN IP)

Private IPs are used within an organization or home network to connect internal devices. These addresses are not routable on the Internet and must be translated using NAT (Network Address Translation) before accessing external networks.

  • Private IPs are defined for internal use and cannot be directly accessed from the Internet.
  • If a private IP device needs to access the Internet, it must go through a NAT gateway that converts private IPs to a public IP.

Accessing Public and Private Networks

If a private network (LAN) device needs to access a public network (Internet), it must go through SNAT (Source NAT).

  • The public Internet (managed by ISPs) consists of public IPs.
  • Private IPs are not routable on the Internet and will be blocked unless translated via NAT.

If a public network (Internet) device needs to access a private network (LAN) device, it requires DNAT (Destination NAT), VPN, or port forwarding.

For communication between two private networks across the public Internet, a VPN (Virtual Private Network) can be used.

Internal Network vs. External Network

  • The internal network (LAN) is essentially a private network.
  • The external network (WAN) can include both public Internet and other private networks.

Key Takeaway:

  • "Public network" ≠ "External network."
  • In simple terms, Public Network = External Network and Private Network = Internal Network, but technically, the definitions differ slightly.

Complete Range of IP Addresses

IP addresses are divided into five classes with the following ranges:

  • Class A: 1.0.0.1 – 127.255.255.254
  • Class B: 128.0.0.1 – 191.255.255.254
  • Class C: 192.0.0.1 – 223.255.255.254
  • Class D: 224.0.0.0 – 239.255.255.255 (Reserved for multicast)
  • Class E: 240.0.0.0 – 255.255.255.255 (Reserved for future use)

Among these, Class A, B, and C are commonly used on the Internet:

  • Class D is used for multicast communications.
  • Class E is reserved for future and experimental purposes.

Special IP Addresses

  • 0.0.0.0 → Represents the current host.
  • 255.255.255.255 → Broadcast address for the current subnet.
  • Class E IPs (11110 prefix) → Reserved for experimental use.
  • Loopback addresses (127.x.x.x) → Reserved for local loopback testing (e.g., 127.0.0.1 for web server testing).
  • Network IDs cannot start with 0, as 0.0.0.0 represents the local network.

Public IP Address Ranges

Within Class A, B, and C, specific ranges are designated for public IP addresses:

  • Class A Public IPs:

    • 1.0.0.0 – 9.255.255.255
    • 11.0.0.0 – 126.255.255.255
  • Class B Public IPs:

    • 128.0.0.0 – 172.15.255.255
    • 172.32.0.0 – 191.255.255.255
  • Class C Public IPs:

    • 192.0.0.0 – 192.168.255.255
    • 192.169.0.0 – 223.255.255.255

Private IP Address Ranges

The following IP address ranges are reserved for private networks and cannot be routed on the Internet:

  • Class A Private IPs: 10.0.0.0 – 10.255.255.255 (10.0.0.0/8)
  • Class B Private IPs: 172.16.0.0 – 172.31.255.255 (172.16.0.0/12)
  • Class C Private IPs: 192.168.0.0 – 192.168.255.255 (192.168.0.0/16)

These addresses are not assigned by Internet authorities and are meant for internal network use. Even though they cannot directly communicate with the Internet, NAT (Network Address Translation) can allow private network devices to access the public Internet.

Many internal network devices, such as printers, managed switches, and smart devices, also use private IP addresses to conserve public IP resources.

Subnetworks & Local Area Networks (LANs)

What is a Subnetwork (Subnet)?

A subnet refers to a segment of a computer network that shares the same physical network devices (e.g., switches or hubs). Computers within the same subnet can communicate directly.

What is a Local Area Network (LAN)?

A LAN is a network that consists of multiple interconnected devices within a limited area (e.g., an office, building, or home network). A LAN can contain multiple subnets.

  • If all devices in a LAN are in the same subnet, they can communicate directly.
  • A LAN can be divided into multiple subnets using VLANs (Virtual Local Area Networks).

Devices Can Only Communicate Within the Same Subnet

Devices in the same subnet can communicate with each other directly. If two devices are in different subnets, they need to communicate through a router.

How to Determine if Two IPs Belong to the Same Subnet

To check if two IP addresses belong to the same subnet, use the subnet mask:

  1. Convert the IP address and subnet mask to binary.
  2. Perform a bitwise AND operation on both values.
  3. Compare the results—if they match, the two IPs are in the same subnet.

Example 1

Given:

  • IP Address 1: 192.168.1.1
  • Subnet Mask: 255.255.255.0
  • IP Address 2: 192.168.1.2
  • Subnet Mask: 255.255.255.0

Analysis:

Both addresses belong to the 192.168.1.0 subnet, so they are in the same subnet.

Example 2

Given:

  • IP Address 1: 192.168.1.1
  • Subnet Mask: 255.255.255.0
  • IP Address 2: 192.168.1.2
  • Subnet Mask: 255.255.0.0

Analysis:

At first glance, the two IPs look similar. However:

  • 192.168.1.1 with 255.255.255.0 belongs to 192.168.1.0/24.
  • 192.168.1.2 with 255.255.0.0 belongs to 192.168.0.0/16.

Since the subnet IDs are different, they are NOT in the same subnet.

Example 3

Given:

  • IP Address 1: 192.168.1.1
  • Subnet Mask: 255.255.252.0
  • IP Address 2: 192.168.2.1
  • Subnet Mask: 255.255.252.0

Analysis:

  • Unlike Example 1, the subnet mask here is 255.255.252.0 instead of 255.255.255.0.
  • 192.168.1.1 and 192.168.2.1 both belong to 192.168.0.0/22.

Since they fall within the same subnet range, they are in the same subnet.

Final Thoughts

Understanding localhost, 127.0.0.1, local IPs, and public/private IPs is crucial for networking and system administration. The key takeaways are:

  • localhost is a domain name (defaulting to 127.0.0.1).
  • 127.0.0.1 is a loopback address used for local testing.
  • Local IPs allow external access, while 127.0.0.1 and localhost do not.
  • Public IPs are routable on the Internet, while private IPs are used within internal networks.
  • Subnet masks determine whether two IPs belong to the same subnet.
  • Routers are required to communicate across different subnets.

By understanding these fundamentals, you can efficiently troubleshoot and configure network environments.

We are Leapcell, your top choice for hosting backend projects.

Leapcell

Leapcell is the Next-Gen Serverless Platform for Web Hosting, Async Tasks, and Redis:

Multi-Language Support

  • Develop with Node.js, Python, Go, or Rust.

Deploy unlimited projects for free

  • pay only for usage — no requests, no charges.

Unbeatable Cost Efficiency

  • Pay-as-you-go with no idle charges.
  • Example: $25 supports 6.94M requests at a 60ms average response time.

Streamlined Developer Experience

  • Intuitive UI for effortless setup.
  • Fully automated CI/CD pipelines and GitOps integration.
  • Real-time metrics and logging for actionable insights.

Effortless Scalability and High Performance

  • Auto-scaling to handle high concurrency with ease.
  • Zero operational overhead — just focus on building.

Explore more in the Documentation!

Try Leapcell

Follow us on X: @LeapcellHQ

Read on our blog