IP Addressing Notes

IPv4 Addressing

  • An IPv4 address is a 32-bit number divided into four 8-bit values called octets.

  • Each octet can have a value from 0 to 255.

  • Four decimal numbers are separated by periods in a format called dotted decimal notation

  • Subnet masks are also 32-bit numbers that determine how many bits are allocated to a network ID and how many to a host ID.

  • When written in binary, 1s in the subnet mask that correspond to bits in the IP address mean the matching bit locations are part of the network ID.

  • Example:

    • 192.168.14.250 = 11000000.10101000.00001110.11111010

    • 255.255.255.0 = 11111111.11111111.11111111.00000000

    • The example above shows 192.168.14.0 as the network ID and 250 as the host ID

Binary Math

  • Computers determine the network ID by doing a logical AND operation between its IP address and subnet mask.

  • A logical AND is an operation between two binary values.

  • AND operations can have the following results:

    • 0 AND 0 = 0

    • 1 AND 0 = 0

    • 0 AND 1 = 0

    • 1 AND 1 = 1

  • The logical AND operation between a computer’s IP address and subnet mask looks like this:

    • 10101100.00011111.01100100.00000110 (binary for 172.31.100.6)

    • AND 11111111.11111111.00000000.00000000 (binary for 255.255.0.0)

    • 10101100.00011111.00000000.00000000 (binary for 172.31.0.0)

  • Converting Binary to Decimal

    • Review how the decimal number system works

    • 0 through 9 are used to represent any possible number

    • Each place in a decimal number can have 10 possible values

    • The ones place can be expressed as a number 0 through 9, multiplied by 10 raised to the 0 power or 10010^0 (any number raised to the 0 power equals 1)

    • The decimal number 249 can be expressed as either of the following:

      • (2102)+(4101)+(9100)=249(2 * 10^2) + (4 * 10^1) + (9 * 10^0) = 249

      • (2100)+(410)+(91)=249(2 * 100) + (4 * 10) + (9 * 1) = 249

  • With binary arithmetic, there are only 2 possible values (1 or 0).

    • For example, using the same method you used to solve the decimal example, you can express the binary number 101 as either of the following. The numbers in bold are the binary digits.

      • (122)+(021)+(120)=5(1 * 2^2) + (0 * 2^1) + (1 * 2^0) = 5

      • (14)+(02)+(11)=5(1 * 4) + (0 * 2) + (1 * 1) = 5

  • Converting Decimal to Binary

    • To convert 125 to binary:

      • 125 is less than 128, so you place a 0 in the column under the 128. The test number remains 125.

      • 125 is greater than 64, so you place a 1 in the column under the 64 and subtract 64 from 125, leaving your new test number as 61.

      • 61 is greater than 32, so you place a 1 in the column under the 32 and subtract 32 from 61, leaving your new test number as 29.

      • 29 is greater than 16, so you place a 1 in the column under the 16 and subtract 16 from 29, leaving your new test number as 13.

      • 13 is greater than 8, so you place a 1 in the column under the 8 and subtract 8 from 13, leaving your new test number as 5.

      • 5 is greater than 4, so you place a 1 in the column under the 4 and subtract 4 from 5, leaving your new test number as 1.

      • 1 is less than 2, so you place a 0 in the column under the 2.

      • 1 is equal to 1, so you place a 1 in the column under the 1 and subtract 1 from 1, leaving your new test number as 0. When your test number is 0, you’re done.

  • Converting Binary to Decimal Using a Table

    • Using the binary number 11010011, you get the following: 128+64+0+16+0+0+2+1 = 211

IP Address Classes

  • IP Addresses are categorized in Classes A-E.

  • Only IP addresses in the A, B, and C classes are available for host assignment.

  • Class A address information:

    • The value of the first octet is between 1 and 127.

    • An IP registry assigns the first octet, leaving the last three octets to be assigned to hosts.

    • This allows 24 bits of address space or 16,777,214 hosts per network address.

  • Class B address information:

    • The value of the first octet is between 128 and 191.

    • An IP registry assigns the first two octets, leaving the third and fourth octets to be assigned to hosts.

    • Having two octets in the host ID allows 65,534 hosts per network address.

  • Class C address information:

    • The value of the first octet is between 192 and 223.

    • An IP address registry assigns the first three octets.

    • These networks are limited to 254 hosts per network.

  • Class D address information:

    • The value of the first octet is between 224 and 239.

    • These addresses are reserved for multicasting.

  • Class E address information:

    • The value of the first octet is between 240 and 255.

    • These addresses are reserved for experimental use and can’t be used for address assignment.

    • Table summarizing address Classes A, B, and C:

      • Class A: First octet 0-127, Default subnet mask 255.0.0.0, Network ID bits 8, Max hosts/network 16,777,214, Host bits 24

      • Class B: First octet 128-191, Default subnet mask 255.255.0.0, Network ID bits 16, Max hosts/network 65,534, Host bits 16

      • Class C: First octet 192-223, Default subnet mask 255.255.255.0, Network ID bits 24, Max hosts/network 254, Host bits 8

Private IP Addresses

  • Due to the popularity of TCP/IP and the Internet, unique IP addresses are almost exhausted.

  • A series of addresses have been reserved for private networks (networks whose hosts can’t be accessed directly through the Internet).

  • Reserved addresses:

    • Class A addresses beginning with 10

    • Class B addresses from 172.16 to 172.31

    • Class C addresses from 192.168.0 to 192.168.255

  • The addresses in those ranges can’t be routed across the Internet.

  • If access to the Internet is necessary, a process called Network Address Translation (NAT) is used.

  • Another type of private IP address is a link-local address:

    • It is not assigned manually or through DHCP.

    • It is assigned automatically when a computer is configured to receive an IP address through DHCP but no DHCP service is available.

    • Automatic Private IP Addressing (APIPA) is another term for this type of addressing.

    • APIPA addresses are assigned in the range of 169.254.1.0 through 169.254.254.255 with a subnet mask of 255.255.0.0.

Classless Interdomain Routing

  • Classless Interdomain Routing (CIDR) is a type of address configuration where subnet masks could be configured regardless of the address class.

  • The use of IP addresses with their default subnet masks is referred to as classful addressing.

  • With CIDR, you could assign the IP address of 172.31.210.10 with a subnet mask of 255.255.255.0.

  • In this case 172.31.210.0 would be the network ID and .10 would be the host ID.

CIDR Notation

  • CIDR notation uses the format A.B.C.D/n where n is the number of 1 bits in the subnet mask.

  • Example:

    • 172.31.210.10 with a 255.255.255.0 subnet mask is expressed as 172.31.210.10/24 in CIDR notation.

    • The network ID is 24 bits, leaving 8 bits for the host ID.

Broadcast Domains

  • A broadcast domain defines which devices must receive a packet that’s broadcast by any other device.

  • A broadcast is a packet addressed to all computers on the network.

  • TCP/IP communication relies heavily on broadcast packets.

  • DHCP and ARP use broadcasts to perform their tasks.

  • Every time a computer receives a broadcast packet, the NIC generates an interrupt, causing the CPU to stop what it’s doing and read the packet.

  • If the broadcast is not relevant to the computer, the packet is discarded.

Subnetting

  • Subnetting is a process that reallocates bits from an IP address’s host portion to the network portion, creating multiple smaller address spaces.

  • Reasons to subnet:

    • To divide a very large network into many smaller subnetworks

    • To conserve IP addresses

    • To divide a network into logical groups

Calculating a Subnet Mask

  • To divide a large network into smaller subnets, follow this process:

    • Decide how many subnets you need.

      • Each router interface connection indicates a required subnet.

    • Decide how many bits you need to meet or exceed the number of required subnets.

      • Use the formula 2n2^n, with n representing the number of bits you must reallocate from the host ID to the network ID.

      • The number of subnets you create is always a power of 2, so if you need 60 subnets, you must reallocate 6 bits (26=642^6 = 64), reallocating 5 bits gives you only 32 subnets.

    • Reallocate bits from the host ID, starting from the most significant host bit (that is, from the left side of the host ID).

    • You must also ensure that you have enough host bits available to assign to computers on each subnet.

      • To determine the number of host addresses available, use the formula 2n22^n - 2, with n representing the number of host (0) bits in the subnet mask.

  • The pattern to the subnetwork numbers is increments of 4.

    • To derive this pattern:

      • Look at the octet where the subnet bits are reallocated

      • Look at the rightmost reallocated bit

      • The subnet increment is determined by the binary place value of this bit

  • Determining Host Addresses

    • Host addresses in each subnet can be determined by cycling through the host bits

  • Calculating a Subnet Mask Based on Needed Host Addresses

    • To find out what prefix to assign an IP network based on the number of host addresses required for the network:

      • Determine how many host bits are needed to support the number of hosts specified

      • Subtract this number from the number of network bits

      • For example, for a network ID 172.16.16.0 that will support 60 hosts:

        • You need 6 bits for the host ID because 26=642^6 = 64 (which is the closest power of 2 to 60)

        • The prefix is 32 – 6 = 26

        • CIDR notation would be 172.16.16.0/26

Configuring IPv4 Addresses

  • Rules for IP address assignment:

    • A host can be assigned only a Class A, Class B, or Class C address

    • Every IP address configuration must have a subnet mask

    • All hosts on the same physical network must share the same network ID in their IP addresses

    • All host IDs on the same network must be unique

    • You can’t assign an IP address in which all the host ID bits are binary 0

    • You can’t assign an IP address in which all the host ID bits are binary 1

    • Computers assigned different network IDs can communicate only if a router is present to forward packets

    • The default gateway address assigned to a computer must have the same network ID as that computer

  • Windows OSs allow assigning multiple IP addresses to a single network connection, via the Advanced TCP/IP Settings dialog box.

  • Multiple IP addresses can be useful in these situations:

    • The computer is hosting a service that must be accessed by using different addresses

    • The computer is connected to a physical network that hosts multiple IP networks

  • A default gateway is almost always used in IP configurations.

  • The default gateway’s address must have the same network ID as the host’s network ID.

  • Using Multiple Default Gateways

    • Just as you can configure multiple IP addresses, multiple gateways can be configured

    • Windows attempts to select the gateway with the best metric automatically

      • Metric is a value assigned to the gateway based on the speed of the interface used to access the gateway

  • Using Multihomed Servers

    • A multihomed server has two or more NICs, each attached to a different IP network.

    • Each NIC requires its own IP address for the network to which it’s connected

    • Reasons for this type of configuration:

      • A server is accessed by internal clients and external clients

      • A server provides resources for computers on multiple subnets of the network

      • A server is configured as a router or VPN server

    • Multihomed servers can run into routing issues due to multiple default gateways being configured

  • Using the route Command

    • Windows computers maintain a routing table that dictates where a packet should be sent, based on the packet’s destination address

    • Typing route print displays the routing table

    • Results are displayed in five columns:

      • Network Destination

      • Netmask

      • Gateway

      • Interface

      • Metric

    • The route command can be used to change the routing table and to fix issues caused by using a multihomed server

Network Address Translation

  • Network Address Translation (NAT) allows an organization to use private IP addresses while connected to the Internet.

  • The NAT process translates a workstation’s private address (as a packet leaves the corporate network) into a valid public Internet address.

    • When data returns to the workstation, the address is translated back to the original private address.

  • NAT is usually handled by a network device connected to the Internet, such as a router.

  • Address translation is kept track of in a NAT table.

  • Port Address Translation (PAT) allows several hundred workstations to access the Internet with a single public Internet address.

  • Each packet contains source and destination IP addresses along with source and destination port numbers.

  • A single public IP address is used for all workstations, but different source port numbers are used for each communication session.

Internet Protocol Version 6

  • IPv4 was developed more than 40 years ago and is showing its age as its address space becomes used up.

  • IPv6 is the replacement for IPv4.

  • IPv6 addresses look very different from IPv4 addresses:

    • They have a built-in hierarchy and fields with a distinct purpose.

  • Methods have been developed to allow IPv4 and IPv6 networks to coexist and communicate with one another.

  • Originally named IPng (IP next generation), IPv6 was created in 1994 by the Internet Engineering Task Force (IETF)

  • IPv6 includes the following improvements:

    • Larger address space

    • Hierarchical address space

    • Autoconfiguration

    • Built-in Quality of Server (QoS) support

    • Built-in support for security

    • Support for mobility

    • Extensibility

IPv6 Address Structure

  • With IPv6, subnetting as done in IPv4 is no longer applicable.

  • IPv6 uses 128 bits, instead of IPv4’s 32 bits, for an address.

  • IPv6 addresses are written as eight 16-bit hexadecimal numbers separated by colons:

    • fe80:0:0:0:18ff:0024:8e5a:60

    • Things to note about IPv6 addresses:

      • One or more consecutive 0 values can be written as a double colon, but only one double colon can exist in an IPv6 address.

      • Leading 0s are optional (the value 0024 above could be written as 24).

      • Hexadecimal numbers are easier to convert to binary

  • The IPv6 Interface ID

    • The interface ID of an IPv6 is typically 64 bits and uses the interface’s 48 bit MAC address for a large portion of the address, as well as a 16 bit value of FF-FE that is inserted after the first 24 bits of the MAC address

    • An IPv6 interface ID can be assigned to a host in these ways:

      • Using the 48-bit MAC address

        • First two zeros in a MAC address are replaced with 02

        • This autoconfigured 64-bit host ID is referred to as an Extended Unique Identifier (EUI)-64 interface ID

      • A randomly generated permanent interface identifier

      • A temporary interface identifier

      • Via DHCPv6

      • Manually

Transitioning from IPv4 to IPv6

  • Technologies to help ease the transition to IPv6:

    • Dual IP architecture

    • IPv6-over-IPv4 tunneling

    • Intra-Site Automatic Tunnel Addressing Protocol (ISATAP)

    • 6to4

    • Teredo

Dual IP Layer Architecture

  • A dual IP layer architecture means that the computer can communicate directly with both IPv4 and IPv6 devices by using the native packet types.

  • Computers running either architecture can encapsulate IPv6 packets in an IPV4 header, a process called “tunneling”

IPv6-over-IPv4 Tunneling

  • Tunneling is a network protocol technique that allows transmitting a packet in a format that’s otherwise incompatible with the network architecture by encapsulating the packet in a compatible header format.

  • It’s needed when packets must traverse a network in which their protocol isn’t used.

  • IPv6-over-IPv4 tunneling allows a host to send an IPv6 packet over an IPv4 network to an IPv6 device

6to4 Tunneling

  • 6to4 provides automatic tunneling of IPv6 traffic over an IPv4 network.

  • It can provide host-to-router or router-to-host tunneling but is most often used to create a router-to-router tunnel.

  • The key to 6to4 tunneling is the 2002::/16 prefix:

    • Routers configured to perform 6to4 tunneling recognize the 2002 prefix as a 6to4 address.

  • The IPv4 address embedded in the 6to4 address must be a public address, which limits its use

Teredo Tunneling

  • Teredo is an automatic IPv6-over-IPv4 tunneling protocol that solves the problem of 6to4’s requirement of a public IPv4 address and the inability to traverse NAT routers

  • A Teredo address can be identified by the Teredo prefix 2001::/32 and has the following format:

    • 2001:tttt:tttt:gggg:pppp:xxxx:xxxx

    • The first 16 bits are always the Teredo prefix 2001

    • The next 32 bits, represented by t characters, are the Teredo server’s IPv4 public address

    • The next 16 bits, shown as g characters, are Teredo flags that specify processing options

    • The p characters represent an obscured UDP port the client uses for Teredo traffic

    • The last 32 bits are the obscured IPv4 address the client uses for Teredo traffic