# From Local Networks to the Internet

So far, you’ve learned many powerful Linux and operating system concepts:  
users, permissions, processes, scripting, automation—and you’re already far ahead of most beginners.

However, **one crucial concept is still missing** before you truly feel like a Linux professional:

👉 **Networking**

In this article, we’ll build networking knowledge **step by step**, starting from your home network and ending with how the internet, DNS, firewalls, and ports actually work.

---

## Local Area Network (LAN)

Let’s start with something familiar: **your home network**.

Your laptop, phone, printer, and smart TV are all connected to the same network.  
This type of network is called a **LAN (Local Area Network)**.

A LAN is:

* A group of devices
    
* Connected in the same physical location
    
* Such as a house, office, school, or campus
    

Each device in a LAN must be uniquely identifiable.

---

## IP Addresses — Identity of a Device

Every device on a network has a **unique IP address**.

**IP** stands for **Internet Protocol**.

Example:

```plaintext
172.16.0.0
```

An IPv4 address:

* Is **32 bits long**
    
* Each bit is either `0` or `1`
    
* Bits are grouped into **4 octets**
    
* Each octet = 8 bits
    

That’s why IP addresses range from:

```plaintext
0.0.0.0 → 255.255.255.255
```

Devices communicate by sending data **to IP addresses**, not names.

---

## Switch — Communication Inside the LAN

Inside a LAN, devices communicate using a **network switch**.

A switch:

* Knows all device IP addresses in the LAN
    
* Forwards data to the correct destination
    

Example:

* Your laptop sends data to the printer
    
* The switch delivers it using the printer’s IP address
    

---

## Router — Connecting to the Internet

What happens when you access Facebook or Google?

Those servers are **outside your LAN**.

This is where a **router** comes in.

A router:

* Connects your LAN to the outside world
    
* Bridges LAN and WAN (Wide Area Network)
    
* Is your **gateway to the internet**
    

When your device sends data externally:

1. It sends the request to the router
    
2. The router forwards it to the internet
    
3. The response comes back the same way
    

The router’s IP address is called the **gateway**.

---

## Subnets — Knowing What’s Local vs External

How does your device know whether an IP address is:

* Inside the LAN?
    
* Or outside on the internet?
    

This is determined by the **subnet**.

### Subnet Mask Example

```plaintext
192.168.0.0 / 255.255.255.0
```

This means:

* First **24 bits are fixed**
    
* Devices must start with `192.168.0`
    
* Last octet can range from `0–255`
    

### CIDR Notation

Same subnet written as:

```plaintext
192.168.0.0/24
```

More examples:

* `/16` → first 16 bits fixed
    
* `/24` → first 24 bits fixed
    

**Subnet defines the IP address range of a LAN.**

---

## Required Network Information for a Device

To communicate properly, a device needs:

1. **IP address**
    
2. **Subnet**
    
3. **Gateway**
    

With this information:

* LAN traffic goes through the switch
    
* External traffic goes through the router
    

---

## NAT — Network Address Translation

LAN IP addresses are **private**.

They are **not visible on the internet**.

When you send a request outside:

* Your router replaces your private IP
    
* Uses its **public IP instead**
    

This process is called **NAT (Network Address Translation)**.

### Why NAT Is Important

1. **Security** – internal devices are hidden
    
2. **Efficiency** – IP ranges can be reused
    

Multiple companies can use the same LAN IP ranges without conflict.

---

## Firewalls — Controlling Access

By default, external devices **cannot access your LAN**.

This protection is enforced by a **firewall**.

A firewall:

* Is a set of network rules
    
* Controls who can access what
    
* Protects against unauthorized traffic
    

You explicitly define:

* Which IP addresses are allowed
    
* Which services are accessible
    
* Which **ports** are open
    

---

## Ports — Doors to Applications

Every device has **ports**.

Think of ports like **doors in a building**:

* Some doors are open
    
* Some are closed
    
* Some allow only specific guests
    

Applications listen on specific ports.

### Common Standard Ports

* **80** → HTTP (web)
    
* **443** → HTTPS
    
* **3306** → MySQL
    
* **5432** → PostgreSQL
    

⚠️ Only one application can use a port at a time.

---

## DNS — Translating Names to IPs

Humans don’t remember IP addresses.

We remember names like:

```plaintext
facebook.com
```

But networks only understand IP addresses.

This translation is done by **DNS (Domain Name System)**.

DNS maps:

```plaintext
Domain name → IP address
```

Think of DNS as the **internet’s address book**.

---

## Domain Hierarchy

DNS is hierarchical.

### Top-Level Domains (TLDs)

* `.com` – commercial
    
* `.org` – nonprofit
    
* `.edu` – education
    
* `.gov` – government
    
* `.mil` – military
    
* `.net` – networking
    

### Country Domains

* `.de` – Germany
    
* `.us` – United States
    
* `.uk` – United Kingdom
    
* `.fr` – France
    

---

## Domain Management

All domain names are regulated by  
**Internet Corporation for Assigned Names and Numbers (ICANN)**.

ICANN:

* Manages domain namespaces
    
* Authorizes domain registrars
    
* Ensures uniqueness worldwide
    

---

## Subdomains

A company can create multiple services under one domain.

Example:

* [`bootcamp.techworldwithnana.com`](http://bootcamp.techworldwithnana.com)
    
* [`courses.techworldwithnana.com`](http://courses.techworldwithnana.com)
    
* [`workshops.techworldwithnana.com`](http://workshops.techworldwithnana.com)
    

Each subdomain can:

* Point to a different server
    
* Have a different IP address
    

---

## How DNS Resolution Works

When you type [`facebook.com`](http://facebook.com):

1. Your OS sends a DNS request
    
2. Request goes to a **recursive DNS server**
    
3. If not cached:
    
    * Query root server
        
    * Then `.com` server
        
    * Then authoritative name server
        
4. IP address is returned
    
5. Browser sends request to that IP
    

Results are cached to speed up future requests.

---

## Useful Linux Networking Commands

### `ifconfig`

Shows:

* IP address
    
* Subnet mask
    
* Gateway
    

### `netstat`

Shows:

* Active connections
    
* Listening ports
    
* Network services
    

### `ps aux`

Shows:

* Running processes
    
* Resource usage
    
* Port information
    

### `nslookup`

* Domain → IP
    
* IP → Domain
    
* DNS server info
    

### `ping`

* Tests connectivity
    
* Checks reachability
    

---

## Why This Matters for DevOps

You don’t need to be a networking expert.

But with this foundation, you can:

* Debug connection issues
    
* Configure servers correctly
    
* Understand cloud networking
    
* Secure applications
    
* Troubleshoot production outages
    

And throughout the bootcamp, you’ll **use these concepts constantly**.

---

## Final Takeaway

Networking is the missing puzzle piece that connects:

* Linux
    
* Servers
    
* Applications
    
* The internet
