Achievable logoAchievable logo
CCNA
Sign in
Sign up
Purchase
Textbook
Practice exams
Support
How it works
Exam catalog
Mountain with a flag at the peak
Textbook
Introduction
1. Introduction to networking
2. Administering Ethernet LANs
3. IP connectivity
3.1 Understanding IP addresses
3.1.1 IPv4 addressing
3.1.2 IPv4 network addresses vs. host addresses
3.1.3 Public vs. private IP addresses
3.2 Calculating networks and hosts
3.3 Routers and IPv4 routing fundamentals
3.4 Static routing
3.5 Static vs. dynamic routing and OSPF fundamentals
3.6 Router redundancy in an Ethernet LAN using First Hop Redundancy Protocols (FHRPs)
3.7 Configuring Cisco Routers
4. Network services
5. IPv6
6. Wireless networking
7. Network management and administering network devices
8. Network security fundamentals
9. Network automation and programmability
Wrapping up
Achievable logoAchievable logo
3.1.1 IPv4 addressing
Achievable CCNA
3. IP connectivity
3.1. Understanding IP addresses
Our CCNA course is currently in development and is a work-in-progress.

IPv4 addressing

8 min read
Font
Discuss
Share
Feedback

In this chapter, we’ll focus on Layer 3: the Network layer. This is the layer where most routing decisions happen, so it’s a major focus for many network administrators and engineers.

This is also the layer where routers operate. Before getting into how IP routing works, you need a solid understanding of IPv4 addressing and network boundaries. In this chapter, we’ll discuss IP version 4 (IPv4) only. Later in the book, we’ll also cover IP version 6 (IPv6).

IPv4 addressing

In Chapter 1.4 The Layers of the TCP/IP model, we discussed that every device that communicates on a TCP/IP-based network must have an Internet Protocol (IP) address. This is a logical address assigned by a network administrator to a NIC card, and it’s associated with the NIC’s MAC address. An IP address does two important jobs:

  • It identifies a host on a network.
  • It indicates which IP network that host belongs to.

IP networks have boundaries. Within a single IP network, there’s a range of IP addresses that can be assigned to hosts. A key skill for a network administrator is knowing how to determine that range for any given network.

The construct that defines the network boundary is the subnet mask. The subnet mask tells you where an IP network begins and ends. By inspecting the subnet mask, you can also determine the size of the network - in other words, how many IP addresses this network can accommodate.

Understanding binary

Before we discuss the structure of an IPv4 address, we need to understand binary and why it matters for IP addressing.

Binary (also called the base-2 numeral system) is a numbering system that uses only ones and zeroes (1s and 0s). Computers interpret data using binary, and networking devices like routers and switches do the same. Humans work comfortably with words and decimal numbers, but computers and networking devices ultimately process information as 1s and 0s.

In computing:

  • 1 means on
  • 0 means off

At the physical layer, those 1s and 0s are represented as signals:

  • On copper Ethernet, a 1 might be represented by (roughly) 1 volt, and a 0 by 0 volts.
  • On fiber optic cable, a 1 is the presence of a light signal, and a 0 is the absence of that light.

When 1s and 0s arrive in a particular sequence, devices interpret that sequence as data. It’s similar to how we combine letters into words and words into sentences - except computers do it with bits.

(Image 120)

Image Title - Binary digits compared with the word “CAFE”

What we’ve done in the image above is we’ve represented the word “CAFE” as a string of Hexadecimal characters. Below that, we have converted those Hexadecimal characters (or “letters”) into Binary. When we place those individual blocks together, we end up with what the Binary representation of that string would look like.

We will also discuss Hexadecimal in more detail later in the IPv6 chapters.

With that in mind, to understand the value of an IP address and determine what network it belongs to, you need to be able to convert an IP address from dotted decimal format into binary.

(Image 121)

Image Title - IP Address 192.168.1.2 in Dotted Decimal and Binary

The structure of an IPv4 address

In the image above, you can see the IP address 192.168.1.2 in dotted decimal notation, and below it you can see its binary representation. Each binary digit is called a bit. As discussed earlier:

  • 1 bits are “on”
  • 0 bits are “off”

An IPv4 address contains 32 bits total. Those 32 bits are split into 4 portions called octets. They’re called octets because each portion contains 8 bits.

In dotted decimal notation:

  • Each octet is separated by a dot (.)
  • Each octet is shown as a decimal number

Each octet can have a decimal value from 0 to 255.

A natural next question is: how do you convert a decimal number into binary? Let’s walk through the process.

Converting from decimal to binary

To convert from decimal to binary, you need to understand the positional values within an octet. Positional values are the numeric values assigned to each bit position.

This is similar to place value in decimal numbers (1s place, 10s place, 100s place). For example, in the number 254:

(Image 122)

Image Title - Positional Values of the whole number 254

In decimal, the digits represent different place values (hundreds, tens, ones). Binary works the same way, but the values increase by powers of 2.

For an 8-bit octet, the positional values are:

128 64 32 16 8 4 2 1

(Image 123)

Image Title - Positional Values of an Octet

In binary, each position can contain only:

  • 1 (meaning we “use” that positional value)
  • 0 (meaning we don’t)

Let’s convert the first octet of 192.168.1.2, which is 192, into binary.

(Image 124)

Image Title - Binary sequence for 192

To decide whether a position gets a 1 or a 0, you repeatedly ask: Is the remaining number greater than or equal to this positional value?

You should follow along by drawing this out on a sheet of paper and practicing this. That’s the best way to master it.

Starting with the first positional value of 128:

  • Is 192 greater than or equal to 128?
  • If the answer is “yes”, (which it is), then we must place a 1 in the 128 column.
  • Then, we’ll subtract the positional value 128 from 192 (192 - 128) and we end up with 64.

Let’s move on to the next positional value (64) and ask a similar question using the number we just subtracted:

  • Is 64 greater than or equal to 64?
  • Here, the answer is still “yes”, so then we will place a 1 in the 64 column.
  • Then, we will subtract the value 64 from the difference in the previous step, which was also 64 (64 - 64) and we end up with 0.

Hopefully by now, you can see the pattern. We continue this all the way until we reach the final positional value of 1. Since we’re already left with the number 0, which is not greater or equal to any of the remaining positional values, the final Binary sequence in the first Octet then becomes:

11000000

Let’s also do the second octet (168) together.

Starting with the first positional value of 128:

  • Is 168 greater than or equal to 128?
  • Yes, so we must place a 1 in the 128 column.
  • Then, we’ll subtract the positional value 128 from 168 (168 - 128) and we end up with 40.

Moving on to the second positional value (64):

  • Is 40 greater than or equal to 64?
  • No, so we must place a 0 in the 64 column.
  • Whenever there is a “0” in the positional value, we do not subtract, we simply move on to the next positional value.

Third positional value, 32:

  • Is 40 greater than or equal to 32?
  • Yes, so we must place a 1 in the 32 column.
  • Then, we’ll subtract the positional value 32 from 40 (40 - 32) and we end up with 8.

Fourth positional value, 16:

  • Is 8 greater than or equal to 16?
  • No, so we must place a 0 in the 16 column.
  • Whenever there is a “0” in the positional value, we do not subtract, we simply move on to the next positional value.

Fifth positional value, 8:

  • Is 8 greater than or equal to 8?
  • Yes, so we must place a 1 in the 8 column.
  • Then, we’ll subtract the positional value 8 from 8 (8 - 8) and we end up with 0.

At this point, we’re already at 0, so the remaining positional values will be 0. The binary representation of 168 then becomes:

10101000

This same procedure would be repeated for the 3rd and 4th octets, which have much easier numbers to calculate.

Hopefully you can now see how to convert decimal numbers to binary digits within an octet.

Converting from binary to decimal

To convert from binary to decimal, the simplest method is to add up the positional values that have a 1.

  • Wherever you see a positional value with a 1, add that value.
  • Ignore any positional values that contain a 0.

The total is the decimal value of the octet.

(Image 125)

Image Title - Adding up all the positional values within an Octet

As you can see, converting from binary to decimal is much simpler than converting from decimal to binary.

For practice, attempt to convert the following IP addresses into binary:

  • 10.1.1.255
  • 172.32.1.4
  • 192.168.8.64

In the next chapter, we’ll look at how the bits within a subnet mask determine what network an IP address belongs to.

Network layer (layer 3)

  • Handles routing decisions in networks
  • Routers operate at this layer
  • Focus on IPv4 addressing and network boundaries

IPv4 addressing

  • Logical address assigned to NIC, linked to MAC address
  • Identifies host and its network membership
  • Network boundaries defined by subnet mask
    • Subnet mask determines network size and address range

Binary (base-2) system

  • Uses only 1s (on) and 0s (off)
  • Computers and networking devices process data in binary
  • Physical representation:
    • Copper: voltage levels
    • Fiber: light presence/absence
  • IP addresses must be understood in both decimal and binary

Structure of an IPv4 address

  • 32 bits total, divided into 4 octets (8 bits each)
  • Dotted decimal notation: octets separated by dots, values 0-255
  • Each octet’s value determined by its binary representation

Decimal to binary conversion

  • Each octet uses positional values: 128, 64, 32, 16, 8, 4, 2, 1
  • Place 1 if decimal value ≥ positional value, subtract and continue
  • Place 0 if decimal value < positional value, move to next position

Binary to decimal conversion

  • Add positional values where bit is 1
  • Ignore positions with 0
  • Sum equals decimal value of octet

Sign up for free to take 10 quiz questions on this topic

Previous
Next  | 3.1.2 IPv4 network addresses vs. host addresses
All rights reserved ©2016 - 2026 Achievable, Inc.

IPv4 addressing

In this chapter, we’ll focus on Layer 3: the Network layer. This is the layer where most routing decisions happen, so it’s a major focus for many network administrators and engineers.

This is also the layer where routers operate. Before getting into how IP routing works, you need a solid understanding of IPv4 addressing and network boundaries. In this chapter, we’ll discuss IP version 4 (IPv4) only. Later in the book, we’ll also cover IP version 6 (IPv6).

IPv4 addressing

In Chapter 1.4 The Layers of the TCP/IP model, we discussed that every device that communicates on a TCP/IP-based network must have an Internet Protocol (IP) address. This is a logical address assigned by a network administrator to a NIC card, and it’s associated with the NIC’s MAC address. An IP address does two important jobs:

  • It identifies a host on a network.
  • It indicates which IP network that host belongs to.

IP networks have boundaries. Within a single IP network, there’s a range of IP addresses that can be assigned to hosts. A key skill for a network administrator is knowing how to determine that range for any given network.

The construct that defines the network boundary is the subnet mask. The subnet mask tells you where an IP network begins and ends. By inspecting the subnet mask, you can also determine the size of the network - in other words, how many IP addresses this network can accommodate.

Understanding binary

Before we discuss the structure of an IPv4 address, we need to understand binary and why it matters for IP addressing.

Binary (also called the base-2 numeral system) is a numbering system that uses only ones and zeroes (1s and 0s). Computers interpret data using binary, and networking devices like routers and switches do the same. Humans work comfortably with words and decimal numbers, but computers and networking devices ultimately process information as 1s and 0s.

In computing:

  • 1 means on
  • 0 means off

At the physical layer, those 1s and 0s are represented as signals:

  • On copper Ethernet, a 1 might be represented by (roughly) 1 volt, and a 0 by 0 volts.
  • On fiber optic cable, a 1 is the presence of a light signal, and a 0 is the absence of that light.

When 1s and 0s arrive in a particular sequence, devices interpret that sequence as data. It’s similar to how we combine letters into words and words into sentences - except computers do it with bits.

(Image 120)

Image Title - Binary digits compared with the word “CAFE”

What we’ve done in the image above is we’ve represented the word “CAFE” as a string of Hexadecimal characters. Below that, we have converted those Hexadecimal characters (or “letters”) into Binary. When we place those individual blocks together, we end up with what the Binary representation of that string would look like.

We will also discuss Hexadecimal in more detail later in the IPv6 chapters.

With that in mind, to understand the value of an IP address and determine what network it belongs to, you need to be able to convert an IP address from dotted decimal format into binary.

(Image 121)

Image Title - IP Address 192.168.1.2 in Dotted Decimal and Binary

The structure of an IPv4 address

In the image above, you can see the IP address 192.168.1.2 in dotted decimal notation, and below it you can see its binary representation. Each binary digit is called a bit. As discussed earlier:

  • 1 bits are “on”
  • 0 bits are “off”

An IPv4 address contains 32 bits total. Those 32 bits are split into 4 portions called octets. They’re called octets because each portion contains 8 bits.

In dotted decimal notation:

  • Each octet is separated by a dot (.)
  • Each octet is shown as a decimal number

Each octet can have a decimal value from 0 to 255.

A natural next question is: how do you convert a decimal number into binary? Let’s walk through the process.

Converting from decimal to binary

To convert from decimal to binary, you need to understand the positional values within an octet. Positional values are the numeric values assigned to each bit position.

This is similar to place value in decimal numbers (1s place, 10s place, 100s place). For example, in the number 254:

(Image 122)

Image Title - Positional Values of the whole number 254

In decimal, the digits represent different place values (hundreds, tens, ones). Binary works the same way, but the values increase by powers of 2.

For an 8-bit octet, the positional values are:

128 64 32 16 8 4 2 1

(Image 123)

Image Title - Positional Values of an Octet

In binary, each position can contain only:

  • 1 (meaning we “use” that positional value)
  • 0 (meaning we don’t)

Let’s convert the first octet of 192.168.1.2, which is 192, into binary.

(Image 124)

Image Title - Binary sequence for 192

To decide whether a position gets a 1 or a 0, you repeatedly ask: Is the remaining number greater than or equal to this positional value?

You should follow along by drawing this out on a sheet of paper and practicing this. That’s the best way to master it.

Starting with the first positional value of 128:

  • Is 192 greater than or equal to 128?
  • If the answer is “yes”, (which it is), then we must place a 1 in the 128 column.
  • Then, we’ll subtract the positional value 128 from 192 (192 - 128) and we end up with 64.

Let’s move on to the next positional value (64) and ask a similar question using the number we just subtracted:

  • Is 64 greater than or equal to 64?
  • Here, the answer is still “yes”, so then we will place a 1 in the 64 column.
  • Then, we will subtract the value 64 from the difference in the previous step, which was also 64 (64 - 64) and we end up with 0.

Hopefully by now, you can see the pattern. We continue this all the way until we reach the final positional value of 1. Since we’re already left with the number 0, which is not greater or equal to any of the remaining positional values, the final Binary sequence in the first Octet then becomes:

11000000

Let’s also do the second octet (168) together.

Starting with the first positional value of 128:

  • Is 168 greater than or equal to 128?
  • Yes, so we must place a 1 in the 128 column.
  • Then, we’ll subtract the positional value 128 from 168 (168 - 128) and we end up with 40.

Moving on to the second positional value (64):

  • Is 40 greater than or equal to 64?
  • No, so we must place a 0 in the 64 column.
  • Whenever there is a “0” in the positional value, we do not subtract, we simply move on to the next positional value.

Third positional value, 32:

  • Is 40 greater than or equal to 32?
  • Yes, so we must place a 1 in the 32 column.
  • Then, we’ll subtract the positional value 32 from 40 (40 - 32) and we end up with 8.

Fourth positional value, 16:

  • Is 8 greater than or equal to 16?
  • No, so we must place a 0 in the 16 column.
  • Whenever there is a “0” in the positional value, we do not subtract, we simply move on to the next positional value.

Fifth positional value, 8:

  • Is 8 greater than or equal to 8?
  • Yes, so we must place a 1 in the 8 column.
  • Then, we’ll subtract the positional value 8 from 8 (8 - 8) and we end up with 0.

At this point, we’re already at 0, so the remaining positional values will be 0. The binary representation of 168 then becomes:

10101000

This same procedure would be repeated for the 3rd and 4th octets, which have much easier numbers to calculate.

Hopefully you can now see how to convert decimal numbers to binary digits within an octet.

Converting from binary to decimal

To convert from binary to decimal, the simplest method is to add up the positional values that have a 1.

  • Wherever you see a positional value with a 1, add that value.
  • Ignore any positional values that contain a 0.

The total is the decimal value of the octet.

(Image 125)

Image Title - Adding up all the positional values within an Octet

As you can see, converting from binary to decimal is much simpler than converting from decimal to binary.

For practice, attempt to convert the following IP addresses into binary:

  • 10.1.1.255
  • 172.32.1.4
  • 192.168.8.64

In the next chapter, we’ll look at how the bits within a subnet mask determine what network an IP address belongs to.

Key points

Network layer (layer 3)

  • Handles routing decisions in networks
  • Routers operate at this layer
  • Focus on IPv4 addressing and network boundaries

IPv4 addressing

  • Logical address assigned to NIC, linked to MAC address
  • Identifies host and its network membership
  • Network boundaries defined by subnet mask
    • Subnet mask determines network size and address range

Binary (base-2) system

  • Uses only 1s (on) and 0s (off)
  • Computers and networking devices process data in binary
  • Physical representation:
    • Copper: voltage levels
    • Fiber: light presence/absence
  • IP addresses must be understood in both decimal and binary

Structure of an IPv4 address

  • 32 bits total, divided into 4 octets (8 bits each)
  • Dotted decimal notation: octets separated by dots, values 0-255
  • Each octet’s value determined by its binary representation

Decimal to binary conversion

  • Each octet uses positional values: 128, 64, 32, 16, 8, 4, 2, 1
  • Place 1 if decimal value ≥ positional value, subtract and continue
  • Place 0 if decimal value < positional value, move to next position

Binary to decimal conversion

  • Add positional values where bit is 1
  • Ignore positions with 0
  • Sum equals decimal value of octet

More from Understanding IP addresses

  • IPv4 network addresses vs. host addresses
  • Public vs. private IP addresses