githubEdit

4IPv4 Addressing

This is based on the Layer 3 of the OSI model, where routers operate.

Routing

The broadcast of frames to end devices is limited to the local network, it does not cross the router and cannot go to another end device.

IPv4

  • Source IP Address & Destination IP Address

    • These fields are both 32-bits (4 bytes) in length, as you can see they stretch from 0 to 31 in this chart.

circle-info

192.169.1.254 - an IPv4 Address

  • An IPv4 address is 32 bits long, so each of these four groups of numbers represents 8 bits. 192 represents 8 bits, 168 - 8 bits, 1 - 8 bits, 254 - 8 bits.

Decimal
Binary

192

11000000

168

10101000

1

0000001

254

11111110

These are pretty hard to understand for humans, that is why IP addresses are written using the dotted decimal, because there are four decimal numbers, 192, 168, 1, 254, separated by dots.

Network, host portion

circle-info

192.168.1.254/24

That /24 is used to identify which part of the IP address represents the network and which represents the end host. Since the IP address upside is 32 bits, it means that the first 24 bits of this IP address represent the network portion of the address, and the remaining 8 bits represent the end host portion.

IPv4 Address Classes

Class
First octet
First octet numeric range
Prefix length

A

0xxxxxxx

0-127

/8

B

10xxxxxx

128-191

/16

C

110xxxxx

192-223

/24

D

1110xxxx

224-239

E

1111xxxx

240-255

  • Addresses in class D are reserved for 'multicast' addresses.

  • Class E addresses are reserved for experimental uses.

  • The end of the class A range is usually considered to be 126, NOT 127, and that is because of loopback addresses.

Class
Leading bits
Size of network number bit field
Size of rest bit field
Number of networks
Addresses per network

Class A

0

8

24

128 (2^7)

16,777,216 (2^24)

Class B

10

16

16

16,384 (2^14)

65,536 (2^16)

Class C

110

24

8

2,097,152 (2^21)

256 (2^8)

  • The first address in each network is the network address, it cannot be assigned to hosts.

  • The last address of the network is the broadcast address, the Layer 3 address used when you want to send traffic to all hosts, and it cannot be assigned to hosts. So the host count is two less.

Loopback Addresses

  • Address range: 127.0.0.0 - 127.255.255.255

  • These addresses are used to test the 'network stack' (OSI, TCP/IP) on the local device.

circle-info

Try to ping any IP addresses from that range. The PC responds with the pings

Netmask

A netmask is written in dotted decimal like an IP address, where the network portion is all 1s and the host portion is all 0s. For example, the network mask of a class A address is 255.0.0.0. The network mask of class B is 255.255.0.0 and for the class C is 255.255.255.0.

Class
CIDR Notation
Subnet Mask
Binary Representation

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)

Network Address

  • If the host portion of the address is all 0's, it means it is the network address, the identifier of the network itself.

  • The network address CANNOT be assigned to a host.

Broadcast Address

  • The LAST address in a network, with a host portion of all 1's, is the broadcast address for the network.

  • Like the network address, the broadcast address CANNOT be assigned to a host.

Maximum hosts per network

circle-info

192.168.1.0/24

  • This is a Class C network 192.168.1.0/24. Because it is class C, it uses a /24 prefix length, and therefore the last octet, the last 8 bits, are the host portions.

  • That means that the host portion can be 0 to 255. So 0, to 255 gives us a total of 256 addresses, which is 282^8, because there are 8 bits. But, remember those two special address, if the host portion is all 0, it represents the network address (network id), and if the host portion is all 1, it represents the broadcast address.

  • Those 2 addresses cannot be assigned to a host, so actually the maximum hosts per network is 2822^8 - 2, which is 254 for a class C network.

circle-info

172.16.0.0/16

  • This is a Class B network 172.16.0.0/16. It goes from 172.16.0.0/16 through 172.16.255.255/16. The host portion is 16 bites, giving us 65,536 possible addresses. There are two addresses that cannot be hosts, the network address and the broadcast address, so actually there are 65,534 maximum hosts per class B network.

This goes to same to the other classes. The formula for this is:

2n22^n - 2

First / Last Usable Address

Commands

  • You need to be in privileged exec mode.

  • The status command is linked to the Layer 1 status of the interface.

  • administratively down: Interface has been disabled with the 'shutdown' command.

  • This is the default Status of Cisco router interfaces.

  • Cisco switch interfaces are NOT administratively down by default.

  • The protocol is the Layer 2 status. Because the interfaces are down at Layer 1, Layer 2 cannot operate, so all of these interfaces are down at Layer 2.

IPv4 Address Configuration

  • To configure the interface itself, I have to enter interface config mode. So I use the command 'interface' followed by the name of the interface.

  • By doing this you can set the IP address.

  • The no shutdown command is used to enable the interface.

Last updated