Class notes

Comments

Transcription

Class notes
Day14
CIDR
Classless Inter-Domain Routing
IP Addresses
• Each computer connected directly to internet
must have a unique IP address
• Address is made up of 2 parts
– Network Address
– Host Address
– E.g. 10.0.0.1 may be host 1 in the network 10.0.0.0
• Not all networks are the same size.
– Because of differing needs, some networks can
hold 2 hosts, some can hold 16,777,216 hosts.
– Therefore we need to be able to specify how much
of the IP defines is the host address, and how much
defines the network.
Format of IP
• “Dotted Decimal”
– Each element is called an “octet”
– There are 4 “octets”
– Example
• 10.0.0.1
• Binary
– 00001010 00000000 00000000 00000001
• Hex
– 0a000001
• Decimal
– 167,772,161
Subnet Masks (netmask)
• A netmask defines how much of the IP
address represents the network, and
how much represents the host.
• Example:
– My IP address is 123.123.123.5
– Everyone in my network has an IP address
123.123.123.X
• Network Address is 123.123.123.0
• My host address is .5
Netmasks
• A netmask is a 32 bit number just like
an IP address.
• Valid netmasks have sequential 1’s
followed by 0’s.
• Example of a valid netmask:
– 255.255.255.0
– 11111111.11111111.11111111.00000000
• Example of an Invalid netmask:
– 11111111.11111111.11111101.00000000
The netmask “masks” the IP address
• The 1’s and 0’s in the netmask
correspond to the network and host
portions of the IP address.
• Example:
– IP address: 10.0.0.1
• 00001010 00000000 0000000 00000001
– Netmask: 255.0.0.0
• 11111111 00000000 0000000 00000000
– Thus the network address is:
• 10
– And the host address is:
• 0.0.1
Common Netmasks
• 255.0.0.0
• 255.255.0.0
• 255.255.255.0
(Class A).
(Class B).
(Class C).
Example
• IP 139.131.1.147 / 255.255.255.0
– What network is this host in?
• 139.131.1.0
– What is the host ID?
• 147
Simple netmask example:
• Address:
– 200.200.200.55
• Netmask:
– 255.255.0.0
– 11111111 . 11111111 . 00000000 . 00000000
• This tells us:
200 . 200 . 200 . 55
Network Address
Host Address
It gets worse!
• Unfortunately the host address can start at
ANY of the 32 bits, not just on the 8 bit
boundaries.
• More complex Netmask Example:
– 255.255.255.128
– 11111111 . 11111111 . 11111111 . 10000000
Network Address
• Now our IP address: 200.200.200.55 is part
of:
– Netmask: 255.255.255.128
– Lowest Address: 200.200.200.0
– Highest Address: 200.200.200.127
255.255.255.128 netmask means:
• When the netmask was 255.255.255.0 we
had 256 addresses in network
• Once it becomes 255.255.255.128, we now
only have 128 addresses in network.
• If we took a 255.255.255.0 network, and
used a 255.255.255.128 netmask on it:
– Our 256 address network, is now divided into 2
networks:
• 200.200.200.0
- 200.200.200.127
• 200.200.200.128 - 200.200.200.255
– They BOTH have the netmask 255.255.255.128
What are all the valid netmasks?
•
•
•
•
•
•
•
•
•
11111111.11111111.11111111.00000000
11111111.11111111.11111111.10000000
11111111.11111111.11111111.11000000
11111111.11111111.11111111.11100000
11111111.11111111.11111111.11110000
11111111.11111111.11111111.11111000
11111111.11111111.11111111.11111100
11111111.11111111.11111111.11111110
11111111.11111111.11111111.11111111
= 255.255.255.0
= 255.255.255.128
= 255.255.255.192
= 255.255.255.224
= 255.255.255.240
= 255.255.255.248
= 255.255.255.252
= 255.255.255.254
= 255.255.255.255
* Of course, this is only looking at the class C networks
What the netmasks mean
• 255.255.255.0
• 255.255.255.128
each
• 255.255.255.192
• 255.255.255.224
• 255.255.255.240
• 255.255.255.248
• 255.255.255.252
• 255.255.255.254
• 255.255.255.255
1 Network
2 Networks
256 addresses
128 addresses in
4 Networks 64 addresses in each
8 Networks 32 addresses in each
16 Networks 16 addresses in each
32 Networks 8 addresses in each
64 Networks 4 addresses in each
???
???
This is a single machine.
What’s wrong
here?
Computing a Netmask
• Given a range of addresses
(199.120.197.0 - 199.120.197.127),
you can compute the netmask:
–
Subtract the lowest number in the range
from the highest:
• 199.120.197.127 - 199.120.197.0 = 0.0.0.127
(this means that there are 128 addresses in the
range -- because 0 counts).
– Subtract the resulting number from
255.255.255.255:
• 255.255.255.255 - 0.0.0.127 = 255.255.255.128
Computing the Address Range
Given a network (255.255.255.128), you
can compute the range of addresses:
• Subtract the netmask from 255.255.255.255:
– 255.255.255.255 - 255.255.255.128 = 0.0.0.127
• Add 1 to each octet which is > 0:
– 127 + 1 = 128: 0.0.0.128
• Now you see that there are 128 addresses in
this range.
– (If your answer were 0.0.128.256, you would know
that there were 128*256 addresses in the range.)
Another Example:
• A Network address is 199.120.197.144
• It’s netmask is 255.255.255.240.
– How many IP addresses are in this
network?
Answer:
• 199.120.197.144 / 255.255.255.240.
– How many IP addresses are in this
network?
255.255.255.255 - 255.255.255.240
= 0.0.0.15
• Therefore, we have 16 IP addresses in this
network:
– 199.120.197.144 - 199.120.197.159
– Note: That is 16, because 144 is one of them.

Similar documents