IP Subnetting

Download Report

Transcript IP Subnetting

IP Subnetting
CIT 307
Kevin Siminski
The Basics
 192.168.10.48 255.255.255.224
 So… what does this mean?
 If you want to work in the networking industry you
ABSOLUTELY need to understand how to subnet IP addresses
 IP address is a 32 bit address, bits are either 1 or 0
 IP address contain 4 octets of 8 bits
 11110000.11110000.11111111.11111110
 IP address and Mask define the host address and the network
address
 Network is a layer 3 function in OSI model
 IP address and Network subnet mask also define how
many hosts are in a IP network
 Example 255.255.255.0 = 256 hosts
 255.255.255.128= 128 hosts
 255.255.0.0 = 216 hosts = 65536
 Classful subnetting
 Class A = 255.0.0.0 (16,777,216 Hosts)
 Class B = 255.255.0.0 (65,536 Hosts)
 Class C = 255.255.255.0 (255 Hosts)
-Zero’s indicate how many hosts are available in block-
 Now forget about traditional Classful subnetting
 Variable Length Subnet Masking (VLSM) is what is
utilized today
 An IP address ALWAYS has to important element
 Network address and a Broadcast address
 Network address is always EVEN, Broadcast address is
always ODD.
 An IP address is like a phone number It’s unique; if publically routable over Internet
 192.168.2.0 255.255.255.0
 3 first three octets are the Network; Last octet is host
 For your network you can only use 192.168.2.1-254
 You can’t change the first three octets
 Subnetting is like taking a piece of pie and dividing it up
it smaller pieces.
 You can only sub-divide by multiples of 2-
Yes
Yes
Yes
NO
 The subnet mask determines how the pie is divided
 Network address is similar to your phone number
 Area-code & Exchange (317)-823 = NETWORK
 Last four digits 317-823-1234 = Host
 The broadcast address is similar to dialing the operator and
asking for assistance. In networking, the broadcast address is
used to ask all of the available hosts to broadcast their address
so that switch/router can find the appropriate path to send IP
packets
 Now how do we figure out all this stuff?
 Step 1- Convert IP address to binary form
142.10.24.32
 Convert each octet into it’s 8 binary bits
128
1
0
0
0
64
0
0
0
0
32
0
0
0
1
16
0
0
1
0
8
1
1
1
0
4
1
0
0
0
2
1
1
0
0
1
0
0
0
0
=
=
=
=
142
10
24
32
 We will start with first octet (142), start at left and determine
if you can subtract 128 from 142 and end up with positive
integer, yes = 1 & no = 0
 142-128 = 14 (true), then ask if you can take 14 – 64… NO (false),
14 – 32 (False), 14 – 16 (false), 14-8 = 6 (true), 6-4=2 (true), 2-2=0
(true), 0-1 (false)
 142 = 10001110 (8 bits)… now
 255 = 11111111 & 0 = 00000000
 Now we know why an 8 bit address can be no larger than 255!
 Subnet mask 255.255.255.0 or 255.255.255.128 is same
process
11111111.11111111.11111111.00000000 = 255.255.255.0
11111111.11111111.11111111.10000000 = 255.255.255.128
 Shorthand notation for subnet mask is notated by
counting number of ones
 255.255.255.0 = /24
 255.255.255.128 = /25
 255.255.255.192 = /26 and so on…
 Subnet mask is always contiguous 1’s from left to right
 11111111.11111111.11111111.10110000 is NOT a valid
subnet
 The ones in the subnet equal the network prefix and the
0’s equal the HOST
8 Zero’s in the first example = 28 = 256 HOST; 27 = 128
 A IP address and subnet determine two important pieces
of information:
 What the NETWORK address is
 What the BROADCAST address is
 192.168.10.130 /24 (255.255.255.0)
 Network = 192.168.10.0
 Broadcast = 192.168.10.255
 USABLE HOSTS = 192.168.10.1-254 (these are address you
can use for your network)
 Now how did I figure this out?
 192.168.10.130 /24
 Step one do a bitwise & operation against octets

0 + 0 = 0; 1+0 = 0; 0+1=0; 1+1= 1 (TRUE)

If you want more details, look up binary number system on wikipedia

Now compare the octet by converting to binary-
192.168.10.130
255.255.255.0
128
64
32
16
8
4
2 1
192
1
1
0
0
0
0
0 0
255
1
1
1
1
1
1
1 1
0
0
0 0
Now use bitwise & to compare the values
192
1
1
0
0
Simple rules- Anytime you compare a NUMBER against 255, will result in
same number, Anytime you compare a number against 0, will result in 0
during bitwise & operation

Now do the rest…
128
64
32
16
8
4
2
1
168
1
0
1
0
1
0
0
0
255
1
1
1
1
1
1
0
0
168
1
0
1
0
1
0
0
0
128
64
32
16
8
4
2
1
10
0
0
0
0
1
0
1
0
255
1
1
1
1
1
1
1
0
10
0
0
0
0
1
0
1
0
128
64
32
16
8
4
2
1
30
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NETWORK ADDRESS = 192.168.10.0

NETWORK ADDRESS = 192.168.10.0

Subnet mast = 255.255.255.0 (1111111.11111111.11111111.00000000)

This is the part that I like to compare to book-ends:
Usable Hosts
Broadcast
Now lets figure out Broadcast address-
Network add

The subnet mask determines the number of usable hosts, you CANNOT use Network or broadcast for host address or you will
break your network!
To determine number of total hosts take total bits in IP address (32) – number of 1 bits in the
subnetmask (24)
32-24 = 8
Now take 2 raised to the 8 = 28 = 256, now add this number to the ip address in the last octet
0 + 256 = 256, now subtract 1 since you start on 0 value = 255

NETWORK ADDRESS = 192.168.10.0

Broadcast Address = 192.168.10.255

Usable hosts = 192.168.10.1 - 254

200.100.10.120 /25 (255.255.255.128)

NETWORK 200.100.10.x

B/Cast 200.100.10.x

We can quickly determine first 3 octets based on simple rule mentioned in slide 9

Now we just need to determine last octet
128
64
32
16
8
4
2
1
120
0
1
1
1
1
0
0
0
128
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Network Address
32 bits – 25 bits = 7
200.100.10.0
27=128 total hosts
Now take last octet in network 0 + 128 (total hosts) = 128 -1= 127
Broadcast Address 200.100.10.127
Usable hosts = 200.100.10.1-126

200.100.10.120 /17 (255.255.128.0)

NETWORK 200.100.x.0

B/Cast 200.100.x.255

We can quickly determine first 3 octets based on simple rule mentioned in slide 9

Now we just need to determine last octet
128
64
32
16
8
4
2
1
10
0
1
1
1
1
0
0
0
128
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Network Address
200.100.0.0
32 bits – 17 bits = 15 215=32,768 total hosts, Instead take bits in Octet (8) - # of
subnet bits in third octet (1); 8-1 = 7; 27 = 128
Now take last octet in network 0 + 128 (total hosts) = 128 -1= 127
Broadcast Address 200.100.127.255
Usable hosts = 200.100.1-127.0-254

Relationship between # of hosts and subnet mask.

255.255.255.0 = 256 TOTAL hosts

255.255.255.128 = 128 TOTAL hosts

255.255.255.192 = 64 TOTAL Hosts (see the pattern emerging…)

255.255.255.224 = 32

255.255.255.240 = 16

255.255.255.248 = 8

255.255.255.252 = 4

255.255.255.254 = 2 (you really can’t use this since you would only have NETWORK
address and BroadCast, with no usable hosts)
 Visual breakdown of subnets
/24
/25
/26
/27
/28
/29
/30

Remember these simple rules

Network address is always even, broadcast is always odd

Network address is always the low value, broadcast is high value and the usable hosts are between the two values

You can NEVER use a broadcast or network address for a host address