Every device on an IP network needs an address so that others can send data to it. IPv4 is the version you will meet most often.
Four numbers
An IPv4 address is 32 bits long. We write it as four numbers separated by dots, such as 192.168.1.50. Each number is 8 bits, called an octet, so it ranges from 0 to 255. In total there are about 4.3 billion possible addresses.
In binary, each bit in an octet has a value: 128, 64, 32, 16, 8, 4, 2, 1. For example, 192 is 128 + 64, written 11000000.
Network part and host part
An address has two parts. The first bits say which network it is on, and the rest identify the host within that network. A prefix length such as /24 says how many bits belong to the network. With 192.168.1.50/24, the network is 192.168.1.0 and the host part is 50.
Special ranges
These private ranges (RFC 1918) can be reused inside any home or company and are not routed on the public internet:
10.0.0.0/8172.16.0.0/12(172.16 to 172.31)192.168.0.0/16
Others to know:
127.0.0.0/8is loopback: your own machine, usually127.0.0.1.169.254.0.0/16is link-local. A host may pick one when no DHCP server answers.
Finding your address
$ ip -4 address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 192.168.1.50/24 brd 192.168.1.255 scope global dynamic eth0
valid_lft 85964sec preferred_lft 85964secThe line starting with inet shows the address and prefix. brd is the broadcast address, and dynamic means the address has a limited lifetime, typically because it came from DHCP. Your interface may have another name, and the details vary. Run ip -4 address with nothing after it to list them all.
The address your home machine has is usually private. The internet sees a different, public address belonging to your router.
The IPv4 subnetting guide goes further.
Try it
Run ip -4 address. For each address, decide whether it is loopback, private, link-local or public. Then convert the last octet of your main address to binary by hand and check it with python3 -c 'print(format(50, "08b"))', replacing 50 with your number.
Check your understanding
IPv4 Addresses
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.