# IP Addressing and Subnetting Basics

> Chapter 2 of the Courseiva CISCO-DEVNET-ASSOCIATE curriculum — https://courseiva.com/learn/cisco-devnet-associate/ip-addressing-subnetting

**Official objective:** 6.2 — Describe IP addressing, subnetting, and basic routing concepts

## Introduction

How does the internet know which device in your home is asking for a cat video, and which one is sending an email? That's the core problem IP addressing and subnetting solve: they create a unique, organised addressing system so data doesn't get lost. For the Cisco DevNet Associate exam, you must understand this system because every API call, every cloud service interaction, and every network device configuration relies on getting the IP address right.

## The Apartment Building Mailroom Analogy

Ever tried to send a letter to a friend who lives in a massive apartment complex? You can't just write "Alex, Big City" on the envelope and expect it to arrive. You need the building's street address, and most importantly, the apartment number. Without that apartment number, the mail carrier has no idea which specific unit is Alex's. The building's street address is like a public IP address—it gets you to the right building on the internet. But inside that building, there are dozens of apartments, each with a unique number. Those apartment numbers are like private IP addresses—they identify the specific device (your phone, laptop, smart TV) inside your home network. 

Now, imagine you live in that building and you're expecting a package. The building management can't give every apartment its own separate street address; that would be impossible and wasteful. Instead, they have one main address (the public IP) and a mailroom. The mailroom's job is to sort packages and deliver them to the correct apartment. This is exactly what a home router does. It has one public IP address from your internet service provider (like the building's street address) and then it hands out private IP addresses (like apartment numbers) to every device in your home. When data from the internet arrives, the router looks at the port number (like a note the postman leaves saying "Apartment 3B") and forwards the data to the right device. This system, called Network Address Translation (NAT), is why you can have five devices online at once using just one public IP address.

## Core explanation

Let's start with the absolute basics. An IP address is like a street address for your computer. It's a unique number assigned to every device connected to a network—your laptop, your phone, even your smart fridge. Think of it as a digital postcode that tells data where to go. There are two main versions of IP addresses you need to know for the 200-901 exam: IPv4 and IPv6. 

IPv4 is the older system and what most of the internet still runs on. It's a 32-bit number, usually written as four decimal numbers separated by dots, like 192.168.1.1. Each of those four numbers (called octets) can be from 0 to 255. So the full range of possible IPv4 addresses is about 4.3 billion. That sounds like a lot, but it's not enough for every device in the world. This is why we have subnetting and private IP addresses. 

IPv6 was created to solve the address shortage. It's a 128-bit number, written in hexadecimal (using letters and numbers) like 2001:0db8:85a3:0000:0000:8a2e:0370:7334. With IPv6, we have so many addresses we could assign one to every atom on the planet's surface. For the exam, know that IPv6 is the future and that you'll see it in cloud networking and modern infrastructure.

Now, what is subnetting? A subnet (short for 'sub-network') is a logical division of an IP network. Imagine you have a big office building with one main address, but you want to split it into separate departments: sales, engineering, and HR. Subnetting is how you carve that big network into smaller, manageable pieces. Each piece gets its own range of IP addresses, and devices on different subnets need a router to talk to each other. 

Why does this matter? Subnetting improves performance (less traffic jams), security (you can isolate sensitive systems), and management (you can apply different rules to different groups). For your exam, you need to understand the concept of a 'subnet mask'. A subnet mask is a number that tells you which part of an IP address is the 'network' part and which part is the 'host' (device) part. For example, with 192.168.1.0/24, the /24 is shorthand for a subnet mask of 255.255.255.0. This means the first 24 bits are the network, leaving only the last 8 bits for host devices. So you can have 254 usable addresses in that subnet (the first and last addresses are reserved for the network itself and the broadcast). 


Now, let's talk about the types of IP addresses you'll encounter:
- Public IP addresses: These are unique across the entire internet, assigned by your Internet Service Provider (ISP). Think of it as your home's street address visible to the whole world.
- Private IP addresses: These are used within a private network (your home or office) and are NOT routable on the public internet. The standard private ranges are:
  - 10.0.0.0 to 10.255.255.255 (big networks)
  - 172.16.0.0 to 172.31.255.255 (medium networks)
  - 192.168.0.0 to 192.168.255.255 (home networks)


When your device has a private IP address and needs to go onto the internet, a router uses Network Address Translation (NAT) to rewrite the source IP address from your private one to its public one. To the internet, all devices from your home look like they are coming from the same public IP. 

Static vs Dynamic addressing: You can assign an IP address to a device manually (static), or you can use a Dynamic Host Configuration Protocol (DHCP) server to automatically assign addresses. DHCP is like a receptionist who gives every guest a temporary name badge when they arrive. For your exam, know that DHCP is the default for most home networks and cloud environments. 

Finally, let's touch on 'basic routing'. A router is a device that forwards data packets between different networks. It looks at the destination IP address of a packet, consults a routing table (a sort of map stored in the router's memory), and sends the packet along the best path. For the exam, know that routers make decisions based on IP addresses, not physical ports. This is the difference between routing (IP level) and switching (MAC address level). Understanding the default gateway is also crucial: it's the IP address of the router that a device uses to send traffic to destinations outside its own subnet.

## Real-world context

Imagine you are a junior network engineer at a medium-sized company called 'LearnIT'. The company has 200 employees across three floors of an office building. Your boss asks you to design the internal network so that the finance department (with sensitive data) is isolated from the guest Wi-Fi network. Here's what you would actually do. 

First, you would identify the network's public IP address provided by your ISP, say 203.0.113.45. That's the single visible point to the internet. Next, you would plan your internal addressing scheme. You decide to use the private 10.0.0.0/8 range because it gives you plenty of room. 

Now, subnetting is where the real work begins. You divide the 10.0.0.0 network into smaller subnets:
- 10.0.1.0/24 for the finance department (254 addresses)
- 10.0.2.0/24 for engineering
- 10.0.3.0/24 for management
- 10.0.10.0/24 for the guest Wi-Fi


Each department gets its own VLAN (Virtual Local Area Network) which is a way to create separate broadcast domains on the same physical switch. You configure the router to use access control lists (ACLs) to block traffic from the guest Wi-Fi subnet (10.0.10.0/24) to the finance subnet (10.0.1.0/24). This means visitors can browse the web but cannot access sensitive company servers. 

When a new employee joins, they plug their laptop into the network. A DHCP server running on a Windows server automatically assigns them an IP address from the correct subnet. The employee never needs to know their IP address—they just get online. As a network engineer, you might use tools like 'ping' and 'traceroute' to verify connectivity between subnets. 

For the DevNet Associate exam, you might not be physically plugging in cables, but you will configure virtual networks in the cloud. For example, in Amazon Web Services (AWS), you create a Virtual Private Cloud (VPC) and define subnets for public-facing web servers and private databases. You assign CIDR blocks (like 10.0.1.0/24) and route tables. The exact same subnetting principles apply. 

In summary, an IT professional uses IP addressing and subnetting every day to design networks, troubleshoot connectivity, configure firewalls, and secure resources. Without this foundational knowledge, you cannot build a reliable or secure IT system.

## Exam focus

The Cisco DevNet Associate 200-901 exam tests your understanding of IP addressing and subnetting under objective 6.2, but it does not ask you to perform complex binary math or calculate subnets manually. Instead, the exam focuses on conceptual understanding and practical application in a DevOps and automation context. 

Here are the specific topics you must master:

- The difference between IPv4 and IPv6: You need to know why IPv6 exists (address exhaustion) and be able to recognise an IPv6 address format. A typical question might show you a mixing of colon and dot notation and ask you to identify which is valid.
- Public vs private IP addresses: You must memorise the three private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). The exam loves to test if you can spot a private address in a list of addresses.
- Subnet masks and CIDR notation: Understand that /24 equals 255.255.255.0. You will not be asked to calculate subnets, but you will be asked to interpret a given CIDR block, like '10.0.0.0/16', and identify the number of possible hosts.
- Default gateway: Know that the default gateway is the IP address of the router on your network. A typical trap sets the device's default gateway to an IP address at the network address (e.g., 10.0.1.0) or a broadcast address (10.0.1.255), which would cause a failure.
- DHCP vs static addressing: The exam tests the trade-offs. Questions might ask: 'When would you use a static IP address?' Common correct answers: for servers, routers, or printers that need a consistent address.
- NAT (Network Address Translation): Understand the basic concept: a router translates private IPs to a public IP. But the exam also tests the difference between static NAT (one-to-one mapping) and dynamic NAT (pool of public IPs).
- The role of DNS: While not strictly part of subnetting, the exam often melds DNS with IP addressing. Know that DNS resolves a domain name (like www.cisco.com) to an IP address.


Common traps the exam sets:
- They give you an IP address and a subnet mask, then ask you to identify the 'network address'. The network address always has all host bits set to 0. For example, with 192.168.1.5/24, the network address is 192.168.1.0.
- They ask you which address is the 'broadcast address'. The broadcast address is the last address in the subnet (all host bits set to 1). For 192.168.1.0/24, the broadcast is 192.168.1.255.
- They ask you to identify an invalid IP address. For example, a valid octet must be between 0 and 255. An address like 192.168.1.300 is invalid.


To prepare, focus on memorising the private IP ranges and the CIDR to subnet mask conversions for /16, /24, /28, and /30. Use flashcards. Practise identifying network and broadcast addresses for simple /24 subnets.

## Step by step

1. **1. Identify the network requirement** — Before assigning any IP addresses, determine how many devices need to be on the same subnet. For example, a home network might need 10 devices, while an office network might need 200. This decides the size of the subnet (CIDR block).
2. **2. Choose an IP address range** — Select a private IP range (10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16) based on the required number of hosts. For 200 devices, 10.0.0.0/24 gives 254 hosts, which is enough.
3. **3. Define the subnet mask** — A subnet mask of /24 (255.255.255.0) means the first 24 bits are the network part. This leaves 8 bits for host addresses, allowing 254 usable IPs. Write the mask in both decimal and CIDR format.
4. **4. Assign IPs to interfaces** — Give the router's interface an IP like 10.0.0.1 (often the first usable address). Assign static IPs to servers or printers. For client devices, configure a DHCP server to hand out addresses from 10.0.0.50 to 10.0.0.100.
5. **5. Configure the default gateway** — Every device on the subnet must have the router's IP (10.0.0.1) set as its default gateway. This tells the device, 'If you need to reach a device outside your subnet, send the data to this router.'
6. **6. Test connectivity** — Use the 'ping' command from a device to the gateway IP to confirm the device is correctly configured. Then try pinging an external IP (like 8.8.8.8) to verify internet access.
7. **7. Document the network** — Record the subnet, IP assignments, and DHCP scope in a network diagram or configuration file. This helps with troubleshooting and future changes, a key practice for DevOps automation.

## Comparisons

### IPv4 vs IPv6

**IPv4:**
- 32-bit address length
- Written in decimal dotted notation (e.g., 192.168.1.1)
- Approximately 4.3 billion possible addresses

**IPv6:**
- 128-bit address length
- Written in hexadecimal colon notation (e.g., 2001:db8::1)
- Approximately 340 undecillion possible addresses

### Public IP Address vs Private IP Address

**Public IP Address:**
- Unique across the entire internet
- Assigned by ISP is usually paid
- Must be unique globally

**Private IP Address:**
- Only unique within a local network
- Free to use by anyone
- Cannot be routed on the public internet

### DHCP (Dynamic) vs Static IP

**DHCP (Dynamic):**
- IP address changes periodically
- Less manual work to configure
- Good for client devices that change

**Static IP:**
- IP address never changes
- Requires manual configuration on each device
- Best for servers, routers, and printers

### Router vs Switch

**Router:**
- Operates at Layer 3 (Network)
- Uses IP addresses to forward data between networks
- Connects different subnets together

**Switch:**
- Operates at Layer 2 (Data Link)
- Uses MAC addresses to forward data within the same network
- Connects devices within the same subnet

## Diagram

_Flow diagram showing how a single public IP is connected to multiple private subnets via a router using NAT._

```mermaid
flowchart TD
    A[Internet] --> B[Public IP 203.0.113.45]
    B --> C[Router with NAT]
    C --> D[Private Subnet 10.0.1.0/24]
    C --> E[Private Subnet 10.0.2.0/24]
    D --> F[Device 1: 10.0.1.5]
    D --> G[Device 2: 10.0.1.6]
    E --> H[Server: 10.0.2.10]
```

## Common misconceptions

- **Misconception:** "My public IP address is the same as my private IP address (192.168.x.x)." **Reality:** Your public IP address is different from your private IP address. The 192.168.x.x range is reserved for internal use and is not routable on the internet. Your router assigns private IPs to devices and has its own public IP from your ISP. (People often see 192.168.1.1 in their router settings and assume that is their public address, not realising the router uses NAT to translate between private and public.)
- **Misconception:** "Subnetting is just about breaking a network into smaller pieces to save IP addresses." **Reality:** Subnetting is also about security, performance, and management. Isolating different parts of a network (like guests from employees) is a primary reason to subnet. (Beginners focus on the math of address conservation, but practical IT subnetting is more about organisation and security than just saving numbers.)
- **Misconception:** "IPv6 addresses are so long that they are impractical and I can ignore them for the exam." **Reality:** IPv6 is critical and tested on the 200-901. You must recognise the format and know its purpose. (Many beginners find IPv6 intimidating because of its length and hexadecimal notation, but the exam only tests basic recognition and purpose, not deep configuration.)
- **Misconception:** "A router and a switch both use IP addresses to forward data." **Reality:** A router uses IP addresses (Layer 3) to make forwarding decisions between different networks. A switch uses MAC addresses (Layer 2) to forward data within the same network. (The terms 'router' and 'switch' are often used interchangeably in casual conversation, but the exam requires you to know their distinct roles in the OSI model.)
- **Misconception:** "The default gateway is the same thing as a DNS server." **Reality:** A default gateway is a router that forwards traffic out of the local subnet. A DNS server resolves domain names to IP addresses. They are two separate functions. (Home routers often combine DNS and gateway functions in one device, which leads people to think they are the same concept.)

## Key takeaways

- An IPv4 address is 32 bits, written as four decimal octets (e.g., 192.168.1.1).
- Private IP ranges are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.
- A subnet mask (e.g., 255.255.255.0 or /24) defines which part of an IP address is the network and which is the host.
- The default gateway is the IP address of the router that sends traffic outside your local subnet.
- NAT (Network Address Translation) allows many private IPs to share a single public IP address.
- IPv6 uses 128-bit addresses written in hexadecimal and was created to solve IPv4 address exhaustion.
- DHCP automatically assigns IP addresses to devices, reducing manual configuration errors.

## FAQ

**What is the difference between a public and a private IP address?**

A public IP address is unique on the internet and assigned by your ISP. A private IP address is used inside a local network (like your home or office) and cannot be routed on the public internet. Devices with private IPs connect to the internet through NAT.

**What is CIDR notation and how do I read it?**

CIDR (Classless Inter-Domain Routing) notation shows an IP address followed by a slash and a number (e.g., 10.0.0.0/24). The number indicates how many bits in the subnet mask are set to 1. /24 means a subnet mask of 255.255.255.0.

**Why can't I use 192.168.1.300 as an IP address?**

Each octet in an IPv4 address must be between 0 and 255. The number 300 is outside this range, so 192.168.1.300 is an invalid IP address.

**What is the default gateway and why do I need it?**

The default gateway is the IP address of the router on your local network. It acts as the exit point when a device needs to communicate with devices outside its own subnet. Without a gateway, your device can only talk to other devices on the same local network.

**How does DHCP assign IP addresses?**

When a device connects to a network, it sends a broadcast request. A DHCP server receives the request and assigns an IP address from a predefined pool (scope). The device leases that IP for a period of time, after which it must renew the lease.

**What is the difference between a router and a switch in terms of IP addressing?**

A router uses IP addresses (Layer 3) to forward data between different networks. A switch uses MAC addresses (Layer 2) to forward data within the same network. Routers are needed to connect subnets together.

## Check your understanding

1. **Which of the following is a valid private IP address? A) 172.32.1.1 B) 192.168.0.1 C) 203.0.113.5 D) 8.8.8.8**

   Answer: B) 192.168.0.1 is a valid private IP address. The private range 192.168.0.0/16 includes this address.

2. **What does the /24 in the CIDR notation 10.0.0.0/24 represent?**

   Answer: The /24 specifies the subnet mask. It means the first 24 bits of the IP address are the network part, leaving 8 bits for host addresses. It is equivalent to 255.255.255.0.

3. **What is the primary purpose of a default gateway?**

   Answer: The default gateway is the IP address of the router on a local network. It is used to forward traffic from a device to destinations outside its own subnet.

4. **Why was IPv6 created?**

   Answer: IPv6 was created because the world was running out of available public IPv4 addresses. IPv6 provides a vastly larger address space (128-bit) to accommodate the growing number of internet-connected devices.

5. **What is the role of NAT (Network Address Translation) in a home network?**

   Answer: NAT allows a home router with a single public IP address to translate multiple private IP addresses from devices in the home to that public IP, enabling all devices to access the internet simultaneously.

---

Interactive version with quiz and diagrams: https://courseiva.com/learn/cisco-devnet-associate/ip-addressing-subnetting
