Network security

Network Layer in the OSI Model: Layer 3 Explained Simply

Layer 3 is where your data leaves the local network and finds its way across the internet. Here is how addressing, routing and forwarding actually work.

Cysoro Security TeamPublished · 8 min read
NETWORK SECURITY Layer 3 Network How packets cross the internet. IP addressing, routing and forwarding PACKET JOURNEY R1 R2 R3 From: 192.0.2.10 To: 203.0.113.5 Hop by hop CYSORO
Quick answer

The network layer is Layer 3 of the seven-layer OSI model. It moves variable-length packets from a source host to a destination host across one or more networks, using logical IP addresses to identify hosts and routers to choose the best path. Its core jobs are logical addressing, routing, packet forwarding, and fragmentation and reassembly.

Key takeaways

  • Layer 3 moves packets between networks; Layer 2 only moves frames inside one local network.
  • IP addresses are logical and hierarchical, which is what makes internet-scale routing possible.
  • Routers, routing protocols and ICMP are the network layer's main tools, and its main security risks are spoofing and route hijacking.

Every email, video call and web page you open crosses many networks before it reaches you. The network layer is the part of the OSI model that makes that journey possible: it gives every device a logical address and works out how each packet gets from here to there.

What is the network layer in the OSI model?

The network layer is Layer 3 of the seven-layer OSI model of computer networking. It is responsible for packet forwarding, including routing through intermediate routers, moving variable-length packets from a source host to a destination host via one or more networks.

It sits between the data link layer (Layer 2) below and the transport layer (Layer 4) above. It responds to service requests from the transport layer and issues service requests to the data link layer. In plain terms: the transport layer hands it a chunk of data for a distant host, and the network layer works out how to get it there.

The classic analogy is postal addressing. Layer 2 is like delivering a letter inside one building using room numbers. Layer 3 is like the postal system: it uses a full address with street, city and country, so a letter can cross many towns and still arrive. IP addresses play the role of that full address.

What are the functions of the network layer?

The network layer has five core functions: logical addressing, routing, forwarding, fragmentation and reassembly, and error reporting. Each one solves a problem that appears as soon as data leaves a single local network.

Logical addressing gives every host a unique address that determines where it is. On the internet, these are IP addresses, assigned from a hierarchical system so routers can summarize whole groups of addresses instead of memorizing every device. That hierarchy is what lets the internet scale to billions of hosts.

Routing determines the best path for packets, using routing tables and algorithms. Forwarding is the per-packet act of sending each packet to its next hop. Fragmentation breaks IPv4 packets that are larger than a link's maximum transmission unit into smaller pieces, and the destination host reassembles them. Error reporting, mainly through ICMP, tells senders when delivery fails.

Where Layer 3 sits in the OSI model 7 Application 6 Presentation 5 Session 4 Transport — segments, TCP / UDP 3 Network — packets, IP, routing 2 Data link — frames, MAC, switches 1 Physical — bits, cables, radio Layer 3 is the first layer that thinks about the whole network, not just one link.
The seven OSI layers, with the network layer highlighted. Illustration by Cysoro.

How does the network layer work?

The process starts when an application sends data. The transport layer turns it into a segment, and the network layer encapsulates that segment into a packet, adding a header with the source and destination IP addresses. That packet is then handed to the data link layer for delivery to the first router.

Each router on the path reads the destination IP address in the header and looks it up in its routing table. The table says which outgoing interface leads toward that destination network, and the router forwards the packet to the next hop. The packet is forwarded hop by hop until it reaches the destination network, where the final router delivers it to the host.

RFC 791, which specifies IPv4, puts it simply: the internet protocol implements two basic functions, addressing and fragmentation, and the selection of a path for transmission is called routing. It also notes that IP treats each datagram as an independent entity, with no connections, no acknowledgments and no retransmissions. Reliability is left to higher layers such as TCP.

How does IP addressing work at Layer 3?

IP addresses are logical addresses, unlike MAC addresses, which are physical addresses burned into network hardware. A MAC address identifies a network card; an IP address identifies where a device sits in the network, and it can change when the device moves.

IPv4 addresses are 32 bits long, written as four decimal numbers, for example 192.0.2.10. IPv6 addresses are 128 bits long, written in hexadecimal, which provides a vastly larger address space. RFC 8200 specifies IPv6, which was designed because the IPv4 space was running out.

Addresses are hierarchical. The network part identifies the network, and the host part identifies the device inside it. Routers use the network part to make forwarding decisions without knowing every host, and subnetting with CIDR notation lets networks be split and summarized efficiently. Private address ranges, used inside homes and offices, are translated to public addresses at the network boundary, usually by NAT.

How does routing work at the network layer?

Routing protocols let routers learn about the network around them and build their tables. Interior protocols such as OSPF and EIGRP run inside one organization or autonomous system, while BGP, the Border Gateway Protocol, runs between autonomous systems and is what holds the internet together.

OSPF is a link-state protocol: routers share the state of their links, build a complete map of the area, and compute the shortest path. BGP is a path-vector protocol: networks advertise the routes they can reach, along with the path of autonomous systems to get there.

Each network applies its own policy to choose between advertised routes. RIP, one of the oldest protocols, picks routes by hop count and is now rarely used in large networks.

Path choice considers metrics such as hop count, bandwidth, latency and administrative policy. When a link fails, routers exchange updates and converge on new paths. That self-healing behavior is a large part of why the internet keeps working when parts of it break.

Which protocols operate at the network layer?

IPv4 and IPv6 carry the data, but several supporting protocols make the layer work. ICMP, the Internet Control Message Protocol, reports delivery problems and supports diagnostics such as ping and traceroute. IGMP manages multicast group membership, so a host can join a multicast stream. IPsec adds encryption and authentication at the network layer, protecting traffic regardless of the application.

ProtocolJobWhat it carries
IPv4 (RFC 791)Addressing and delivery32-bit addresses, packets
IPv6 (RFC 8200)Addressing and delivery128-bit addresses, packets
ICMPError reporting, diagnosticsEcho, unreachable, time-exceeded messages
IGMPMulticast membershipGroup join and leave messages
OSPFInterior routingLink-state updates inside one network
BGPInternet routingPath advertisements between networks
IPsecEncryption, authenticationProtected packets at Layer 3

One common point of confusion is ARP, the Address Resolution Protocol. ARP maps an IP address to a MAC address so a packet can be handed to the data link layer, but it is generally considered a link-layer helper, not a network-layer protocol itself.

Network layer vs data link layer: what is the difference?

Layer 2 and Layer 3 are easy to confuse because both move data, but they work at different scales. Layer 2 moves frames inside a single network segment, using MAC addresses that only have meaning locally. A switch learns which MAC address lives on which port and forwards frames accordingly.

Layer 3 moves packets between networks, using IP addresses that have meaning everywhere. A router reads the destination IP, consults its routing table, and forwards the packet toward another network. Without Layer 3, every device would need a direct connection to every other device it wanted to reach.

A useful test: if the destination is on the same local network, Layer 2 alone can deliver the frame. If the destination is anywhere else, the packet must go through a router, and Layer 3 takes over. Most home networks cross that boundary every time you open a website.

What is fragmentation and why does it matter?

Every network link has a maximum transmission unit (MTU), the largest packet it can carry. If an IPv4 packet is larger than the smallest MTU on its path, routers fragment it into smaller pieces, and the destination host reassembles them.

IPv6 works differently: routers do not fragment packets in transit. Instead, the sender must discover the path MTU before sending, using Path MTU Discovery. That shifts fragmentation work to the endpoints and keeps routers simpler and faster.

Fragmentation matters for security too. Fragmented packets have been used to evade firewalls and intrusion detection, because a firewall may only inspect the first fragment closely. Modern firewalls reassemble fragments before inspecting them, but the attack history is why fragmentation shows up in so many network security checklists.

What are the security risks at the network layer?

The network layer was designed when the internet was a small research network, so its core protocol, IP, has no built-in authentication. That gap creates several well-known risks. IP spoofing lets an attacker forge the source address of a packet, hiding their origin or impersonating a trusted host. Route hijacking, usually through BGP, lets a network falsely announce that it owns address space, diverting traffic to itself.

ICMP can also be abused for reconnaissance and denial of service, which is why many networks rate-limit or filter some ICMP messages while keeping ping and error reporting working. And because IP itself does not encrypt anything, anyone who can observe the path can read unencrypted packet contents, which is why encryption belongs at higher layers or through IPsec and VPNs.

One packet, four hops: how Layer 3 delivers data Laptop192.0.2.10 R1 R2 R3 Server203.0.113.5 Each router reads the destination IP, checks its routing table, and forwards to the next hop. The packet header stays the same; only the link-layer frame changes at each hop.
Hop-by-hop forwarding: each router moves the packet one step closer. Illustration by Cysoro.

The defenses are layered: use IPsec or a VPN for sensitive traffic, filter spoofed source addresses at your network edge, monitor BGP announcements for your address space, and keep ICMP filtering sensible rather than blocking it entirely.

You can check what your own public address looks like with the what is my IP tool.

Confirm your domain's DNS records with the DNS lookup tool.

How do you troubleshoot network layer problems?

Start with the address. Confirm the device has an IP address, a subnet mask and a default gateway, and that it can reach the gateway with ping. If it cannot, the problem is local: a cable, a Wi-Fi link, or a DHCP failure.

If the gateway answers but the destination does not, use traceroute to see how far packets travel. A traceroute that stops at a particular router points at that router or the link after it. Compare the result with a known-good destination to tell a local problem from an internet-wide one.

Check the routing table on the affected host or router. A missing or wrong route is a common cause of "the internet is down" complaints that are really "this one network is unreachable". And remember that a successful ping only proves the network layer works; a web page that still fails points at the transport or application layer instead.

The bottom line

The network layer is the layer that turns a collection of local networks into an internet. Logical addressing gives every host a place in the hierarchy, routing works out the paths, and forwarding moves each packet hop by hop until it arrives.

If you remember one thing, make it the Layer 2 versus Layer 3 test: same local network, Layer 2; anywhere else, Layer 3 and a router. That single distinction explains most of what a home or office network does every day. You can see your own public address and check your domain's records with the what is my IP tool.

Frequently asked questions

What is the network layer in the OSI model?

The network layer is Layer 3 of the OSI model. It is responsible for moving packets from a source host to a destination host across one or more networks, using logical addressing and routing through intermediate routers.

What is the main function of the network layer?

Its main function is packet forwarding, including routing: deciding the best path for each packet and sending it hop by hop toward its destination. Logical addressing with IP addresses makes that possible.

Which protocols work at the network layer?

The main ones are IPv4 and IPv6, plus ICMP for error reporting, IGMP for multicast group management, and routing protocols such as OSPF, BGP, EIGRP and RIP. IPsec also operates at this layer.

What is the difference between Layer 2 and Layer 3?

Layer 2 moves frames inside a single local network using physical MAC addresses. Layer 3 moves packets between networks using logical IP addresses. A switch works mainly at Layer 2; a router works at Layer 3.

What is a packet in the network layer?

A packet is the unit of data at Layer 3: a header containing source and destination IP addresses plus the payload from the transport layer. Routers read the header to decide where each packet goes next.

What is routing vs forwarding?

Routing is deciding the path: routers exchange information and build routing tables. Forwarding is the act of sending a packet to the next hop using that table. Routing creates the map; forwarding moves the traffic.

Is the network layer the same as the internet layer?

Not exactly, but they do the same core job. The TCP/IP model's internet layer is the layer that moves packets between networks on the internet, using IP to address and route them, which is the network layer's function in OSI terms. The OSI network layer is the broader concept, covering any network architecture, while the internet layer describes the internet's specific approach with IP.

Sources

  1. RFC 791 — Internet Protocol
  2. RFC 8200 — Internet Protocol, Version 6 (IPv6) Specification
  3. RFC 1112 — Host Extensions for IP Multicasting (IGMP)
  4. Exabeam — OSI Layer 3: Core Functions, Protocols and Security Best Practices
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against RFC 791 (IPv4), RFC 8200 (IPv6), RFC 1112 (IGMP) and Exabeam's OSI Layer 3 explainer.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free