--- id: 1777840095-WYOD aliases: - Subnetting (Part 1) tags: - CCNA --- # Subnetting (Part 1) ## IPV4 Address Classes | Class |First octet | numeric range | Prefix Length | | ----- | ---------- | ------------- |------------- | | A |0xxxxxxxx | 0-127 | /8 | | B |10xxxxxxx | 128-191 | /16 | | C |110xxxxxx | 192-223 | /24 | | D |1110xxxxx | 224-239 | | | E |1111xxxxx | 240-255 | | ### Maximum Hosts per Network Host portion all 0s = Network address (network ID) Host portion all 1s = broadcast address 192.168.1.0/24 -> 192.168.1.255/24 Host portion = 8 bits = 2^8 = 256 Maximum hosts per network = 2^8-2 = 254 172.16.0.0/16 -> 172.16.255.255/16 Host portion = 16 bits = 2^16 = 65,536 Maximum hosts per network = 2^16 -2 = 254 10.0.0.0/8 -> 10.255.255.255/8 Host portion = 24 bits = 2^24 = 16,777,216 Maximum hosts per network = 2^24 -2 = 16,777,214 ### How IP addresses are distrubuted - The [[IANA]] (Internet Assigned Numbers Authority) assigns IPV4 addresses/networks to companies based on their size - For example, a very large company might receive a class A or class B network, while a small company might receive a ckass C network. - However, this led to many wasted IP addresses. #### Example 1 +----+ +----+ | R1 |<----->| R2 | +----+ ^ +----+ Point to Point network - 256 addresses - 1 network address (203.0.113.0) - 1 broadcast address (203.0.113.255) - 1 R1 address (203.0.113.1) - 1 R2 address (203.0.113.2) - **252 addresses Wasted** #### Example 2 Company X needs IP addressing for 5000 end hosts. - A class C network does not provide enough addresses, so a class B network must be assigned - This will result in about 6000 addresses being wasted. ## CIDR - When the internet was first created, the creators did not predict that the internet would become as large as it is today - This resulted in wasted address space like the examples. - The [[IETF]] introduced [[CIDR]] in 1993 to replace the 'classful' addressing system. - With CIDR, the requirement of ... - Class A = /8 - Class B = /16 - Class C = /24 were removed - This allowed larger networks to be split into smaller networks, allowing greater efficiency - These smaller networks are called 'subnetworks' or [[subnetting]] +----+ +----+ | R1 |<----->| R2 | +----+ ^ +----+ 203.0.113.0/24 Network address 11001011.00000000.01110001.*00000000* 203 . 0 . 113 . 0 Subnet Mask 11111111.11111111.11111111.*00000000* 255 . 255 . 255 . 0 2^8 - 2 = 254 usable addresses. How many usable addreses are there in each network? #### CIDR /25 **203.0.113.0/25** Network address: 11001011.00000000.01110001.0*0000000* 203 . 0 . 113 . 0 Subnet Mask 11111111.11111111.11111111.1*0000000* 255 . 255 . 255 . 128 *2^7 - 2 = 126 usable addresses* #### CIDR /26 **203.0.113.0/26** Network address 11001011.00000000.01110001.00*000000* 203 . 0 . 113 . 0 Subnet Mask 11111111.11111111.11111111.11*000000* 255 . 255 . 255 . 192 *2^6 - 2 = 62 usable addresses* #### CIDR /27 **203.0.113.0/27** Network address 11001011.00000000.01110001.00*000000* 203 . 0 . 113 . 0 Subnet Mask 11111111.11111111.11111111.111*00000* 255 . 255 . 255 . 224 *2^5 - 2 = 30 usable addresses* #### CIDR /28 **203.0.113.0/28** Network address 11001011.00000000.01110001.00*000000* 203 . 0 . 113 . 0 Subnet Mask 11111111.11111111.11111111.1111*0000* 255 . 255 . 255 . 240 *2^4 - 2 = 14 usable addresses* #### CIDR /29 *203.0.113.0/29* Network address 11001011.00000000.01110001.00000*000* 203 . 0 . 113 . 0 Subnet Mask 11111111.11111111.11111111.11111*000* 255 . 255 . 255 . 248 *2^4 - 2 = 6 usable addresses* #### CIDR /30 **203.0.113.0/30** Network address 11001011.00000000.01110001.000000*00* 203 . 0 . 113 . 0 Subnet Mask 11111111.11111111.11111111.111111*00* 255 . 255 . 255 . 252 *2^4 - 2 = 6 usable addresses* This is the perfect CIDR for our 2 router The remaining addresses in the 20 203.0.113.0/24 address block (20 203.0.113.4 - 20 203.0.113.255) are now available to be used in other subnets! #### CIDR /31 *203.0.113.0/31* 2^1 -2= 0 usable addresses but for our point to point connection we can utilisize it no need for broadcast or network address In cisco device however you get a systeme warning ```cisco Router(config-if)# ip address 203.0.113.0 255.255.255.254 Warning use /31 mask on non point-to-pint interface cautiously ``` The remaining addresses in the 20 203.0.113.0/24 address block (20 203.0.113.2 - 203.0.113.255) are now available to be used in other network! #### CIDR /32 *203.0.113.0/32* 2^1 -2= -1 usable addresses can be used in static routes don't worry about them now ## Review - [[CIDR]] (Classless Inter-Domain Routing) - The process of subnetting