Networking Fundamentals · Topic 3 of 5

IP Addressing, IPv4, IPv6 and Binary

Learn IPv4 addresses and subnet masks, prefix length, private ranges, IPv6 format and address types, and decimal to binary conversion for JN0-106.

  • 5 min
In a nutshell
  • Bit values: 128, 64, 32, 16, 8, 4, 2, 1.
  • Usable hosts = 2 to the power of host bits, minus 2; /30 gives 2 hosts.
  • Private IPv4: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.

What it is

A Layer 3 address identifies an interface across networks, not just on one segment. It has two parts: the network (prefix) part that routers use to forward, and the host part that identifies the interface inside that network.

The subnet mask or prefix length says where the network part ends. IPv4 addresses are 32 bits and IPv6 addresses are 128 bits. Because masks are binary, you need fast decimal to binary conversion to work with them.

IP address192.168.10.37AND with maskMask255.255.255.0Network192.168.10.0/24

How it works

Decimal to binary conversion

Each IPv4 octet is 8 bits. Every bit has a fixed value.

Bit1st2nd3rd4th5th6th7th8th
Value1286432168421

To convert decimal to binary, subtract the largest value that fits, write a 1, and move on; write a 0 where it does not fit. Example: 172 = 128 + 32 + 8 + 4, so 172 is 10101100. To convert back, add the values of the 1 bits: 11000000 is 128 + 64 = 192.

Subnet masks and prefix length

A mask is a run of 1 bits (network) followed by 0 bits (host). The prefix length counts the 1 bits.

PrefixMaskHosts per subnet
/8255.0.0.016,777,214
/16255.255.0.065,534
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522
/31255.255.255.2542, point to point only
/32255.255.255.2551, a host route such as a loopback

Usable hosts are 2 to the power of host bits, minus 2. The first address is the network address and the last is the broadcast address. Junos OS writes addresses with the prefix length:

user@router# set interfaces ge-0/0/0 unit 0 family inet address 192.168.10.1/24

IPv4 address classes and special ranges

Classes are no longer used for routing, but the exam still expects you to recognize them.

ClassFirst octetDefault mask
A1 to 126/8
B128 to 191/16
C192 to 223/24
D (multicast)224 to 239None
E (reserved)240 to 255None
RangeUse
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private addresses (RFC 1918), not routed on the internet
127.0.0.0/8Loopback
169.254.0.0/16Link-local, used when no address is assigned
0.0.0.0/0Default route

IPv6 addresses

An IPv6 address is 128 bits, written as eight groups of four hexadecimal digits separated by colons.

Two rules shorten it:

  1. Drop leading zeros in any group: 0db8 becomes db8.
  2. Replace one run of all zero groups with ::, but only once per address.

So 2001:0db8:0000:0000:0000:0000:0000:0001 becomes 2001:db8::1.

TypePrefixNotes
Global unicast2000::/3Routable on the internet
Unique localfc00::/7Private use, similar to RFC 1918
Link-localfe80::/10Every IPv6 interface has one; not routed
Multicastff00::/8Replaces broadcast
Loopback::1/128The local host
Unspecified::/128No address yet

A LAN subnet is normally a /64, leaving 64 bits for the interface ID. IPv6 has no broadcast; it uses multicast instead.

user@router# set interfaces ge-0/0/0 unit 0 family inet6 address 2001:db8:1::1/64
IPv6 address128 bitsPrefixfirst 64 bitsInterface IDlast 64 bits

IPv4 and IPv6 compared

IPv4IPv6
Length32 bits128 bits
NotationDotted decimalHexadecimal with colons
BroadcastYesNo, multicast instead
Address resolutionARPNeighbor discovery (ICMPv6)
Junos familyfamily inetfamily inet6
Main routing tableinet.0inet6.0
Exam tip

The Junos protocol family names matter. IPv4 is family inet and its table is inet.0; IPv6 is family inet6 and its table is inet6.0.

Common mistakes

Counting the network and broadcast addresses as hosts. A /24 has 256 addresses but only 254 usable hosts.

Using :: twice. An address such as 2001::1::5 is invalid because the reader cannot tell how many zero groups each :: replaces.

Calling 127 a Class A network address for hosts. 127.0.0.0/8 is reserved for loopback, which is why Class A ends at 126.

Watch out

Do not mix up the IPv6 link-local prefix fe80::/10 with the unique local prefix fc00::/7. Link-local is never routed; unique local can be routed inside an organization.

What to remember for the exam

  • Bit values: 128, 64, 32, 16, 8, 4, 2, 1.
  • Usable hosts = 2 to the power of host bits, minus 2; /30 gives 2 hosts.
  • Private IPv4: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
  • IPv6 is 128 bits; :: can appear only once; leading zeros may be dropped.
  • Link-local fe80::/10, global unicast 2000::/3, multicast ff00::/8, loopback ::1.
  • IPv6 has no broadcast; LAN subnets are /64.
  • Junos: family inet and inet.0 for IPv4, family inet6 and inet6.0 for IPv6.

Check yourself

  • What is 11100000 in decimal, and which prefix length gives that last mask octet?

    224, which is 128 + 64 + 32; it is the last octet of a /27 mask, 255.255.255.224.

  • How many times can the double colon appear in one IPv6 address, and why?

    Only once, because a second one would make it impossible to tell how many zero groups each replaces.

  • How many usable hosts does a /28 subnet have?

    14, because 4 host bits give 16 addresses minus the network and broadcast addresses.

Topic 3 of 5 in Networking Fundamentals

Test yourself on Networking Fundamentals

The full Juniper JNCIA-Junos JN0-106 question bank has 1,155 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.