How Networks Transfer Data: Switches, Routers and IP Addresses
Why Should You Care How Data Travels?
Every time you visit a website, stream a video, or send a message online, your data goes on a journey — quietly, behind the scenes, in just milliseconds. But that journey involves a lot more than just “connecting to Wi-Fi” or “having internet.”
It starts with your device (called a client) and ends in a remote device (called a server) — like a website you want to visit. But between these two points, there’s a complex process of lookups, decisions, routing, switching, and translations that make the whole thing work.
We already explored the basics of the internet’s components — like clients, servers, switches, routers, and cables — in our article Internet Infrastructure Components: The Basics.
We also laid the foundation in Foundations of LAN & WAN and Foundations of Subnetting — both essential for understanding what comes next.
Now it’s time to connect the dots and dive deeper into how it all works together in real time.
Why This Matters
Understanding how data flows across a network isn’t just for IT professionals. Once you learn what’s supposed to happen when you open a website or send a file, you’ll start to recognize what’s normal — and what’s suspicious.
This is crucial if you care about:
- Online security
- Digital privacy
- Network performance
- Avoiding cyberattacks
Once you understand how data legitimately flows, you'll see how hackers often try to exploit that very process — and what you can do to protect yourself. This is your first step toward becoming a more informed and secure internet user.
Getting Ready: What Must Happen Before You Can Browse the Web
Before any website loads, before any message is sent, your device needs something essential — a proper network configuration. Whether you're accessing Netflix, sending files to your home printer, or logging into a company wiki or ticketing system, your device must be configured correctly to start the journey.
There are four must-have pieces of information that every device needs to connect to a network — whether it's a personal laptop, a corporate server, personal mobile, tablet, camera or even your car.
1. IP Address
This is your device’s unique identity on the network. It must fall within the correct range based on how the network is designed.
- In homes, your router usually handles this automatically.
- In corporate networks, IP ranges are carefully planned across departments or floors.
You can get this:
- Automatically using DHCP (Dynamic Host Configuration Protocol)
- Manually, by assigning a static IP in your settings
2. Subnet Mask
This defines which part of the IP address belongs to the network, and which part is available for your specific device (the client).
It tells your device, “Hey, here’s who’s local and who’s not.” Most home networks use /24 subnet mask: 255.255.255.0
3. Default Gateway
This is your door to the outside world — usually the IP address of your home router or the corporate router. Any network communication your device wants to send outside the local area network (LAN) is sent to the default gateway, which knows how to reach beyond the local network.
4. DNS Server
DNS (Domain Name System) is like your internet's phonebook. When you type in your browser www.netflix.com, your device asks the DNS server, “What’s the IP address of this domain?” Then it uses the result to connect.
You can use:
- An internal DNS server (common in companies)
- Or a public DNS server like:
- Google: 8.8.8.8
- Cloudflare: 1.1.1.1
These four settings can be:
- Assigned automatically via DHCP protocol (which most people use at home and in organizations by default)
- Or configured manually for devices that need fixed settings (like printers or servers)
Hands-On Practice: Check Your Network Settings on Windows
There are two easy ways to view your network configuration on a Windows device: using the Command Prompt or the Graphical User Interface (UI) — which is just the menu system you click through (instead of typing commands).
Option 1: Use the Command Prompt
- Press Windows + R, type cmd, and hit Enter.
- In the black terminal window that opens, type the following and hit Enter: ipconfig /all
- You’ll see detailed information about all your network interfaces:
- IPv4 Address – your current IP
- Subnet Mask - your current subnet mask
- Default Gateway - your current default gateway
- DNS Servers - your current DNS servers
This is the fastest way to get a full status of your current network interface setup.
Option 2: Use the Settings Menu (UI Method)
This method is more visual and beginner-friendly:
- Press the Start button and open Settings.
- Go to Network & Internet.
- Click on either Wi-Fi or Ethernet, depending on your connection.
- Select your active connection (usually labeled with your network name).
- Click the arrow down icon (▾) next to your network to expand settings.
- Scroll down and click Edit under IP Assignment or DNS Server Assignment.
- In the pop-up window:
- Switch the setting to Manual using the dropdown menu.
- Toggle IPv4 (commonly used) to On.
- Fill in the required fields:
- IP address
- Subnet mask
- Gateway
- Preferred DNS
This manual setup is usually only needed for advanced users or specific networks (like corporate environments or static IP configurations).
Hands-On Practice: Check Your Network Settings on macOS or Linux
Just like Windows, macOS and Linux also provide two main ways to view or change your network configuration — through the Terminal (command-line) or the System Settings (UI).
Option 1: Use the Terminal
macOS:
- Open Terminal (You can find it via Spotlight: press Cmd + Space and type Terminal).
- Type: ifconfig
or for a simpler IP readout: ipconfig getifaddr en0
(“en0” is usually the Wi-Fi interface; Ethernet is often “en1”, but run ifconfig to confirm). - To view DNS info, type: scutil --dns
Linux:
- Open your Terminal.
- Type: ip a or ifconfig
Note: If ifconfig is not installed, use sudo apt install net-tools first. - To view DNS settings, type:
cat /etc/resolv.conf
Option 2: Use the Graphical Settings (UI Method)
macOS:
- Click the Apple menu → System Settings (or System Preferences on older versions).
- Go to Network.
- Select your active connection (Wi-Fi or Ethernet).
- Click Details… or the small “i” icon.
- You’ll find:
- IP Address
- Subnet Mask
- Router (Default Gateway)
- DNS Servers
- To edit these manually:
- Click Configure IPv4 and choose Manually.
- Enter your IP, Subnet Mask, and Default Gateway.
- Under DNS, add or update entries like 8.8.8.8 or 1.1.1.1.
Linux (Ubuntu/GNOME example):
- Click on the network icon in the top-right corner.
- Select Settings or Network Settings.
- Choose the active connection (Wi-Fi or Wired) and click the gear icon.
- Under the IPv4 tab:
- You’ll see your IP Address, Netmask, and Gateway.
- Switch from Automatic (DHCP) to Manual to input custom values.
- Under the DNS section, add servers like:
- Google: 8.8.8.8
- Cloudflare: 1.1.1.1
The Journey Begins: What Happens Once You Visit a Website
Once all four mandatory configurations are in place, your device is officially ready to interact with services across the network — whether that’s within a local area network (LAN) or a wide area network (WAN). From this point forward, we’ll stick with the simpler terms LAN and WAN for clarity.
Let’s walk through a familiar example: visiting wikipedia.org on your phone.
To access wikipedia.org, you need an app that can communicate over the internet — like Chrome browser, which you’ve likely installed yourself. Once you tap the Chrome icon, the app launches. If your homepage is set to wikipedia.org, the site’s landing page appears almost instantly.
But what’s actually happening behind the scenes to make that possible?
Let’s break it down — step by step.
Once the homepage settings are already configured, the browser — in this case, the Chrome app — knows exactly what to do when it launches. That homepage setting is just a saved website name, or in technical terms, a URL (Uniform Resource Locator). Let’s say it’s set to wikipedia.org.
When you tap the Chrome icon, the browser opens and starts loading your homepage. But what does “loading” really mean?
The browser begins by filling in the saved website address — wikipedia.org. However, here’s the catch: the internet doesn’t work based on names. It runs on IP addresses.
So how does your browser turn a name like wikipedia.org into something the internet can understand?
That’s where DNS (Domain Name System) comes in.
Step 1: DNS Resolution — Turning Names into Numbers
The browser doesn’t know the IP address of wikipedia.org on its own. Instead, it relies on your phone’s operating system (like iOS on iPhones or Android on other devices) to figure it out.
Here’s what happens:
- The Chrome app asks the operating system: “Hey, what’s the IP address of wikipedia.org?”
- The OS checks its current network settings to see what DNS server is configured — this could be a public DNS like 8.8.8.8 (Google) or 1.1.1.1 (Cloudflare).
- Then, the OS sends a request to that DNS server: “What’s the IP address of wikipedia.org?”
- The DNS server responds: “Here it is — 192.0.2.123” (as an example).
Now the browser has what it needs: a real IP address. The next step? Start building the request and sending the data toward that server.
Step 2: Is the Destination IP Inside or Outside the LAN?
Once your browser receives the IP address of the destination website (e.g. 192.0.2.123 from the DNS response), your device needs to figure out how to get there.
But here’s the thing — your device isn’t sending that data blindly. It first asks:
“Is this destination IP address part of my local network (LAN), or do I need to send it out through my gateway to reach the broader internet (WAN)?”
This is called a routing decision.
How the Routing Decision Works
Your device compares:
- Its own IP address (e.g. 192.168.1.20)
- Its own subnet mask (e.g. 255.255.255.0)
- The destination IP address (e.g. 192.0.2.123)
It uses the subnet mask to “mask out” the network part of both IP addresses. If the network parts match, the destination is in the same LAN. If they don’t match, the destination is outside the LAN and the packet must go to the default gateway (usually your home router).
Quick Example:
- Your IP: 192.168.1.20
- Subnet mask: 255.255.255.0 - Only the first 3 octets, /24, are used for the network
- Destination IP: 192.0.2.123
Your device calculates:
- Your network: 192.168.1.0
- Destination network: 192.0.2.0 - Not the same network
Conclusion: “This is not on my LAN. I’ll send it to my default gateway.”
What Is the Default Gateway?
The default gateway is usually your router — it’s like the front door of your home network.
If a packet isn’t meant for a device inside your LAN, it must go out through this door to the WAN.
Your device forwards the request to your default gateway (e.g. 192.168.1.1), which takes over the job of delivering it to the destination server.
Every time your device needs to reach a resource outside of your LAN, the request is sent to the default gateway, which handles the routing decision. Likewise, any responses from outside come back through the same gateway to your device.
Step 3: Building the Digital Envelope (The Request)
Now that the routing logic is clear — your device knows the destination IP is outside the LAN, and the default gateway will forward the request — it’s time for the browser to prepare the actual request that will be sent through the network.
Think of it like mailing a letter: you’ve figured out who you’re writing to and which post office (your router) will deliver it. Now you need to pack the message in an envelope with all the right labels.
The browser builds this digital “envelope” — technically called a packet — containing the essential information to complete the request:
What’s Inside the Packet?
-
Client Identification (Source IP Address):
Your device’s own IP — for example, 192.168.1.20 — assigned by your network. This tells the destination server where to send the reply. -
Server Identification (Destination IP Address):
The IP of the server you’re trying to reach, resolved earlier via DNS — for example, 192.0.2.123, which belongs to wikipedia.org. -
The Actual Request (Webpage Path):
Inside the packet is the content of your request — like asking:
GET / HTTP/1.1
This line tells the server, “Please send me the homepage of your site.”
It also includes headers like:
Host: wikipedia.org
This makes sure the server knows which website (and page) you're trying to load — even if it serves many.
Once everything is in place, the browser is ready to send the packet!
Step 4: Inside the LAN — How the Packet Reaches the Router
So now the packet is ready — it's packed with the destination IP address, your device’s IP, and a request for the Wikipedia homepage. Next, the device must send it out through the network. But how does it actually get from your phone to the router? Let’s break it down.
Wi-Fi = Access Point | Wired = Switch
Depending on your setup, this next step looks slightly different:
- In your home Wi-Fi: Your device sends the packet through the wireless antenna. That signal is picked up by your Access Point — usually built into your router or modem-router combo.
- In a corporate network: Non-Wi-Fi devices like laptops and servers often connect with Ethernet cables, and their traffic goes through a network switch instead.
While they work differently under the hood (wireless vs. wired), their role in this step is the same: Forward your request to the next device on the path — the router.
What Do Access Points and Switches Do?
Both Access Points and Switches are focused on another type of address called MAC addresses - this is not an IP addresses.
They do not care where the final destination is (like wikipedia.org) — they only care about how to forward the packet within the LAN.
They Manage a MAC Address Table:
Access Points and Switches both keep a table called a MAC Address Table (or forwarding table), which maps:
- MAC addresses of devices in the network
- The port or interface those devices are connected to
Let’s look at an example from a switch:
MAC Address | Port |
---|---|
AA:BB:CC:11:22:33 | 1 |
77:88:99:AA:BB:CC | 2 |
Router MAC Address | 3 |
So when your phone sends a packet, the switch or access point looks at the destination MAC address, checks the table, and forwards the packet to the correct port — which in this case belongs to the router (your default gateway).
How Does It Know the Router’s MAC Address?
If your device doesn't already know the router's MAC address, it uses a special protocol called ARP (Address Resolution Protocol) to ask:
“Who has IP address 192.168.1.1? Tell me your MAC!”
Since all ARP requests are sent as broadcasts, every device within the LAN can hear this transmission.
The router replies:
“That's me — here’s my MAC address.”
Now your device can send the packet directly to the router, using:
- Destination MAC address: the router's MAC
- Destination IP address: the external IP of Wikipedia (e.g., 192.0.2.123)
Wait — Another Address? What’s a MAC Address?!?
That’s right! Every request and response contains both a MAC address and an IP address and they work together:
- IP addresses are used to identify devices across different networks — LANs and WANs.
- MAC addresses are used to deliver data within the local network (LAN). Switches and access points use them to forward packets to the correct device.
What Does the Full Packet Look Like?
Now that you understand both IP and MAC addresses, the full digital envelope — called a packet — looks like this:
- Client Physical Identification (Source MAC Address): The MAC address of your mobile phone’s network interface card.
-
Server Physical Identification (Destination MAC Address):
If the destination IP is outside your LAN, the destination MAC will be that of your default gateway router.
If it’s inside your LAN, the destination MAC will be the MAC of that internal device.
In our example, the MAC address is the default gateway since the IP address is not within our LAN. - Client Logical Identification (Source IP Address): Your device’s own IP — for example, 192.168.1.20 — assigned by your network. This tells the destination server where to send the reply.
- Server Logical Identification (Destination IP Address): The IP of the server you’re trying to reach, resolved earlier via DNS — for example, 192.0.2.123, which belongs to wikipedia.org.
-
The Actual Request (Webpage Path):
GET / HTTP/1.1
Host: wikipedia.org
At this point, the packet is forwarded using your phone’s Wi-Fi antenna through your access point or switch, across the LAN, and it heads to the router — your default gateway — ready to exit the LAN and continue its journey across the WAN.
The journey has officially begun!
Step 5: Out to the World — Routers & ISPs
Now that the packet has reached your home router, it’s time for it to leave your LAN and travel across the internet — through your Internet Service Provider (ISP) and beyond.
But how does your router know where to send it next?
The Router’s Job: Making Routing Decisions
A router is like a traffic controller — it receives packets and decides where they should go next, based on their destination IP address. This decision-making is called routing.
But the router doesn’t know about every server in the world (that would be impossible). Instead, it looks at:
- The destination IP in the packet — this is the only content of the envelope that the router cares about (e.g., 192.0.2.123 for wikipedia.org).
- Its own routing table — a list of known paths to different networks.
- If it doesn’t recognize the destination in his own routing table, it uses its default gateway — essentially saying:
“I don’t know how to reach 192.0.2.123 (wikipedia.org), so I’ll forward it to someone who might.”
Routers Have a Default Gateway Too
Just like your device uses a default gateway to exit your LAN, your home router also uses a default gateway — your home router is part of your ISP’s infrastructure and they responsible to configure the default gateway.
From there, the packet continues hopping from router to router, moving through:
- Your ISP’s local infrastructure
- Then to larger regional ISP routers
- And finally, to internet backbone routers that connect entire continents
Each router along the way:
- Looks at the destination IP
- Checks its own routing table
- Chooses the best “next hop” and forwards the packet closer to its destination
How Do Routers Learn Where to Send Packets?
Routers don’t know the exact location of every server on the internet. Instead, they rely on routing knowledge passed between other routers — like a chain of digital messengers.
There are two ways routers figure out where to send your data:
-
Static Routing – This is like following printed directions:
A network administrator manually tells the router, “If you ever get traffic to Network X, send it this way.” -
Dynamic Routing – This is more like using a navigation app (like Waze or Google Maps):
The router constantly talks to other routers around it to ask,
“Hey, what’s the best path to reach Network X right now?”
And based on real-time updates, it chooses the most efficient route.
This dynamic system keeps traffic flowing — even if a cable is down, a router is offline or internet traffic spikes in one region.
ISPs: A Massive Network of Routers
Your ISP is basically a big network of routers — all forwarding data across their own systems and handing it off to other ISPs when necessary.
If you’re trying to reach a server in another country:
- Your packet may pass through 10 or more routers
- It might hop between different ISPs
- Until it finally reaches the data center that hosts the server (like wikipedia.org)
All of this happens in milliseconds — and it’s all thanks to routers, default gateways and dynamic routing.
Step 6: At the Server — Handling the Request and Sending Data Back (The Response)
After traveling through multiple routers, networks and possibly even continents — your packet finally reaches its destination - the server. Remember our example: you’re trying to access wikipedia.org.
What Happens When the Packet Arrives?
The server — maybe located in a massive data center — receives your packet and checks what it’s asking for. Inside your digital envelope, it reads:
- “Am I the correct recipient of this packet?” - It checks the Destination IP Address
- “Who sent this and where should I send my reply?” - It checks the Source IP Address
- “What are they asking for?” - It checks the actual HTTP request inside, like:
GET / HTTP/1.1
Host: wikipedia.org
If everything looks good, the server will process your request — otherwise, the request will be ignored by the server.
The Server’s Response
If everything looks okay (the page exists, the the destination IP is the server IP, etc.), the server prepares a response packet — like a reply letter with the page content. The response includes:
- Source IP: The server’s IP address (e.g. 192.0.2.123)
- Destination IP: Your device’s IP address (e.g. 192.168.1.20)
- Content: The actual HTML, CSS, and other assets needed to display the wikipedia.org homepage
Note: In this example, we didn’t include a NAT (Network Address Translation) device — but in real-world scenarios, NAT is essential. The network 192.168.0.0/16 is a private range and cannot communicate directly over the internet. In practice, your private IP is translated by your router to a public IP before it reaches the internet.
This is the start of your phone receiving the response — piece by piece — until it has everything it needs to display the full website.
Then What?
Now, the response packet begins its return journey, following the reverse path:
- From the server back to its ISP’s router
- Through a chain of public routers across the WAN
- Eventually back to your home router (the default gateway)
- Then through the access point or switch
- Finally to your phone
In less than a second, your device receives all the packets it needs to assemble the page — and boom — wikipedia.org loads.
Every additional click on any article within wikipedia.org or any other type of web content you access — like Instagram, YouTube, TikTok, LinkedIn or your favorite app — triggers the exact same chain of events, happening again in milliseconds.
Final Thoughts
What feels like “just opening a website” is actually a lightning-fast journey of IP assignments, routing decisions, MAC lookups, DNS resolutions and more — all happening in milliseconds, millions of times a day, all around the world.
By understanding what’s going on behind the scenes, you’re not just learning how the internet works — you’re gaining the tools to troubleshoot network issues, strengthen your digital security and recognize how legitimate processes can be exploited by attackers - something we’ll cover soon.
Every browser click, every message you send, every video you stream — it's all part of this beautifully orchestrated system. And now you understand it.
Key Takeaways
- A successful network connection needs 4 key settings: IP address, Subnet Mask, Default Gateway and DNS server — whether assigned manually or by automaticly DHCP.
- When you open a browser and visit a site like wikipedia.org, a complex but standardized process kicks off behind the scenes.
- The browser fills in the domain name or the user type it manually, which must be resolved into an IP address using DNS.
- Once the destination IP is known, the device checks whether it belongs to the local network (LAN) or must be routed through the Default Gateway to the WAN.
- The request is wrapped in a digital envelope that includes both IP and MAC addresses, allowing it to be delivered correctly across switches and routers.
- Access points and switches help get your request to the router, which then passes it to your ISP — and eventually, to the destination server.
- The server processes the request, sends back the data, and your device assembles and displays the final result — often in less than a second.
- Every app click, video stream, or message you send uses this same process — proving how essential switches, routers, and IP logic are to everyday life.