ccna-notes

IPv4 Addressing

Table of contents

IPv4 Address

Decimal and Binary

Min/Max binary octet

Binary to Decimal

Decimal to Binary

IPv4 Address Classes

Class First octet First octet numeric range
A 0xxxxxxx 0-127 (1-126)
B 10xxxxxx 128-191
C 110xxxxx 192-223
D 1110xxxx 224-239
E 1111xxxx 240-255
Class First octet First octet numeric range Prefix Length
A 0xxxxxxx 0-127 (1-126) /8
B 10xxxxxx 128-191 /16
C 110xxxxx 192-223 /24

Netmask

Class Prefix Length Netmask Binary octets
A /8 255.0.0.0 11111111 00000000 00000000 00000000
B /16 255.255.0.0 11111111 11111111 00000000 00000000
C /24 255.255.255.0 11111111 11111111 11111111 00000000

Maximum hosts per network

2^n - 2 🔥

where n = number of host bits

/24 (Class C)

192.168.1.0/24192.168.1.255/24

/16 (Class B)

172.16.0.0/16172.16.255.255/16

/8 (Class A)

10.0.0.0/810.255.255.255/8

Network address

192.168.1.0/24

Broadcast address

192.168.1.255/24

IPv4 Address Configuration

Consider the following network where the router interfaces are yet to be configured: Screenshot from Packet Tracer showing 3 LANs connected to R1 router

Show interfaces status and configured IP addresses

Router>enable
Router#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol 
GigabitEthernet0/0     unassigned      YES unset  administratively down down 
GigabitEthernet0/1     unassigned      YES unset  administratively down down 
GigabitEthernet0/2     unassigned      YES unset  administratively down down 
Vlan1                  unassigned      YES unset  administratively down down
Router#

Configure interface IP

Router#config terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface gi
Router(config)#interface gigabitEthernet 0/0
Router(config-if)#ip address 15.255.255.254 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

Router(config-if)#

We’ll do the same for the other 2 interfaces

Router(config-if)#interface gigabitEthernet 0/1
Router(config-if)#ip address 182.98.255.254 255.255.0.0
Router(config-if)#no shutdown

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up

Router(config-if)#
Router(config-if)#interface gigabitEthernet 0/2
Router(config-if)#ip address 201.191.20.254 255.255.255.0
Router(config-if)#no shutdown

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up

Router(config-if)#

Now we can verify our interfaces are configured and working as expected

Router(config-if)#do show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol 
GigabitEthernet0/0     15.255.255.254  YES manual up                    up 
GigabitEthernet0/1     182.98.255.254  YES manual up                    up 
GigabitEthernet0/2     201.191.20.254  YES manual up                    up 
Vlan1                  unassigned      YES unset  administratively down down
Router(config-if)#