Subnetting IP Addresses IP addresses identify hosts and network devices To send and receive messages on an IP network, every host must be assigned a unique 32-bit IP address IP address are displayed in dotted-decimal notation 192.168.1.1 Each of the 4 octets represents 8 bits IP addresses are hierarchical The network portion identifies the network that a host belongs to The host portion identifies an individual host on a network Network Addresses The network portion of the address, is used to represent the entire network It represents a group of IP addresses that can be used on that network The network address consists of the network field plus all 0’s in the host portion of the address 192.168.18.00000000 192.168.18.0 The Network address is not a usable host IP address Network addresses are only used by routers to decide how to get packets to their destination Host vs. Network Portion Network Number Host Number Broadcast Address A Broadcast Address is the address used to send messages to every host on the same network A Broadcast Address consists of the Network address, plus all 1’s in the host field The Broadcast address is NOT a USABLE host address and can not be assigned to a host Broadcast Addresses Network Address 120.0.0.0 170.50.0.0. 192.168.10 Broadcast Address 120.255.255.255 170.5.255.255 192.168.10.255 Usable Host Addresses As we just saw, the Network address and the Broadcast address are NOT usable host addresses A usable host IP address is an IP address that: Is not a Network Address (all 0’s in host field) Is not a Broadcast Address (all 1’s in host field) Is not a reserved Address (127 addresses) Is a Class A, B or C address Only a usable host IP address can be assigned to a host device Determining Usable Host Addresses Network 10.0.0.0 172.16.0.0 192.168.1.0 Usable Hosts 10.0.0.1 – 10.255.255.254 172.16.0.1-172.16.255.254 192.168.1.1-192.168.1.254 Broadcast 10.255.255.255 172.16.255.255 192.168.1.255 Available Host Addresses The number of available host addresses on a network can be calculated with the formula: 2 ^ host bits – 2 Network type 255.0.0.0 2 ^ 24 -2 = 16, 277, 214 255.255.0.0 2 ^ 16- 2 = 65, 534 255.255.255.0 2^8–2= 254 The reason we always subtract 2 from the total host addresses to determine the available host addresses, is because the network address and broadcast address are NOT usable host address Therefore, every network has 2 addresses that can not be assigned to hosts, the very 1st address (all 0’s in the host portion) and the very last address (all 1’s in the host portion) Available Hosts IP Address Classes To create more possible network designations, the 32-bit address space was organized into five classes. Class A, B, and C: Commercial networks Class D and E: multicast and experimental The class of a network is indicated by the values of the first few bits of the IP address, called the high-order bits. Commercial IP Address Classes Class C addresses are usually assigned to small networks N.N.N.H Class B addresses are typically used for medium-sized networks Use 3 octets for the network and 1 for the hosts The default subnet mask is 24 bits: 255.255.255.0 2, 097, 150 (2 ^ 21 – 2) possible networks 254 (2 ^ 8 – 2) available host addresses per network Use 2 octets for the network and 2 for the hosts N.N.H.H The default subnet mask is 16 bits: 255.255.0.0 16, 382 (2 ^ 14 – 2) possible networks 65, 534 (2 ^ 16 – 2) available host addresses per network Class A addresses are typically assigned to large organizations. Use 1 octet for the network and 3 for the hosts N.H.H.H The default subnet mask is 8 bits: 255.0.0.0 126 (2 ^ 7 – 2) possible networks 16, 777, 214 (2 ^ 24 – 2) available host addresses per network Class A The first bit is always 0 Addresses start with 0 to 126 Class B First two bits are always 1 and 0 Addresses start with 128 to 191 Class C First three bits are always 1, 1 and 0 Addresses start with 192 to 223 The value of the 1st Octet The class of an address can be determined by the value of the first octet Each Class of IP Address can only begin with a certain value Also notice, that there is a leading bit pattern that never changes for each class of addresses Class Class A Class B Class C Class D Class E Decimal Value of 1st Octet 1 - 126 128 – 191 192 – 223 224 – 239 240 – 255 Leading Bit value 0 10 110 1110 1111 1 to 126 Private Network Addresses Private Network Addresses The Loopback Address There are also private addresses that can be used for the diagnostic testing of devices. This type of private address is known as a loopback address. The class A, 127.0.0.0 network address, is reserved for loopback testing. The loopback IP address, 127.0.0.1 is used to test a NIC card to verify that it is sending and receiving signals. Subnet Masks A subnet mask is a 32 bit address which tells devices which part of the IP address is network and which part is host Let routers & hosts figure out which network or subnet an IP address belongs to Subnet Masks contain: all 1’s in the network field all 0’s in the host field Example Subnet Masks: 255.255.255.0 255.255.0.0 255.255.255.128 255.254.0.0 Subnet Mask Formats Subnet Masks can be written in 2 different formats: 1. Dotted Decimal format 2. 192.168.1.1 255.255.255.0 Bit-Mask Format 192.168.1.1 /24 This indicates that there are 24 bits ( 24 1’s) in the network and subnetwork portion of the address (255.255.255.0) Default Subnet Masks A default Subnet Mask is used when a network has NOT been subnetted Default Subnet Masks Class /8 B: 255.255.0.0 OR /16 11111111. 11111111.00000000.00000000 16 bits for network, 16 bits for host Class OR 11111111.00000000.00000000.00000000 8 bits for network, 24 bits for host Class A: 255.0.0.0 C: 255.255.255.0 OR 11111111.11111111.1111111.00000000 24 bits for network, 8 bits for host /24 Subnettting Subnetting… Is dividing a network address into smaller divisions, or subnets It allows you to divide a Class A, B or C network address into smaller subnetworks, with their own network addresses Each subnet acts like its own LAN and is connected to its own router interface Class C Network: 192.168.1.0 Addresses Available: Goal: Need 4 separate network addresses for 4 company LANs Solution: 192.168.1.0 - 192.168.1.255 (256 total) 192.168.1.1 - 192.168.1.254 are usable (254 usable) Subnet the Network Address How? 256 Addresses to work with 256 / 4 Subnets needed = 64 Addresses per Subnet Subnet 1 0 to 63 Subnet 2 64 to 127 Subnet 3 Subnet 4 129 to 191 192 to 255 Sample Subnetting Scheme Network Address Assigned: Subnets Created: Why Subnet a Network? 1. Provides better organization of Large Networks 2. Gives local administrators more control over their local networks 3. more efficient assignment of addresses breaks a network into smaller sections, which act like separate networks, without applying for additional Network addresses adds security between networks Reduces the size of the broadcast domain Helps minimize traffic loads by restricting broadcast traffic to smaller area Classful Subnetting Routers see each network as a Single network with a single network number. This keeps routing tables small Each network is identified to routers by its network number Ex. Given a local IP address of 192.168.10.14, the world outside your LAN sees only the advertised major network number of 192.168.10.0. Only internal routers (within your organization) use the Subnet Addresses to route between your local networks These routers use the subnet addresses to recognize different subnets within your whole network – all other routers ignore it! Subnet Address A subnet address is the address that identifies a subnet (similar to a network address) It contains: All 1’s in the network and Subnet Fields All 0’s in the Host fields Subnet addresses are created by borrowing bits from the Host field of a network address and making them part of the network Field All Hosts on a Subnetwork share a common subnetwork address- they are all on the same network or subnet Creating Subnets To create Subnets: Bits are Borrowed from the Host Field and made part of the network field This Creates a Subnet Field in the IP address Network Network S Network S H H Host H H H H •2 Bits are borrowed from the Host Field to make a Subnet Field, which becomes part of the Subnet Address Custom Subnet Masks When a network has been subnetted, it no longer uses the Default Subnet Mask A subnetted network must use a Custom Subnet Mask, which tells the router how many bits have been borrowed from the host portion of the address The router must use a modified or custom subnet mask to distinguish the subnets from each other The Custom Subnet Mask is created by borrowing bits from the host portion of the default subnet mask, and changing them from 0’s to 1’s Create a Custom Subnet Mask Example: A Class A subnet mask, with 2 bits borrowed: Default Mask = 255.0.0.0 2 bits borrowed = 255.11000000.0.0 Custom Subnet Mask = 255.192.0.0 Example: A class B subnet mask with 3 bits borrowed Default Mask = 255.255.0.0 2 bits borrowed = 255.255.11100000.0 Custom Subnet Mask = 255.255.224.0 Example: A class C subnet mask with 4 bits borrowed: Default Mask = 255.255.255.0 2 bits borrowed = 255.255.255.1111 Custom Subnet Mask = 255.255.255.240 Subnet Mask Bit Patterns Recognizing Bit Patterns: 10000000 = 128 11000000 = 192 11100000 = 224 11110000 = 240 11111000 = 248 11111100 = 252 11111110 = 254 11111111 = 255 How many bits to borrow? So how do you know how many bits to borrow to Subnet and to create the Custom Subnet Mask? How many bits you borrow depends on How MANY SUBNETS you need to create! Use these Formulas: Total subnets created = 2 x (x = # of bits borrowed) Usable subnets created = 2 x -2 (2 less than the total subnets) Subnetting Rules A Minimum of 2 bits must be borrowed A Minimum of 2 bits must be left over You can’t use the 1st subnet created because it contains the network address for the entire network You can’t use the last subnet created because it contains the broadcast address for the entire network Number of Subnets Created S S H H H H H H 2 Bits Borrowed= 22 = 4 Subnets, 2 usable S S S H H H H H 3 Bits Borrowed = 23 = 8 Subnets, 6 usable S S S S H H H H 4 Bits Borrowed = 24 = 16 Subnets, 14 usable Number of Subnets Created S S S S S H H H 5 Bits Borrowed = 25 = 32 Subnets, 30 usable S S S S S S H H 6 Bits Borrowed = 26 = 64 Subnets, 62 usable How Many Host Addresses per Subnet? Often it is very important to know not only how MANY SUBNETS will be created, but also how MANY HOST ADDRESSES will be available to each subnet How many host addresses will be available on each subnet is determine by how many bits are left in the host field of the address Use these formulas to determine how many host addresses are available to each subnet: Total host addresses per subnet = 2 y y = the number of bits left over in the host portion of the address (bits not borrowed) Usable host addresses per subnet = 2 y -2 2 less than the total How Many Host Addresses per Subnet? Network S Network S H Network H H Host H H H 6 Bits are left in the Host field of the address 2 Bits borrowed = 2 usable Subnets Host Addresses = 26 (64) per subnet Usable Addresses = 62 per subnet What about the other 2 Addresses? Why is the usable number of host addresses 2 less than the total number of addresses available? Each subnetwork has its own Subnetwork Address and Broadcast Address Both of these addresses are Reserved and cannot be used! The 1st IP address in each subnet becomes the Subnetwork Address The Last IP address in each subnet becomes the Broadcast Address Thus 2 addresses in each subnet cannot be used as host addresses The Trade-Off An unfortunate by-product of creating subnetworks is that the reserved network and broadcast numbers can not be used in each subnetwork. Every Subnet created creates 2 more unusable addresses in the network. Formulas to Remember! # Total Subnets Created = 2# Bits Borrowed # Usable Subnets Created = 2# Bits Borrowed - 2 # Total Hosts/Subnet = 2# Host Bits Remaining # Usable Hosts/Subnet = 2# Host Bits Remaining - 2 Custom Subnet Mask Problem The network 192.56.32.0 needs to be divided into 2 usable subnets, what is the custom subnet mask? • What class is the address? C • What is the default subnet mask? 255.255.255.0 • We need 2 usable subnets – how many bits do we need to borrow? 2 • What is the Custom subnet mask? 255.255.255.192 • 8 bits are in the host portion of address (00000000) • We need to borrow 2 bits from the left side of the host portion of the default subnet mask to create our subnet mask NNNNNNNN.NNNNNNNN.NNNNNNNN.SShhhhhh 11111111. 11111111. 11111111. 11000000 Custom Subnet Mask Problems The network 177.56.0.0 needs 3 usable subnetworks, what would it’s custom subnet mask be? What class is this address B What is the default subnet mask? 255.255.0.0 How many bits need to be borrowed? 3 (8 total, 6 usable) What is the custom subnet mask? 255.255.224.0 11111111.11111111.11100000.00000000 How many bits have been borrowed to for the address 205.10.7.16, with mask 255.255.255.240? How many usable subnets are there? What class is this address? C What is the default subnet mask? 255.255.255.0 How many bits were borrowed to make this mask? 4 How many usable subnets will that create? 14 Subnetting When we subnet a network, these are the things that must be determined: 1. 2. Custom Subnet Mask Subnet Address for each Subnet 3. Broadcast Address for each Subnet 4. The address used to send messages to all hosts in the subnet The last address in each subnet range Contains all 1’s in the host portion of the Subnet Address Usable Host addresses for each subnet The address that identifies the entire subnet – only used by routers (like a network address) Contain’s all 1’s in the network/subnet portion of the address and all 0’s in the host portion of the address The 1st address in each Subnet range All the addresses in each subnet that can be assigned to hosts We now know how to create the Custom Subnet Mask, but how do we determine the Subnet Information? Subnetting These are the steps we use to Subnet: 1. 2. 3. 4. 5. 6. 7. Determine what class the Network address is Determine the Default Subnet Mask Determine How many bits need to be borrowed to create the needed # of subnets Create the Custom Subnet Mask Determine the Subnet Addresses Determine the Broadcast Address for each subnet Determine the usable host addresses for each subnet Subnetting Problem The network 192.168.10.0 needs 6 usable subnets 1. 2. 3. Find the subnetwork address for each subnet Find the ranges usable host IP addresses for each subnet Find the broadcast address for each subnet What is the Class? C What is the Default Subnet Mask? 255.255.255.0 How many bits need to be borrowed? •Need 6 usable subnets. •3 bits = 6 usable subnets 4. What is the custom Subnet Mask? 11111111.11111111.11111111.11100000 = 255.255.255. 224 Subnetting Problem 5. Determine the Subnet Addresses • Use binary counting to begin converting the 0’s in the subnet portion to 1’s (starting from the last bit borrowed) 192.168.10.SSSHHHHH 192.168.10.000|00000 – 192.168.10.0 192.168.10.001|00000 – 192.168.10.32 – 192.168.10.010|00000 –192.168.10.64 – 192.168.10.011|00000 – 192.168.10.96 – 192.168.10.100|00000 – 192.168.10.128 – 192.168.10.101|00000 – 192.168.10.160– 192.168.10.110|00000 – 192.168.10.192– 192.168.10.111|00000 – 192.168.10.224 – 1st 2nd 3rd 4th 5th 6th 7th 8th (not usable) (1st usable) (2nd usable) (3rd usable) (4th usable) (5th usable) (6th usable) (not usable) Subnetting Problem 6. 7. Determine the Broadcast Address for each subnet Determine the usable host addresses for each subnet Usable Subnet Subnet Address Usable Hosts Broadcast Address Class B Subnetting The network 177.56.45.13 needs 7 usable subnetworks – What is the Subnetwork Address, Broadcast Address and Host Range for the 3rd subnet What class is this address? B 2. What is the default subnet mask? 255.255.0.0 3. How many bits need to be borrowed to get 4 4 bits usable subnets? 1. 23= 6 usable subnets 4. What is the custom subnet mask? 255.255.11110000.0 255.255.240.0 5. Determine Subnet Addresses Original Network: 177.56.hhhhhhhh.hhhhhhhh Subnetted Network: 177.56.SSSShhhh.hhhhhhhh 177.56.0000|0000.0 – 1st subnet, not usable 177.56.0001|0000.0– 177.56.16.0 – 2nd subnet, 1st usable 177.56.0010|0000.0 – 177.56.32.0 – 3rd subnet, 2nd usable 177.56.0011|0000.0 – 177.96.48.0 – 4th subnet, 3rd usable 177.56.0100|0000.0 – 177.56.64.0 – 5th subnet, 4th usable 177.56.0101|0000.0 – 177.56.80.0 – 6th subnet, 5th usable 177.56.0110|0000.0 – 177.56.96.0 – 7th subnet, 6th usable 177.56.0111|0000.0 – 177.56.112.0 – 8th subnet, 7th usable ========================================= 177.56.1111|0000.0 – 177.56.240.0- last subnet, not usable NOTE: Do you see a pattern above? The place value of the last subnetted bit is also the increment by which the subnetwork numbers will increase!!!! Subnetting Shortcut The value of the Subnet addresses increases by the value of the LAST BIT BORROWED The place value of the last subnetted bit is also the increment by which the subnetwork numbers will increase!!!! Ex. Subnet Mask 255.255.255.240 Borrow 4 bits: SSSS|hhhh •The place value of the last bit borrowed = 16 •Subnetwork numbers = .0, .16, .32, .48, .64, .80, etc. Subnetting Shortcuts If you borrow For Class A, B and C 2 bits 11000000 3 bits 11100000 4 bits 11110000 5 bits 11111000 6 bits 11111100 For Class A and B only 7 bits 11111110 8 bits 11111111 Subnets increase by Ex: 64 32 16 8 4 192.168.1.64 172.16.32.0 10.16.0.0 192.168.1.8 120.4.0.0 2 1 150.1.2.0 90.1.0.0 Class B Subnetting Determine the Broadcast Address for the firstst 6 subnets 7. Determine the usable host addresses the first 6 subnets 6. Subnet Subnet Address Host Addresses Broadcast Address 1st 177.56.16.0 177.56.16.1 - 177.56.31.254 177.56.31.255 2nd 177.56.32.0 177.56.32.1 – 177.56.47.254 177.56.47.255 3rd 177.56.48.0 177.56.48.1 -177.56.63.254 177.56.63.255 4th 177.56.64.0 177.56.64.1 -177.56.79.254 177.56.79.255 5th 177.56.80.0 177.56.80.1-177.56.95.254 177.56.95.255 6th 177.56.96.0 177.56.96.1- 177.56.111.254 177.56.111.255 Find info for the 2nd usable subnet Subnetwork Address: Broadcast Address: 177.56.32.0 177.56.47.255 NOTE: The broadcast address is the very last address in this subnet’s range. This is a Class B address which means we must consider the last 2 octets Host Address Range: 177.56.32.1 – 177.56.47.254 NOTE: This is a Class B address which means we must consider the last 2 octets Boolean AND • ANDing is used by devices to determine which Subnet an address belongs to • Devices AND IP addresses and their subnet mask, to determine the subnet address ANDing = 10101100 00010000 = 172 16 00000010 00000000 2 this host is on the subnetwork 172.16.2.0 0 Reverse Subnetting You can also use Reverse Subnetting to determine what subnet a host address belongs to IP Host Address: 192.168.10.70 Default Subnet Mask: 255.255.255.224 Class : C Default Subnet Mask 255.255.255.0 How many Bits have been borrowed (subnetted): 3 By what increment do the subnets increase? By 32 What is the subnet address? 192.168.10.64