setting IP addresses copyright 2015 Robert Montante
What IP Address to Choose? Computers connect to the Internet by way of a Local Area Network LANs have network IDs - the leftmost part of the IP address - assigned by an ISP or network administrator So this part is usually a fixed value Host IDs - the rightmost part of the IP address - are chosen by a local administrator, or generated automatically
Who Assigns Network IDs? Internet Assigned Numbers Authority (IANA) manages IP address blocks IANA assigns blocks to RIRs RIRs assign sub-blocks to specific organizations for their own use or for redistribution (ISPs do this) ISPs assign sub-blocks or individual IP addresses to customers Some IP address blocks are reserved for special uses e.g. 127.0.0.0/8 always refers back to the local host known as the loopback address
RIRs Regional Internet Registries RIRs receive blocks of IP addresses from IANA assign sub-blocks to ISPs, other organizations
IPv4 Allocation by RIR 2017 All unreserved blocks have been allocated
(What is a Hilbert curve?) These are Hilbert curves of increasing degree... They tend to keep numbers "close" to their neighbors Used for IPv4 "/8" address blocks
IPv4 Allocation by RIR 2013 Black squares: legacy allocations, not controlled by RIRs
IPv4 Allocations by Year From "ipv6now.com.au" North American usage grew in the 1990s Asia and Europe exploded around 2006-2007
Special IP addresses from RFC 6890, 2013 Address Block CIDR mask Address Range Uses - from RFC 6890 0.0.0.0 /8 10.0.0.0 /8 127.0.0.0 /8 169.254.0.0 /16 172.16.0.0 /12 192.168.0.0 /16 224.0.0.0 /4 240.0.0.0 /4 0.0.0.0-0.255.255.255 10.0.0.1-10.255.255.254 127.0.0.1-127.255.255.254 169.254.0.1-169.254.255.254 172.16.0.0-172.31.255.254 192.168.0.1-192.168.255.254 224.0.0.1-239.255.255.254 240.0.0.1-255.255.255.254 255.255.255.255 /0 255.255.255.255 Refers to "This" network (only 0.0.0.0 used) Private-use networks - not routed Loopback addresses Link Local (e.g. APIPA, used in Windows) Private-use networks - not routed Private-use networks - not routed Multicast (former class D) Reserved (former class E, "experimental") IP "universal broadcast" address (not routed or used)
Private, Non-Routed Blocks: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 IANA reserves blocks of IP addresses for local use Internet routers drop packets with addresses in these blocks Edge networks usually use subsets of 192.168.0.0/16 172.16.0.0/12 less common Intermediate-level routers (access, gateway) frequently use 10.0.0.0/8 subnets
Special Host Addresses On a Network h host bits yield 2 h different values for host addresses Unusable host-bits values: Host bits are all 0s: the IP address equals the network ID, and refers to the entire subnet Host bits are all 1s: the IP address is the subnet's broadcast address Thus, h host bits yield (2 h - 2) valid host addresses
Static Host ID Assignments Suitable for small networks No need to operate a DHCP server Necessary for server systems If a server s IP address changes, clients will lose the ability to access it! Accidentally giving two hosts the same address, or specifying an incorrect subnet mask, can isolate a host or even break the network
Setting static IP addresses Linux the "ifconfig" command can be used: > sudo ifconfig eth0 192.168.0.5 Windows the "netsh" command can be used: > netsh interface ip set address name="local Area Connection" static 192.168.0.5 GUI tools are also available
Dynamic IP Address Assignments Dynamic Host Configuration Protocol (DHCP) used to distribute IP addresses to hosts when they connect (or reconnect) to the network Based on earlier BOOTP protocol Full IP address (network ID, host ID), network mask, IP addresses of gateway router and DNS server, other configuration information can all be handed out DHCP server assigns host ID from a "pool" of available values One server can hand out different network IDs and information, based on location of requesting host
DHCP Operation Starting host broadcasts DHCP Discovery packet Local gateway forwards packet to one or more DHCP servers DHCP servers respond with DHCP Offer Offer contains IP address, subnet mask, other information Host then broadcasts DHCP Request for offered IP address Server returns DHCP lease acknowledgement Limited lease lifetime: typically weeks, days, or hours Host renews lease periodically Renewals typically occur when the lease is half over
DHCP exploration activity (preferably on a virtual client) Start wireshark Display filter: bootp Release your DHCP-assigned IP address: Linux: sudo dhclient -r Windows: ipconfig /release Obtain a new DHCP lease: Linux: sudo dhclient -4 Windows: ipconfig /renew Do you see the DHCP exchange? What are the source, destination IP addresses?
Configuring a Windows DHCP Server: Address pool Network mask (subnet mask)
example of a dhcpd.conf file (OpenBSD)
subnetting
Dividing an IP Address - Two Approaches The original approach IP classes Five network classes, determined by numeric value class A: the biggest networks; only 126 such class B: medium-size networks; 16,384 total class C: small networks; over 2 million possible class D, class E: special uses Wasteful and limiting Since 1993 Classless Internet Domain Routing (CIDR) IP addresses divided based on network mask
IP Address Classes (the old way) class A: 1.0.0.0 to 126.0.0.0 class B: 128.0.0.0 to 191.255.0.0 class C: 192.0.0.0 to 223.255.255.0 class D: 224.0.0.0 to 239.255.255.255 class E: 240.0.0.0 to 255.255.255.254
CIDR Classless Internet Domain Routing Network address blocks use as many network bits as needed remaining bits are host bits note: the fewer the network bits, the bigger the network Network masks (a.k.a. subnet masks) mark off network bits Network administrator can subdivide a network into subnets by lengthening the subnet mask
CIDR Notation Network addresses include the network mask information class A addresses are written 1.0.0.0/8.. 126.0.0.0/8 class B addresses are written 128.0.0.0/16.. 191.255.0.0/16 class C addresses are written 192.0.0.0/24.. 223.255.255.0/24 148.137.0.0 / 16 (former class B network) 148.137.59.0/24, 148.137.141.0/25, 148.137.141.128/25 these are three subnets of 148.137.0.0/16
Subnetting Start with a network block: 172.16.0.0/16 (only part of the 2 nd private address range) Decide what's needed: Do you need so-many subnets?...or do you need so-many hosts-per-subnet? Determine number of bits needed to count each subnet or each host-on-a-subnet Move leftmost bits from host ID to network ID according to subnet/hosts needs Defines corresponding subnet mask
Subnetting example Network block 172.16.0.0/16 10101100 00010000 hhhhhhhh hhhhhhhh network mask: 11111111 11111111 00000000 00000000 = 255.255.0.0 75 subnets needed so, need enough bits to count at least 75 2 7 = 128 >= 75, so 7 bits needed to count subnets Move 7 leftmost host-id bits into network ID 10101100 00010000 nnnnnnnh hhhhhhhh 9 bits left available to count hosts within a subnet New subnet mask: 11111111 11111111 11111110 00000000 = 255.255.254.0
Subnetting example subnet addresses Network ID bits: 16 (original block) + 7 (subnetting) = 23 2 7 = 128 possible subnets Subnetworks: 172.16.x.0/23 where x varies from one subnet to the next Subnet mask: 255.255.254.0 Host ID bits: 32 23 = 9 2 9 2 = 510 hosts per subnet 1 st subnet: 10101100 00010000 00000000 00000000 = 172.16.0.0/23 2 nd subnet: 10101100 00010000 00000010 00000000 = 172.16.2.0/23 3 rd subnet: 10101100 00010000 00000100 00000000 = 172.16.4.0/23 4 th subnet: 10101100 00010000 00000110 00000000 = 172.16.6.0/23 last subnet: 10101100 00010000 11111110 00000000 = 172.16.254.0/23
Subnetting example 2 Network block 172.16.0.0/16 10101100 00010000 hhhhhhhh hhhhhhhh network mask: 11111111 11111111 00000000 00000000 = 255.255.0.0 1000 hosts needed per subnet so, need enough host bits to count at least 1000 2 10 = 1024 >= 1000, so 10 bits needed to count hosts 10 rightmost host-id bits leave 6 left over for subnet IDs 10101100 00010000 nnnnnnhh hhhhhhhh New subnet mask: 11111111 11111111 11111100 00000000 = 255.255.252.0
Subnetting example 2 subnet addresses Network ID bits: 16 (original block) + 6 (subnetting) = 22 2 6 = 64 possible subnets Subnetworks: 172.16.x.0/22 where x varies from one subnet to the next Subnet mask: 255.255.252.0 1 st subnet: 10101100 00010000 00000000 00000000 = 172.16.0.0/22 2 nd subnet: 10101100 00010000 00000100 00000000 = 172.16.4.0/22 3 rd subnet: 10101100 00010000 00001000 00000000 = 172.16.8.0/22 4 th subnet: 10101100 00010000 00001100 00000000 = 172.16.12.0/22 last subnet: 10101100 00010000 11111100 00000000 = 172.16.252.0/22
another DHCP server with subnetting
done