Internet protocol specifics

Layer 3 IP protocol features

view on github

IP features

Table of contents

  1. IP addressing
  2. IP Routing
  3. ip utilities family

  • Network classes were formerly used to address layer 3 subnetworks depending on the number of nodes.

  • The subnet mask was then static and inferred from the address itself :

    Class Netmask Addresses
    A 255.0.0.0 0.0.0.0 - 127.255.255.255
    B 255.255.0.0 128.0.0.0 - 191.255.255.255
    C 255.255.255.0 192.0.0.0 - 223.255.255.255
    Multicast 240.0.0.0 224.0.0.0 - 239.255.255.255
  • However, this system was discontinued and replaced by CIDR based addressing and route aggregation.

  • In this context, specific address ranges are now reserved for addressing of private / isolated networks :

    Class Netmask Addresses
    A 255.0.0.0 10.0.0.0 - 10.255.255.255
    B 255.255.0.0 172.16.0.0 - 172.31.255.255
    C 255.255.255.0 192.168.0.0 - 192.168.255.255
  • Such addresses are not routable to the public internet : they are ignored by every public facing router.


IP Routing

  • IP packet routing is the selection of the next network hop with respect to the packet destination and the node's routing table.
  • IP packet forwarding is the process of writing packets to the interface configured for the selected next hop.
  • Every node in a layer 3 network segment performs both operations regardless of its hardware being optimized for that or not.
  • A routing table entry contains the following fields :
    • Destination : the destination network.
    • Netmask : subnet mask for the destination.
    • Gateway : IP address of the next hop node.
    • Interface : local interface for link-level communication with the next hop node.
    • Metric : routing metric for the current route.
  • The routing decision for an incoming IP packet is as follows :
    1. The kernel reads the destination address from the packet's IP header.
    2. The address is evaluated against the configured destination for each routing table entry.
    3. The entry whose destination has the longest matching prefix is selected as next hop.
    4. The packet is then forwarded to the gateway address of the selected entry.
  • In a node's routing table, destination networks can be either :
    1. Directly connected if a network interface has an IP address and subnet mask belonging to the destination network.
    2. Remote if packets have to be forwarded to another router in order to reach the destination network.
  • In large networks, routing table entries are automatically maintained using dynamic routing protocols.
  • If the routing tables are consistent across all nodes in a network, hop-by-hop packet forwarding suffices to transfer data from any node to any other node.

ip utilities family

  • Used to assign addresses to network devices and configure static routes if needed :
# print layer 2 installed NICs with MAC addresses
ip -h link list

# print ipv4 / ipv6 configured NICs with layer 3 ingress (RX) and egress (TX) statistics
ip -h -s --family inet address list
ip -h -s --family inet6 address list

# add an additional ip address to the loopback interface
sudo ip address add 192.168.10.10 dev lo

# print kernel TCP connections cache, resolve addresses to hostames
ip -h -r tcpmetrics list

# print layer 2 ARP cache for ipv4 interfaces
ip -h -family inet neighbour list

# print layer 3 detailed routing table entries for interface eth0
ip -d --family inet route list table all dev eth0

# resolve next hop to destination using routing table
ip route get 8.8.8.8

# monitor local network stack (unclear)
ip -d monitor all

# manage named network namespaces (copies of the kernel networking stack)
man ip-netns