Timedora

4 IP Addressing and Routing

Learn how IP addresses identify networks and interfaces, how subnetting organizes address space, and how routers select paths to forward packets.

IPv4 addressing and

An is a 32-bit identifier for a network interface, written as four decimal octets—for example, 192.168.10.25. A prefix length states how many leading bits identify the network. The prefix /24 corresponds to subnet mask 255.255.255.0, with 24 network bits and 8 host bits.

writes an address and prefix together as address/prefix. It supports any prefix length rather than requiring networks to use fixed class sizes.

Address counts and subnet boundaries

For an ordinary IPv4 subnet with prefix length pp:

Total addresses=232−p\text{Total addresses}=2^{32-p}
Ordinarily assignable host addresses=232−p−2\text{Ordinarily assignable host addresses}=2^{32-p}-2

The subtraction accounts for the network and broadcast addresses. This rule has exceptions: on /31 point-to-point links, both addresses can be used as endpoints.

To find subnet boundaries, calculate the block size by subtracting the relevant subnet-mask octet from 256256. For a /26 mask of 255.255.255.192, the block size in the last octet is 256−192=64256-192=64.

Dividing a /24 into four subnets

Starting with 192.168.10.0/24, borrowing two bits for creates four /26 subnets. Each has 64 total addresses and, under the ordinary subnet rule, 62 assignable host addresses.

  • 192.168.10.0/26: address range .0–.63, usable host range .1–.62, broadcast .63.

  • 192.168.10.64/26: address range .64–.127, usable host range .65–.126, broadcast .127.

  • 192.168.10.128/26: address range .128–.191, usable host range .129–.190, broadcast .191.

  • 192.168.10.192/26: address range .192–.255, usable host range .193–.254, broadcast .255.

Private IPv4 ranges

These IPv4 ranges are for internal networks. Their addresses are not globally unique and are not intended to be routed across the public Internet:

  • 10.0.0.0/8

  • 172.16.0.0/12

  • 192.168.0.0/16

IPv6 addressing

IPv6 uses 128-bit addresses written as eight groups of hexadecimal digits separated by colons. For example, 2001:db8:1234:1:0000:0000:0000:0025 can be shortened to 2001:db8:1234:1::25. Leading zeros within a group may be omitted, and one consecutive run of all-zero groups may be replaced by :: once in an address.

The range 2001:db8::/32 is reserved for documentation examples. A prefix such as 2001:db8:1234:1::/64 identifies a network prefix and an interface identifier.

IPv6 supports unicast, multicast, and anycast addresses, but does not use IPv4-style broadcast addresses. Link-local addresses use the fe80::/10 prefix and are used on a local link.

Routing tables and packet forwarding

A router examines a packet’s destination IP address and compares it with entries in its routing table. A route commonly records the destination prefix, the next hop if one is needed, the outgoing interface, and a metric or preference used to choose among route candidates.

The router applies : among routes that match the destination, it selects the route with the most matching leading bits. For a packet destined for 10.20.30.8, routes 10.0.0.0/8, 10.20.0.0/16, and 10.20.30.0/24 all match, but 10.20.30.0/24 is the most specific.

A simplified routing table might include these entries:

  • Destination 192.168.10.0/24: directly connected, outgoing interface LAN.

  • Destination 192.168.20.0/24: next hop 192.168.10.1, outgoing interface LAN.

  • Destination 0.0.0.0/0: next hop 192.168.10.254, outgoing interface LAN.

The 0.0.0.0/0 matches any IPv4 destination that is not matched by a more specific route. A router can also have the IPv6 ::/0.

Static and

A is entered by an administrator rather than learned from a routing protocol. It can be useful when a path is simple and stable, such as a small branch router’s route to a central network, or when configuring a deliberately. For example, a route to 192.168.20.0/24 could send packets to next-hop router 192.168.10.1.

For the route to work, the next hop must itself be reachable, and a return path must also exist. Static routes do not automatically adapt if a link or next-hop router fails unless tracking or failover mechanisms are configured.

has routers exchange reachability information and update routes as the network changes. A routing protocol chooses or advertises paths, while packet forwarding still uses the installed routing table. can reduce manual updates in larger or changing networks, but requires correct configuration and appropriate route filtering.

Broad dynamic-routing approaches

  • A shares route and distance information with neighbors. RIP is a classic example; it uses hop count as its metric and has a maximum usable metric of 15.

  • A distributes information about network links so routers can build a topology database and calculate paths. OSPF is a link-state interior gateway protocol used within an autonomous system.

  • advertises paths between autonomous systems. BGP is the principal inter-domain routing protocol; policy and path attributes help determine which routes are selected and advertised.

A protocol’s computed preference or metric helps select among learned candidate routes. Once routes are installed, forwarding uses the best matching prefix. The most specific matching route wins; how candidate routes for the same prefix are compared can depend on the protocol and device configuration.

Applying the routing rules

For 192.168.40.0/27, the subnet contains 232−27=322^{32-27}=32 total addresses. Under the ordinary subnet rule, 32−2=3032-2=30 are assignable to hosts.

For destination 172.16.10.7, each of 172.16.0.0/12, 172.16.8.0/21, and 172.16.10.0/24 matches, but 172.16.10.0/24 is the most specific route. If no more-specific route matches a destination, the provides a next hop for it.

The three broad dynamic-routing approaches correspond to these descriptions: sharing distance information with neighbors is distance vector; calculating paths from shared link-state information is link state; and advertising paths between autonomous systems is path vector.