Linux Network Services

What is L1, L2, L3, and L4 in networking?

Explains the first four OSI layers in plain language: physical cabling, data link frames, IP addressing and routing, and transport ports with TCP or UDP.

On this page
  1. The OSI model in brief
  2. Layer 1: physical
  3. Layer 2: data link
  4. Layer 3: network
  5. Layer 4: transport
  6. Layers 5 to 7
  7. Layers in the TCP/IP model
  8. Using layers when troubleshooting

Network engineers often describe devices and problems by layer. A phrase like “layer 2 switch” or “layer 3 router” only makes sense once you know what each layer does. In this context, L stands for layer. This article explains L1 to L4, the first four layers of the OSI model, with everyday examples for each.

The OSI model in brief

The OSI reference model splits network communication into seven layers. It is a teaching and troubleshooting model rather than a strict description of every network. Each layer handles one job and passes its data to the layer above or below it. Lower numbers sit closer to the physical wire or radio signal, and higher numbers sit closer to the applications you use.

Layer Name Unit of data Everyday examples
1 Physical Bits Cables, fiber, Wi-Fi radio, network cards
2 Data link Frames MAC addresses, Ethernet, switches
3 Network Packets IP addresses, routers
4 Transport Segments (TCP) or datagrams (UDP) Port numbers, TCP, UDP

Layer 1: physical

Layer 1 is about moving raw bits across a medium. It covers twisted-pair cables such as Cat5e or Cat6, fiber optics, the radio signals of Wi-Fi, connectors, and the electrical or optical details of network cards. Simple devices that work only at this layer, such as hubs, repeat signals without looking at the data. A cable that is unplugged or damaged is usually a layer 1 problem.

Layer 2 organizes bits into frames and moves them between devices on the same local network. Ethernet and Wi-Fi both use layer 2 framing. Devices are identified here by MAC addresses, which are hardware-based addresses on network cards, although an operating system can sometimes change them. Switches work at this layer. The frame check sequence lets the receiver detect many damaged frames.

Layer 3: network

Layer 3 moves packets between networks, not only within one. IP addresses live here, and routers use them to choose where a packet goes next. IPv4 and IPv6 are the two common versions. When someone says a device has an IP address, they mean its layer 3 identity.

Layer 4: transport

Layer 4 handles delivery between applications on two machines. Port numbers tell the receiving computer which application should get the data. TCP sets up a connection, keeps data in order, and resends what gets lost. UDP sends datagrams without those guarantees, which suits lookups and some real-time traffic. Many readers wonder: is TCP layer 3 or 4? It is layer 4, the transport layer. Web traffic over HTTPS usually uses TCP port 443, and DNS queries commonly use UDP port 53.

Layers 5 to 7

The OSI model continues with the session, presentation, and application layers. Those cover higher-level concerns such as how applications open and format their conversations. The article on what are the 7 network layers and their functions covers the upper layers in more detail.

Layers in the TCP/IP model

The TCP/IP model used across the internet groups these functions into four layers, so the layer numbers differ between models. When a source says “layer 3,” check whether it means the OSI model or TCP/IP before you rely on it.

Using layers when troubleshooting

Checking from the bottom up is a common habit:

  1. Confirm the cable, Wi-Fi link, or interface is up (layers 1 and 2). ip link show displays interface state.
  2. Confirm the address and route look right (layer 3). ip addr show and ip route show display them.
  3. Confirm the service answers on its port (layer 4). Run sudo ss -tulpn on the server, or test with curl from another machine.

Each step narrows the cause. A working ping does not prove that an application is running, and a running service does not prove the cable is good.

The complete guide to linux network services

Internet and Network Services in Linux Explained
Read the guide

Keep exploring

Guides from other topics

All topics →