IPv4 Addressing and Basic Router Configuration
Layer 3 Overview
- Concept: Layer 3 (Network Layer) of the OSI model provides connectivity between end hosts on different networks (outside the local area network).
- Details:
- Logical Addressing: Uses IP addresses (assigned via configuration), unlike MAC addresses (burned into hardware at the factory).
- Path Selection: Routers select the best path to a destination across complex networks.
- Broadcast Domains: Routers do not forward Layer 2 broadcast frames (destination MAC
FFFF.FFFF.FFFF). Broadcasts are strictly limited to the local network.
Binary and Decimal Conversion
- Concept: IPv4 addresses are 32-bit binary numbers, typically represented in dotted decimal format for human readability.
- Details:
- An IPv4 address consists of four 8-bit groups called octets.
- Binary Place Values: 128, 64, 32, 16, 8, 4, 2, 1.
- Range per Octet: 0 (all 0s) to 255 (all 1s).
- Conversion Rules:
- Binary to Decimal: Add the place values of all bits that are
1. - Decimal to Binary: Subtract the largest possible place value from the decimal number sequentially. If it subtracts cleanly, write a
1; otherwise, write a0.
- Binary to Decimal: Add the place values of all bits that are
IPv4 Address Structure
- Concept: Every IPv4 address is divided into two parts: the Network portion and the Host portion.
- Details:
- Network Portion: Identifies the specific network. Must be identical for all devices on the same local network.
- Host Portion: Identifies the specific end device (PC, router interface) on that network. Must be unique within the network.
- Prefix Length: Denoted by a slash followed by a number (e.g.,
/24). It indicates the number of bits in the network portion.
IPv4 Address Classes
- Concept: Historically, IPv4 addresses are divided into five classes (A-E) based on the leading bits of the first octet.
- Details: Classes A, B, and C are used for unicast addressing. Class D is for multicast, and Class E is experimental.
- Important Exceptions:
- The
127.x.x.xrange is reserved for Loopback addresses (used to test the local TCP/IP stack, e.g.,127.0.0.1). Traffic sent here never leaves the device. - The
0.x.x.xrange is reserved. - Therefore, usable Class A addresses technically start at
1.x.x.xto126.x.x.x.
- The
| Class | First Octet Range | Leading Bits | Default Prefix | Default Subnet Mask | Networks | Hosts per Network |
|---|---|---|---|---|---|---|
| A | 1 - 126 | 0 |
/8 |
255.0.0.0 |
126 | 16,777,214 |
| B | 128 - 191 | 10 |
/16 |
255.255.0.0 |
16,384 | 65,534 |
| C | 192 - 223 | 110 |
/24 |
255.255.255.0 |
2,097,152 | 254 |
| D | 224 - 239 | 1110 |
N/A | N/A | N/A (Multicast) | N/A |
| E | 240 - 255 | 1111 |
N/A | N/A | N/A (Experimental) | N/A |
Things to note: The number of usable hosts per network is always 2^N - 2 (where N is the number of host bits), because the network address and broadcast address cannot be assigned to hosts.
Subnet Masks and Prefix Lengths
- Concept: A subnet mask distinguishes the network portion from the host portion using contiguous
1s for the network and contiguous0s for the host. - Details:
- Prefix Length (CIDR): Modern notation (e.g.,
/24). - Subnet Mask: Dotted decimal notation (e.g.,
255.255.255.0). - Both represent the exact same boundary.
- Prefix Length (CIDR): Modern notation (e.g.,
| Prefix Length | Binary Subnet Mask | Dotted Decimal Subnet Mask |
|---|---|---|
/8 |
11111111.00000000.00000000.00000000 |
255.0.0.0 |
/16 |
11111111.11111111.00000000.00000000 |
255.255.0.0 |
/24 |
11111111.11111111.11111111.00000000 |
255.255.255.0 |
Network and Broadcast Addresses
- Concept: Two specific addresses in every IPv4 subnet are reserved and cannot be assigned to end hosts.
- Details:
- Network Address (Network ID): The first address in the subnet. The host portion consists of all
0s. Used to identify the network itself in routing tables. - Broadcast Address: The last address in the subnet. The host portion consists of all
1s. Used to send Layer 3 packets to all hosts on the local network.- When a packet is sent to the broadcast IP, the encapsulating frame uses the broadcast MAC address (
FFFF.FFFF.FFFF).
- When a packet is sent to the broadcast IP, the encapsulating frame uses the broadcast MAC address (
- Network Address (Network ID): The first address in the subnet. The host portion consists of all
Calculating Usable Hosts and Addresses
- Concept: Formulas to determine the size and boundaries of an IPv4 subnet.
- Details:
- Maximum Usable Hosts:
2^H - 2(whereH= number of host bits). - Network Address: Host portion set to all
0s. - First Usable Address: Network Address + 1.
- Broadcast Address: Host portion set to all
1s. - Last Usable Address: Broadcast Address - 1.
- Maximum Usable Hosts:
Example Calculation for 192.168.1.0/24:
- Host bits (H): 32 - 24 = 8 bits.
- Max Usable Hosts: 2^8 - 2 = 254.
- Network Address:
192.168.1.0 - First Usable:
192.168.1.1 - Broadcast Address:
192.168.1.255 - Last Usable:
192.168.1.254
Cisco IOS Interface Configuration
- Concept: Configuring Layer 3 IP addresses on Cisco router interfaces to enable inter-VLAN or inter-network routing.
- Details:
- Router interfaces are administratively down by default (unlike switch interfaces).
- You must use the
no shutdowncommand to enable them. - IP addresses are configured using the dotted decimal subnet mask in IOS, not the slash prefix notation.
Router> enable
Router# configure terminal
Router(config)# interface gigabitethernet 0/0
Router(config-if)# description #Connected_to_SW1#
Router(config-if)# ip address 192.168.1.254 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)# exit
Things to note:
- You can use shortcuts for commands and interface names (e.g.,
int g0/0,ip add,no shut). - You can move directly from one interface configuration mode to another without returning to global configuration mode.
- The
descriptioncommand is highly recommended for documenting what the interface connects to.
Cisco IOS Verification Commands
- Concept: Commands used to verify interface status, IP configurations, and Layer 1/Layer 2 states.
- Details:
- Layer 1 Status (
statuscolumn): Physical state. Is the interface enabled? Is a cable connected? - Layer 2 Status (
protocolcolumn): Data link state. Are keepalives functioning? Is the encapsulation protocol up? - You will never see
statusasdownandprotocolasup.
- Layer 1 Status (
| Command | Purpose |
|---|---|
show ip interface brief |
Displays a summary of all interfaces, including IP address, Layer 1 status, and Layer 2 protocol state. |
show interfaces [interface] |
Displays detailed Layer 1, Layer 2, and some Layer 3 information (including MAC/BIA address) for a specific interface. |
show interfaces description |
Displays interface status alongside configured descriptions. |
Router# show ip interface brief
Router# show interfaces gigabitethernet 0/0
Router# show interfaces description
Things to note:
show ip interface briefoutput columns:- OK?: Legacy column indicating if the IP address is valid (always
YESon modern IOS). - Method: How the IP was assigned (e.g.,
manual,unset,DHCP). - Status: Layer 1 state (
up,down,administratively down). - Protocol: Layer 2 state (
up,down).
- OK?: Legacy column indicating if the IP address is valid (always
Command Summary
! Enter privileged EXEC mode
Router> enable
! Enter global configuration mode
Router# configure terminal
! Enter interface configuration mode
Router(config)# interface gigabitethernet 0/0
Router(config)# int g0/0
! Configure IP address and subnet mask
Router(config-if)# ip address <ip_address> <subnet_mask>
! Enable the interface
Router(config-if)# no shutdown
Router(config-if)# no shut
! Add a text description to the interface
Router(config-if)# description <text>
! Verify interface IP and status summary
Router# show ip interface brief
Router# sh ip int br
! Verify detailed interface information (includes MAC/BIA)
Router# show interfaces [interface_id]
! Verify interface descriptions
Router# show interfaces description