Every device on a network needs an address, and computers read those addresses in binary. In this lesson you will learn to convert between the dotted-decimal numbers people read and the bits devices use.
What an IPv4 address is
An IPv4 address is 32 bits, written as four 8-bit groups called octets, separated by dots. Each octet ranges from 0 to 255.
- Example:
192.168.10.25 - In binary:
11000000.10101000.00001010.00011001 - Part of the address identifies the network, and the rest identifies the host on that network.
- The subnet mask tells you where that split happens. A mask like
255.255.255.0means the first 24 bits are the network part.
Binary to decimal
Each bit in an octet has a place value. From left to right they are:
128 64 32 16 8 4 2 1
To convert binary to decimal, add the place values where the bit is 1.
11000000= 128 + 64 = 19200001010= 8 + 2 = 1011111111= 255 (all bits on)
To convert decimal to binary, go left to right and ask whether each place value fits into what remains. For 25: 128 no, 64 no, 32 no, 16 yes (remainder 9), 8 yes (remainder 1), 4 no, 2 no, 1 yes. That gives 00011001.
Network, host, and special addresses
When you apply a mask, the address splits into two parts. The first address in a range (all host bits 0) is the network address. The last (all host bits 1) is the broadcast address. Neither can be given to a device.
- Network
192.168.10.0with mask255.255.255.0: usable hosts are.1through.254, and the broadcast is.255. - Private ranges (not routed on the internet):
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16. 127.0.0.1is loopback, which means “this device itself”.169.254.x.xis a self-assigned address that often signals that a DHCP server could not be reached. This is a useful clue when troubleshooting.
Practice in your own lab
In Packet Tracer or on your own practice computer, you can check an address with a built-in command:
ipconfig (Windows)
ip addr (Linux)
Compare the address and mask shown to the binary you calculated by hand.
Check your understanding
What is the decimal value of the binary octet 11000000?
- 128
- 192
- 224
- 240
Answer: 192 128 + 64 = 192, because only the first two bits are set.
How many bits are in an IPv4 address?
- 8
- 16
- 32
- 128
Answer: 32 Four octets of 8 bits each make 32 bits.
Which address is a private IPv4 address?
- 8.8.8.8
- 172.20.5.9
- 172.32.0.1
- 200.100.50.25
Answer: 172.20.5.9 The private range 172.16.0.0/12 covers 172.16.0.0 to 172.31.255.255, so 172.20.5.9 is inside it and 172.32.0.1 is not.
In the network 192.168.10.0/24, what is the broadcast address?
- 192.168.10.0
- 192.168.10.1
- 192.168.10.254
- 192.168.10.255
Answer: 192.168.10.255 The broadcast address has all host bits set to 1.
