IPv4 - Internet Protocol version 4 ==================================== .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is IPv4?** IPv4 stands for Internet Protocol version 4. It is the fourth version of the Internet Protocol and the most widely used protocol for identifying devices on a network using a 32-bit address. Each device on a network is assigned a unique IPv4 address to enable communication. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is IPv4 useful?** * Identifying devices on a network * Routing data between devices across networks * Enabling internet communication .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works?** * Device gets an IP address – Either manually or via DHCP. * Data is sent with IP headers – Each packet includes source and destination IPv4 addresses. * Routers forward packets – Based on the destination IP, routers direct the packet toward its target. * Target device receives data – The device with the matching IP address processes the packet. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is IPv4 used?** * Home networks – Routers assign IPv4 addresses to phones, laptops, TVs, etc. * Enterprise networks – Servers, workstations, and printers use IPv4 for communication. * Internet – Every website, server, and online service uses IPv4 (or IPv6) to identify and communicate with devices. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI Layer does IPv4 operate at?** * IPv4 operates at the **Network Layer (Layer 3)** of the OSI model. * It handles logical addressing and routing between different networks. * It is responsible for packet forwarding, including routing through intermediate routers. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is IPv4 windows specific?** * No. * IPv4 is a universal Internet Protocol standard used across all major operating systems, including Windows, Linux, macOS, and others. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is IPv4 linux specific?** * No. * IPv4 is not specific to Linux; it is a fundamental protocol used globally on all platforms. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Transport Protocol is used by IPv4?** * IPv4 itself is a Network Layer protocol (Layer 3). * It supports transport protocols like TCP, UDP, and ICMP over it, but IPv4 is not built on top of transport protocols. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Port is used by IPv4?** * IPv4 does not use ports directly. * Ports are used by Transport Layer protocols (like TCP and UDP) which run over IPv4. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is IPv4 using Client server model?** * No. * IPv4 is a network layer protocol for addressing and routing; it does not implement a client-server model. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the address range of IPv4?** * IPv4 addresses are 32 bits long, represented as four decimal numbers (octets) separated by periods. * The address range is from **0.0.0.0** to **255.255.255.255**. * This gives a total of approximately 4.3 billion unique addresses. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is an IPv4 subnet mask?** * A subnet mask is used to divide an IPv4 network into smaller subnetworks. * It determines which portion of an IP address refers to the network and which part refers to the host. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the purpose of IPv4 CIDR notation?** * Classless Inter-Domain Routing (CIDR) is used to allocate IP addresses more efficiently. * CIDR notation uses a slash (`/`) followed by a number to represent the number of bits used for the network portion of the address (e.g., 192.168.1.0/24). .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the difference between public and private IPv4 addresses?** * Public IP addresses are globally routable and can be used over the internet. * Private IP addresses are used within private networks and are not routable over the internet. * Private IP ranges include: - **10.0.0.0 to 10.255.255.255** - **172.16.0.0 to 172.31.255.255** - **192.168.0.0 to 192.168.255.255** .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is an IPv4 gateway?** * A gateway is a device that routes traffic between different networks. * In home and small office networks, the gateway is often the router that connects to the internet. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is NAT (Network Address Translation)?** * NAT allows multiple devices on a local network to share a single public IP address. * It translates private IP addresses to public ones when packets are sent out to the internet. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How to find public IP address on any machine?** * **Web Services:** Visit websites like [whatismyipaddress.com](https://www.whatismyipaddress.com) or [ipinfo.io](https://ipinfo.io). * **Command Line:** - **Linux/Mac:** `curl ifconfig.me` or `curl ipinfo.io/ip` - **Windows:** `nslookup myip.opendns.com resolver1.opendns.com` * **Router/Gateway Interface:** Log into your router’s admin page (typically 192.168.1.1) and check the WAN/Internet section. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is an IPv4 broadcast address?** * The broadcast address is used to send data to all devices in a network. * In IPv4, the broadcast address for a subnet is determined by setting all the host bits to 1. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the ARP protocol in IPv4?** * The Address Resolution Protocol (ARP) maps an IP address to a MAC address. * ARP is used by IPv4 devices to identify the hardware address of other devices on the same network. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is an IPv4 routing table?** * A routing table is used by routers to determine where to send packets based on the destination IP address. Use ip route on ubuntu to see routing table. * It contains entries for networks and associated next-hop addresses. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the role of DNS in IPv4?** * The Domain Name System (DNS) translates human-readable domain names (like `example.com`) into IP addresses. * DNS ensures that users can access websites by using easy-to-remember names instead of IP addresses. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the difference between IPv4 and IPv6?** * IPv4 uses a 32-bit address space, while IPv6 uses a 128-bit address space, allowing for a much larger number of unique addresses. * IPv6 also includes improvements in security, routing efficiency, and mobility. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the role of DHCP in IPv4?** * The Dynamic Host Configuration Protocol (DHCP) assigns dynamic IP addresses to devices on a network. * DHCP helps reduce the need for manual configuration of IP addresses. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is an IPv4 address conflict?** * An address conflict occurs when two devices on the same network are assigned the same IP address. * This can cause network communication issues and prevent devices from accessing the network. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is IPv4 packet structure?** * IPv4 packets consist of a header and data. The header contains information such as the source and destination IP addresses, time-to-live (TTL), and protocol type. * The packet is used to encapsulate data for transmission across the network. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the Time-to-Live (TTL) field in IPv4?** * The TTL field indicates the maximum number of hops a packet can make before being discarded. * It is used to prevent packets from circulating endlessly in case of routing loops. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is IPv4 fragmentation?** * Fragmentation allows large packets to be broken into smaller pieces to fit the MTU (Maximum Transmission Unit) of the network. * Each fragment is transmitted separately and reassembled at the destination. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the role of ICMP in IPv4?** * The Internet Control Message Protocol (ICMP) is used for network diagnostics (e.g., `ping`) and error reporting. * It allows devices to report issues with packet delivery and network reachability. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is IPv4 anycast?** * Anycast is a communication method where a packet is delivered to the nearest device (or the device with the smallest number of hops) that shares the same IP address. * It is commonly used for load balancing and redundancy in network services. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`IPv4 Version&RFC Details ` * :ref:`IPv4 Basic Setup on Ubuntu using IPv4 ` * :ref:`IPv4 Protocol Packet Details ` * :ref:`IPv4 Usecases ` * :ref:`IPv4 Basic Features ` * :ref:`Reference links ` .. _IPv4_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _IPv4_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _IPv4_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _IPv4_step5: .. tab-set:: .. tab-item:: IPv4 Version&RFC Details .. csv-table:: :file: ./ipv4/IPv4_Version_RFC_details.csv :widths: 10,10,10,30 :header-rows: 1 .. _IPv4_step21: .. tab-set:: .. tab-item:: IPv4 Basic Setup on Ubuntu using IPv4 **Basic IPv4 Protocol Implementation** verify that two laptops with manually assigned IPv4 addresses can communicate using the ICMP protocol, and to observe the correct packet flow. **Test Setup** * Laptop 1 * Assign the IPv4 address 192.168.1.10 to the enp0s8 interface. .. code-block:: shell test:~$ sudo ip addr add 192.168.1.10/24 dev enp0s8 test:~$ sudo ip link set enp0s8 up * Laptop 2 * Assign the static IPv4 address 192.168.1.100/24 to the network interface enp0s8. .. code-block:: shell test:~$ sudo ip addr add 192.168.1.100/24 dev enp0s8 test:~$ sudo ip link set enp0s8 up **Procedure** * Step-1 : Test Connectivity * From Laptop 2, initiate a network ping to Laptop 1's IP address (192.168.1.10). .. code-block:: shell test:~$ ping 192.168.1.10 PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data. 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=2.67 ms 64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=0.568 ms 64 bytes from 192.168.1.10: icmp_seq=3 ttl=64 time=0.881 ms 64 bytes from 192.168.1.10: icmp_seq=4 ttl=64 time=0.839 ms 64 bytes from 192.168.1.10: icmp_seq=5 ttl=64 time=1.03 ms 64 bytes from 192.168.1.10: icmp_seq=6 ttl=64 time=1.21 ms 64 bytes from 192.168.1.10: icmp_seq=7 ttl=64 time=1.12 ms 64 bytes from 192.168.1.10: icmp_seq=8 ttl=64 time=8.48 ms 64 bytes from 192.168.1.10: icmp_seq=9 ttl=64 time=0.886 ms 64 bytes from 192.168.1.10: icmp_seq=10 ttl=64 time=1.05 ms ^C --- 192.168.1.10 ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 9101ms rtt min/avg/max/mdev = 0.568/1.873/8.483/2.268 ms * Step-2 : Observe Packets with Wireshark * Simultaneously, use Wireshark to capture network traffic on either laptop * Apply a filter for ICMP packets to focus on the ping traffic. .. note:: * ICMP is the Internet Control Message Protocol, which is used by ping to send echo requests and receive replies. **Analysis of Packets** * Request and Reply * The first packet will be an Echo (ping) request originating from ``192.168.1.100`` and destined for ``192.168.1.10``. * The second packet will be an Echo (ping) reply, originating from ``192.168.1.10`` and destined for ``192.168.1.100``. This pattern confirms successful two-way communication. * Packet Details * Frame : Shows information about the physical layer. * Ethernet : Displays the Source MAC Address (Laptop 2) and Destination MAC Address (Laptop 1). * Internet Protocol Version 4 (IPv4) : Shows the Source IP (``192.168.1.100``) and Destination IP (``192.168.1.10``). * ICMP : Contains the specific type and code that identify the packet as an Echo request or reply. .. note:: * The Time to Live (TTL) in the IPv4 header is a value that indicates the maximum number of hops a packet can take before it is discarded. **Wireshark Capture** :download:`Download wireshark capture ` .. _IPv4_step6: .. tab-set:: .. tab-item:: IPv4 Protocol Packet Details **IPv4 Packet** .. csv-table:: :file: ./ipv4/IPv4_Packetdetails1.csv :widths: 10,20,30,10 :header-rows: 1 .. _IPv4_step7: .. tab-set:: .. tab-item:: IPv4 Usecases .. csv-table:: :file: ./ipv4/IPv4_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _IPv4_step8: .. tab-set:: .. tab-item:: IPv4 Basic Features .. csv-table:: :file: ./ipv4/IPv4_Basic_Features.csv :widths: 10,10,30 :header-rows: 1 .. _IPv4_step20: .. tab-set:: .. tab-item:: Reference links * Reference links