Nmap online course

IPv4 Addresses: Structure, Assignment, and Identification

Learn how IPv4 addresses identify network interfaces, how CIDR separates network and host portions, how DHCP assigns addresses, and how to view IP configuration on Windows and Linux.

What Is an IP Address?

An IP address is a logical network-layer address used by Internet Protocol networks to identify interfaces and route traffic. It gives devices a way to send and receive data across an IP network.

A host is a network-connected device or endpoint, such as a laptop, server, phone, printer, or router. A host communicates through one or more network interfaces, such as Ethernet, Wi-Fi, a VPN adapter, or a virtual interface. Each interface can have one or more assigned IP addresses.

A device needs an appropriate IP configuration to communicate with other devices on a TCP/IP network. To reach destinations beyond the local LAN, it also normally needs a correct subnet configuration and a default gateway, which is the router used to reach other networks.

IPv4 Address Size and Notation

In many introductory networking contexts, “IP address” commonly means an IPv4 address. IPv4 uses 32 bits, divided into four groups of 8 bits. Each 8-bit group is called an octet.

IPv4 is normally written in dotted-decimal notation: four decimal octets separated by periods. Each octet has a value from 0 through 255 because 8 bits can represent 256 values.

192.168.0.1
10.0.0.25

For example, 192.168.0.1 contains four octets: 192, 168, 0, and 1. Each value must be within the range 0–255.

Network and Host Portions

An IPv4 address is interpreted together with a subnet mask or a CIDR prefix length. The prefix length is slash notation, such as /24, that states how many of the 32 bits belong to the network prefix. The remaining bits identify hosts within that network.

The division is not fixed solely by the first or last decimal number. The subnet mask or CIDR prefix determines where the network portion ends and the host portion begins.

Example: 192.168.0.1/24

In the simple example 192.168.0.1/24, the first 24 bits are the network portion and the final 8 bits are available for host numbering. The equivalent subnet mask is 255.255.255.0.

  • Network address: 192.168.0.0
  • Host address: 192.168.0.1
  • Network prefix: 192.168.0.0/24

The network address represents the subnet rather than one individual host. An address such as 192.168.0.1 can be assigned to an interface, often a router or another host, within that subnet.

Example addressCIDR prefixSubnet maskNetwork portionHost portionNetwork address
192.168.0.1/24/24255.255.255.0First 24 bitsFinal 8 bits192.168.0.0
10.0.0.25/8/8255.0.0.0First 8 bitsFinal 24 bits10.0.0.0
172.16.5.10/16/16255.255.0.0First 16 bitsFinal 16 bits172.16.0.0

How IPv4 Addresses Are Assigned

Static or Manual Configuration

A static IP address is configured manually or reserved so that an interface consistently receives the same address. Static configuration can be useful for servers, network appliances, printers, and infrastructure that other systems must reliably find.

Manual configuration must match the local network. An incorrect address, prefix, gateway, or DNS setting can prevent communication or create address conflicts.

Dynamic Assignment with DHCP

DHCP, the Dynamic Host Configuration Protocol, automatically provides network configuration to clients. Home and enterprise laptops, phones, and desktop computers commonly receive their settings from a local router or DHCP server when they join a network.

A DHCP response commonly includes:

  • An IPv4 address
  • A subnet mask or CIDR prefix
  • A default gateway
  • DNS server addresses
  • A lease duration

A lease is temporary. A laptop might receive a private address such as 192.168.1.20, then receive a different address after the lease expires, the device reconnects, or the DHCP server changes its allocation. A DHCP reservation can provide consistent assignment without manually configuring the client.

Local DHCP and the Public Internet

In a typical home network, a router provides DHCP to local devices. Those devices use private IPv4 addresses, while the router has a separate public-facing address supplied through the Internet service provider or another upstream network. The router forwards traffic between the private LAN and the public network, often using network address translation.

This arrangement does not mean every computer on the LAN receives an address directly from the ISP. The local DHCP server normally configures the computers; the router separately obtains or is assigned the public-facing address.

Common IPv4 Address Categories

CategoryRange or exampleTypical meaningPublicly routable
Private RFC 191810.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Internal addresses used on private networksNo, not directly on the public Internet
Loopback127.0.0.1Local-only communication with the current machineNo
Link-local169.254.0.0/16Often self-assigned when DHCP is unavailableNo
Public addressFor example, an address allocated for Internet useGlobally reachable according to routing and firewall policyGenerally yes

A private IPv4 address is intended for internal networks and is not globally routed on the public Internet. A public IP address is globally routable in principle, although firewalls, carrier policies, and routing configuration still affect reachability.

IP Addresses Versus MAC Addresses

A MAC address is a link-layer interface identifier used on a local network segment. An IP address is a logical, configurable address used at the network layer.

CharacteristicIP addressMAC address
Network layerNetwork layer, used by IPLink layer
ScopeSupports communication between different networksNormally operates on the local link
AssignmentConfigured manually or assigned dynamicallyUsually associated with a network interface by its manufacturer or software
Routing roleRouters use IP information to forward trafficNot used to route traffic across separate IP networks
FormatIPv4 uses four decimal octets, such as 192.168.1.20Often six hexadecimal pairs, such as 00:11:22:33:44:55

A network interface can therefore have both a MAC address and one or more IP addresses. MAC addressing helps deliver frames on the local link, while IP addressing supports routing between networks.

View Your Local IPv4 Configuration

Windows

Open Command Prompt or PowerShell and run:

ipconfig

Locate the active Ethernet or Wi-Fi adapter. Read its IPv4 Address, Subnet Mask, and Default Gateway fields. Disconnected adapters can usually be ignored unless you are troubleshooting them.

For expanded details, including DHCP status, the MAC address, DNS servers, and lease information, run:

ipconfig /all

Linux

Use the modern ip command to display interface addresses:

ip addr show

Find an active interface such as eth0, enp0s3, or wlan0. An IPv4 entry is labeled inet, for example:

inet 192.168.1.20/24

The slash suffix is the CIDR prefix length. To quickly print assigned non-loopback addresses, use:

hostname -I

This output can contain more than one address. To inspect routing information, including the default gateway, use:

ip route

Legacy Linux and Unix Environments

The older ifconfig command may be available on legacy systems or through a separately installed package:

ifconfig

Look for the interface's IPv4 output, often labeled inet. ifconfig is deprecated on many modern Linux distributions, so prefer ip addr show when possible.

How to Recognize the Address You Need

  • Loopback: 127.0.0.1 reaches only the current machine. It is not the machine's LAN address.
  • Link-local: 169.254.x.x commonly indicates that the host could not obtain a DHCP lease.
  • Private LAN: An address such as 10.1.2.3 is commonly used inside an organization or home network.
  • Public: An address outside the private and special-use ranges may be publicly allocated, but actual reachability depends on routing and security controls.

If multiple addresses appear, the host may have several physical or virtual interfaces, a VPN, containers, or multiple configured addresses. Identify the interface carrying the active default route instead of assuming the first displayed address is the relevant LAN address.

Practical Example: A Laptop Joins Wi-Fi

  1. The laptop associates with a wireless network.
  2. Its interface requests configuration from the local DHCP server, often running on the router.
  3. The server supplies a private IPv4 address, prefix, gateway, DNS settings, and lease duration.
  4. The laptop uses the local subnet for nearby devices and sends traffic for other networks to the default gateway.

If the laptop later reconnects, renews its lease, or moves to another network, its IPv4 address may change.

IPv4 and IPv6

IPv6 is a later version of Internet Protocol that uses 128-bit addresses. IPv6 notation and interpretation differ from IPv4: IPv6 addresses use colon-separated hexadecimal groups rather than four dotted-decimal octets.

This lesson focuses on IPv4. For deeper study, continue with IPv4 headers, private IP addresses, and the TCP/IP protocol suite.

Troubleshooting IPv4 Configuration

No Expected IPv4 Address

Likely causes include a disconnected or disabled interface, Wi-Fi connected to the wrong network, or an unavailable DHCP server.

  • Verify that the adapter is connected and active.
  • Run ipconfig /all on Windows or ip addr show on Linux.
  • Check whether a DHCP lease, IPv4 address, prefix, and default gateway are present.

The Address Begins with 169.254

The host probably did not obtain a DHCP lease and assigned itself a link-local address. Check the DHCP service, switch or Wi-Fi connection, and VLAN placement. Reconnect or renew the lease only when appropriate for the environment.

The Address Is 127.0.0.1

You are viewing the loopback interface rather than an Ethernet or Wi-Fi interface. Select the active physical or wireless interface; loopback cannot identify the machine's LAN address.

An IPv4 Address Exists but Internet Access Fails

Possible causes include a missing or incorrect default gateway, an incorrect prefix or subnet mask, DNS failure, or an upstream router or ISP outage.

  • Compare the address and prefix with the expected local configuration.
  • Inspect the default route with ip route on Linux or the gateway fields in ipconfig /all on Windows.
  • Test a known IP destination separately from testing a DNS name to distinguish routing problems from name-resolution problems.

IPv4 Addresses in Network Discovery

IP addresses are common targets and scope definitions in Nmap. Understanding the local address and CIDR prefix helps you select an intended lab host or subnet rather than guessing from one address.

For an authorized lab, document the permitted subnet and use its prefix to identify the intended range. For example, a permitted 192.168.1.0/24 lab subnet is a different scope from a single host such as 192.168.1.20. Do not probe systems or address ranges without explicit authorization.

Continue with specifying an IP address range, discovering whether a host is online, and what Nmap is.

Exam-Relevant Notes

  • IPv4 addresses contain 32 bits.
  • Each IPv4 octet contains 8 bits and ranges from 0 through 255.
  • The subnet mask or CIDR prefix, not simply an octet's position, determines the network and host portions.
  • 127.0.0.1 is IPv4 loopback.
  • 169.254.x.x commonly indicates link-local addressing after DHCP failure.
  • Private IPv4 addresses are intended for internal networks and are not directly globally routed.
  • IP addresses operate at the network layer; MAC addresses operate on the local link.
  • IPv6 uses 128-bit addresses and colon-separated hexadecimal notation.