IP v4 Addressing
IPv4
Layer 3 protocol
Packets treated independently and may take different routing paths
Best effort delivery
No data recovery features
Format Overview
32 bit binary number (4 Bytes) divided into 4 octets (8 bits or 1 Byte)
Has a network and host portions
Network Address Portion ( Network ID)
identifies a specific network
routers maintain routing tables and uses the network address
looks at destination IP address and match to network address
Host Address Portion (Host ID)
identifies a specific endpoint on a network
servers, printers etc
Address Classes
Address classes were used from 1981 till 1993 when CIDR (Classless Inter-Domain Routing) was introduced. Prior to 1993 the IPv4 address space was divided into 5 Classes Class A - Unicast Trafic 0-127 (0 and 127 are reserved with 127 being loopback address and 0 being the network address, so actually the range is from 1.0.0.0-126.255.255.255` Class B - Unicast Traffic - Range from 128.0.0.0 - 191.255.255.255 Class C - Unicast Traffic - Range from 192.0.0.0 - 223.255.255.255 Class D - Multicast Traffic - Range from 224.0.0.0 - 239.255.255.255 Class E - Reserved for future or experimental purposes - Range from 240.0.0.0 255.255.255.255
IPv6 does not use address classes IPv4 Classes has now been replaced with CIDR in 1993
Special Addresses
Directed Broadcast Address - host sends data to ALL devices on a specific network. This is ALL 1's in the entire host portrion of the address Network 172.31.0.0 - a directed broadcast for this network would be 172.31.255.255
In this example above an attacker on IP 172.16.0.10 wants to ATTACK 172.16.0.1 he would would initiate a directed broadcast to the 172.31.0.0 network FROM a SOURCE IP of 172.16.0.1 and ALL devices on that subnet including 172.31.0.1 will forward that broadcast to upper level protocols for processing. These would then respond to the 172.16.0.1 machine thus the machine would be overwhelmed and cause a DDoS or Directed Denial of Service attack. Cisco has disabled the feature for Directed Broadcasts to prevent these types of attacks.
Local Broadcasght address An example would be a DHCP server responding to a client broadcast for an allocation of an IP address. Remember LOCAL BROADCAST addresses are ALWAYS dropped by L3 devices - this can be overridden by using DHCP forwarding or DHCP relay ( this is if the DHCP server is in a different subnet to the client)
Here the switch receives the broadcast and using the proxy will then send a UNICAST DHCP request to the DHCP server on behalf of the broadcast from the PC that requested it.
Local Loopback Address - Very useful for testing and can be used to send a message to itself to make sure that the TCP/IP stack is correctly installed and working. For ANYTHING in the 127 range (its a Class A address, thus the biggest mistake the designers ever did was to make the entire 127.0.0.0/8 (approx 16 million addresses) is considered a loopback address!!!
In IPv6 the loopback address is ::1 and made sure they didn't make the same mistake again :)
Loopback Interface - Don't get confused with Routers and Switches who also have loopback addresses, but these have valid IP addresses and NOT the same as the local loopback address. Routers and Switches have Loopback INTERFACES for example 10.1.1.1/32
Link Local Address - IPv4 (RFC3927) This IP is referred to as APIPA (Automatic Private IP Address) and is allocated dynamically if a DHCP server is not found. Its IP address range is 169.254.0.0/16
RFC 1918- Private Addresses
RFC (Request for Comment) private IP Networks that are NOT routable on the Internet (See RFC 1149 - done on the 1st April 1990 - the transmission of IP datagrams on Avian Carriers :) )
The private IP address ranges allocated are:
10.0.0.0 - 10.255.255.255 (10/8 prefix) Class A
172.16.0.0 - 172.31.255.255 (172.16/12 prefix) Class B
192.168.0.0/16 - 192.168.255.255 (192.168/16 prefix) Class C
These private IP's will need to use NAT to access the internet !
Subnet Masks
Used to determine which part of the IP address is the network portion and which part is the host portion and if the device is local or remote. If remote, it will be forwarded to the default gateway. Class A, B and C networks have default masks, known as "Natural Masks" ie /8, /16 and /24 The /8 means that it has a subnet mask of 255.0.0.0. The 255 says in binary the 8 bits are all 1's This means that all 1's is the network portion and all 0's are the host portion (node)
The first line shows the decimal values for the binary numbers of an octet
Dec Value & Range | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Subnet | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 |
2nd Octet | /9 | /10 | /11 | /12 | /13 | /14 | /15 | /16 |
3rd Octet | /17 | /18 | /19 | /20 | /21 | /22 | /23 | /24 |
4th Octet | /25 | /26 | /27 | /28 | /29 | /30 | /31 | /32 |
Using the rule of 2^n-2 (one address for the network and one for the broadcast address) when it comes to POINT-to-POINT links we can use the /31 subnet mask as there is ONLY 2 addresses anyway
Working Out Hosts and Networks
Here we can see we need to work out what the subnet should be for San Francisco and New York if each site requires 60 hosts each. We have been given a network of 192.168.1.0/24 to use
Hosts - We use the formula of , we count the HOST bits from right to left. The minus 2 is because we have to allocate an IP for the subnet itself as well as an IP for the broadcast address
Networks - We use the formula and we count NETWORK bits from left to right
Step1: Write down the 'Shortcut Table"
Example: 1
ABC Ltd has been allocated a subnet 10.1.1.0/24 for a small office in London. Paul, the network admin, needs to split this subnet into smaller subnets. Each subnet needs to support 14 machines
STEP 1:
Which formula to use? Hosts or Networks
As the question asks "The subnets need to support 14 hosts" we will use theformula
Therefore we need to count from the right hand side to the left hand side
STEP 2:
Work out how many bits are required to cover the number to host. Check the table above and we see that 2^4 = 16 minus 2 gives us the 14 hosts we require. This means that 4 binary bits (2^4) will support the 14 hosts. So we need to to 'steal' 4 bits from the HOST portion and allocate that to the NETWORK portion to create multiple subnets able to support 14 devices.
Step 3:
Here we see its a /28 with a network range of 16 (10.1.1.0/28, 10.1.1.16/28, 10.1.1.32/16 etc)
Therefore the networks:
Network Address 1st Usable Address Last Usable Address Broadcast Address
10.1.1.0/28 10.1.1.1 10.1.1.14 10.1.1.15
10.1.1.16/28
Example 2
You have been given the 172.16.0.0/16
network. You are asked to create 80 subnets for your company LAN's. What prefix should you use
Step1
Which formula to use? Hosts or Networks
As the question asks "Create 80 subnets" we will use theformula
Therefore we need to count from the left hand side to the right hand side
Step 2
Work out how many bits we need and for 80 networks n = 7 ( )
So from /16 count 7 from left to right = /23
A network range of 2 with dotted decimal of 255.255.254.0
Hosts per network = 2^9 = 512 hosts/subnet
.Network Address 1st Usable Address Last Usable Address Broadcast Address
172.16.0.0/23 172.16.0.1 172.16.1.254 172.16.1.255
172.16.2.0/23 172.16.2.1 ----> etc
172.16.4.0/23
Example 3
You have been given the 172.30.0.0/16 network. Your company requires you to divide the network into 4 subnets of equal size. Identify the network and broadcast address of the second subnet
Step1
Which formula to use? Hosts or Networks
As the question asks "Create 4 subnets of equal sizes" we will use theformula
Therefore we need to count from the left hand side to the right hand side
Step 2
Work out how many bits we need and for 4 networks n = 2 ( )
So from /16 count 2 from left to right = /18
A network range of 64 with dotted decimal of 255.255.192.0
Hosts per network = (2^14)-2 = hosts/subnet
Example 4
You have been given the 10.0.0.0/8 network. You must create 2000 subnets which will be distributed to various enterprises. What prefix length must you use? How many hosts addresses (usable addresses) will be in each subnet?
Step 1
Which formula to use? Hosts or Networks
As the question asks "Create 2000 subnets" we will use theformula
Therefore we need to count from the left hand side to the right hand side
Step 2
Work out how many bits we need and for 2000 netwoks n = 11 (2^11= 2048 Networks)
So from /8 count 11 from left to right = /19
A network range of 32 with dotted decimal of 255.255.224.0
Hosts per network = (2^13)-2 = hosts/subnet (=8190 Hosts)
Network Address 1st Usable Address Last Usable Address Broadcast Address
10.0.0.0/19 10.0.0.1 10.0.31.254 10.0.31.255
10.0.32.0/19 10.0.32.1 10.0.63.254 10.0.63.255
10.0.64.0/19
Last updated