Linux Networking Basics

Ayush Bhat
4 min readMar 16, 2023

--

In this blog we will discuss basics about Linux networking.

Source Internet

OSI Model

OSI Model stands for Open Systems Interconnection Model. This model was created :

  • To standardize the language used to describe networking protocols.
  • Defines the mechanism in which system communicate with one another.

Mnemonic used to remember the sequence of layers is : Please Do Not Throw Sausage Pizza Away

OSI Layer 1 Physical

  • This is the layer where “signals” are converted to information the system can use.
  • Deals with transferring of bits over a physical medium such as electric pulses over copper cables.

Frame : It is a unit of data collected from Layer 1 interface.

OSI Layer 2 Data Link Layer

  • Layer 2 is all about the hardware, setting and examining the network adapters
  • This layer accepts data from the hardware in layer 1 and adds an address to all inbound packets it accepts.
  • The address number is 6 bytes, 3 bytes for the manufacturer and 3 random bytes assigned to the adapter. This 6 byte address is also known as the MAC Address.
  • Here IP address and MAC Address are associated using ARP Protocol.
  • Common Data Link Layer Protocols are ARP, RARP, IPv4, STP

OSI Layer 3 Network Layer

  • This layer deals with routing and forwarding packets.
  • Information like IP address of destination are added in the front of our data in this layer.
  • Common layer 3 protocols are IPv4, IPv6, OSPF (Open Shortest Path First), ICMP (Internet Control Message Protocol) and IGRP (Interior Gateway Routing Protocol).

OSI Layer 4 Transport Layer

  • In this layer data is broken into manageable chunks
  • responsible for the end-to-end communication protocols
  • data is combined by defining source and destination port numbers
  • Common protocols used in this layer are TCP, UDP and SCTP
  • Transport protocols use ports to distinguish b/w different types of traffic. The ports are classed in three different ways: Well-Known Ports (0–1023), Expand Registered Ports (1024–49151) and Ephemeral Ports (49152–65535).

OSI Layer 5 Session Layer

  • Used for establishing, managing, synchronizing and termination of application connection b/w local and remote application
  • It tracks application processes this includes remote procedure calls
  • It is like building a session b/w local application and remote one
  • There are two types of sessions: connection-mode service and connectionless-mode sessions

OSI Layer 6 Presentation Layer

  • Some Services that are available at Presentation Layer are:
  • Data Conversion, Compression, Encryption/Decryption and Serialization

OSI Layer 7 Application Layer

  • This layer is the top of stack and deals with the protocols which make a global communication network.
  • Common Protocols used are HTTP, DNS, SMTP, FTP, DHCP

Internet Protocol

Two main functions of Internet Protocol are Addressing and Fragmentation

  • Addressing : Examines the address on the incoming packet and decides if the datagram is for the local system or for another system. If the address matches with the local system then headers are removed and datagram is forwarded to the next layer in protocol stack. Whereas if address not matched then the datagram is passed to the next system in the direction of the final system.
  • Fragmentation : Split the and re-assemble the packets if the path to the next system uses smaller transmission unit size.

IP Routing

Routing Processing

  • First, Data Link (MAC ) is examined to check if it matches the local machine’s hardware address
  • Then, the packet is examined for a match of the Destination IP address
  • If destination ip address matches then the packet is for local machine. This is done at Layer 3 Network(IP)
  • And packet is passed up to layer 4

More About IP Addressing

There are two major versions of IP : IPv4 and IPv6

IPv4 : It was the first major Internet Protocol version

Example : 192.168.29.16

IPv4 is 4 bytes == 32 bits, which gives 2³² (4,294,967,296) possible addresses.

IPv4 address space exhaustion raised concerns. To solve this problem there are few ways :

  • Move from Classed Networks to Classless Inter-Domain Routing
  • Move to IPv6
  • Invention of NAT

IPv6 : Designed to deal with the exhaustion of IPv4 addresses. It has 128 bit address size.

Addresses available in IPv6 Address

Yep ✨

Now using IPv6 we have a lot of addresses available

IP Address Parts

  • IP Address has 2 two parts Network Part and Host Part.
  • Network Part is indicated by value of netmask.
  • Host Part is the remaining part after host network part.

IP Subnetting : IP networks can be broken into smaller pieces by using a subnet.

IP Networking Classes : Back in early days of IPv4, IPv4 address were broken into following three classes:

Class A : 0.0.0.0/255.0.0.0

Class B : 128.0.0.0/255.255.0.0

Class C : 192.0.0.0/255.255.255.0

Networks which did not fit in a class B were often given a class A. This led to waste of IP addresses going to waste and creation of CIDR took place to resolve this problem.

--

--

Ayush Bhat

AWS SAA-C02 | Certified Kubernetes Administrator | Linux Foundation Certified Sysadmin | Ex294 RedHat Certified Engineer