copyright 2015 Robert Montante
setting IP addresses
Static Address 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…
2
Setting static IP addresses
•Linux
– the "ifconfig" command can be used: > 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
Choosing IP Addresses
•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, 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
RIRs – Regional Internet Registries
• RIRs
– receive blocks of IP addresses from IANA – assign sub-blocks to ISPs, other organizations
4
IP Address Map - October 2012
Distribution of 420 Million Sampled IP Addresses, June - October 2012
Daily Internet Usage Map - October 2012
Special IP addresses – from RFC 6890, 2013
Address Block CIDR mask Address Range Uses - RFC 6890
0.0.0.0 /8 0.255.255.2550.0.0.0 - Refers to "This" network (only 0.0.0.0 used)
10.0.0.0 /8 10.255.255.25410.0.0.1 - Private-use networks - non-routable
14.0.0.0 /8 14.255.255.25414.0.0.1 - Public-Data Network 24.0.0.0 /8 24.255.255.25424.0.0.1 - Cable TV networks
100.64.0.0 /10 192.168.255.254192.168.0.1 - Shared address space (for Carrier-Grade NAT)(similar to Private-use address spaces) 127.0.0.0 /8 127.255.255.254127.0.0.1 - Loopback addresses
169.254.0.0 /16 169.254.255.254169.254.0.1 - Link Local (e.g. APIPA, used in Windows in XP)
172.16.0.0 /12 172.31.255.254172.16.0.0 - Private-use networks - non-routable
192.0.0.0 /24 192.0.0.254192.0.0.1 - IETF protocol assignments
192.0.0.0 /29 192.0.0.1 - 192.0.0.6 DS-Lite (Dual-Stack, IPv4-and-IPv6 devices)
192.0.2.0 /24 192.0.2.254192.0.2.1 - "TEST-NET-1" (e.g. example addresses in documentation)
192.88.99.0 /24 192.88.99.254192.88.99.1 - 6to4 relay anycast
192.168.0.0 /16 192.168.255.254192.168.0.1 - Private-use networks - non-routable
198.18.0.0 /15 198.19.255.254198.18.0.1 - Benchmark tests of network interconnect devices 198.51.100.0 /24 198.51.100.254198.51.100.1 - "TEST-NET-2" (e.g. example addresses in documentation)
203.0.113.0 /24 203.0.113.254203.0.113.1 - "TEST-NET-3" (e.g. example addresses in documentation) 224.0.0.0 /4 239.255.255.254224.0.0.1 - Multicast (former class D)
240.0.0.0 /4 255.255.255.254240.0.0.1 - Reserved (former class E, "experimental") 255.255.255.255 255.255.255.255 IP "universal broadcast" address (not routed or used)
6
DHCP
– Dynamic Host Configuration Protocol • Operation:
– Starting host broadcasts “DHCP Discovery” packet • Local gateway should route this packet to one or
more DHCP servers
– DHCP servers respond with “DHCP Offer”
• Offer contains IP address, subnet mask, and some other information
– Host acknowledges with “DHCP Request” – Server returns acknowledgement of a “DHCP
lease” with a fixed lifetime
• typically a week or so, or a day or less in public areas
– Host can renew its lease periodically as long as it wants it
• Renewals typically occur when the lease is half over
example of a dhcpd.conf file (OpenBSD)
DHCP exploration activity
• Start wireshark (on the physical host)
– Display filter:eth.addr==<your MAC address>
• Release your DHCP-assigned IP address:
– Linux: dhclient -r
– Windows: ipconfig /release • Obtain a new DHCP lease:
– Linux: dhclient -4
– Windows: ipconfig /renew
8
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 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.0to 239.255.255.255 • class E: 240.0.0.0to 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
10
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 Baddresses 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 partof the 2nd private address range)
• Decide what's needed:
– Need so-many subnets?
– Need so-many hosts-per-subnet?
• Determine number of bits needed to count each subnet or each host-on-a-subnet
• Move bits from host ID to network ID to according to subnet/hosts needs
Subnetting example • Network block 172.16.0.0/16 – 10101100 00010000hhhhhhhh hhhhhhhh – network mask: • 11111111 1111111100000000 00000000 = 255.255.0.0 • 75subnets needed
– so, need enough bits to count at least 75
• 27= 128 >= 75, so 7bits needed
• Move 7 leftmost host-ID bits into network ID
– 10101100 00010000 nnnnnnnh hhhhhhhh
• New subnet mask:
– 11111111 11111111 11111110 00000000 = 255.255.254.0
Subnetting example – subnet addresses
• Network ID bits: 16 (original block) + 7 (subnetting) = 23 – 27= 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 – 29– 2 = 510 hosts per subnet • 1stsubnet: – 10101100 00010000 00000000 00000000 = 172.16.0.0/23 • 2ndsubnet: – 10101100 00010000 00000010 00000000 = 172.16.2.0/23 • 3rdsubnet: – 10101100 00010000 00000100 00000000 = 172.16.4.0/23 • 4thsubnet: – 10101100 00010000 00000110 00000000 = 172.16.6.0/23 … • last subnet: – 10101100 00010000 11111110 00000000 = 172.16.254.0/23
12 Subnetting example 2 • Network block 172.16.0.0/16 – 10101100 00010000hhhhhhhh hhhhhhhh – network mask: • 11111111 1111111100000000 00000000 = 255.255.0.0
• 1000hosts needed per subnet
– so, need enough host bits to count at least 1000
• 210 = 1024 >= 1000, so 10bits needed
• 10 rightmost host-ID bits leave 6 left over for subnet IDs
– 10101100 00010000nnnnnnhh hhhhhhhh
• New subnet mask:
– 11111111 1111111111111100 00000000 = 255.255.252.0 Subnetting example 2 – subnet addresses • Network ID bits: 16 (original block) + 6 (subnetting) = 22 – 26= 64 possible subnets – Subnetworks: 172.16.x.0/22 where x varies from one subnet to the next – Subnet mask: 255.255.252.0 • 1stsubnet: – 10101100 00010000 00000000 00000000 = 172.16.0.0/22 • 2ndsubnet: – 10101100 00010000 00000100 00000000 = 172.16.4.0/22 • 3rdsubnet: – 10101100 00010000 00001000 00000000 = 172.16.8.0/22 • 4thsubnet: – 10101100 00010000 00001100 00000000 = 172.16.12.0/22 … • last subnet: – 10101100 00010000 11111100 00000000 = 172.16.252.0/22
a DHCP server with subnetting
Network/Subnet Addresses; Host Addresses, Broadcast Addresses
• IP address divided into network address and host address
• For a given network/subnet, the network address is fixed
• Host bits:
– Host bits are all 0s:the IP address is the address of the entire subnet
– Host bits are all 1s: the IP address is the subnet's
broadcastaddress
14