---
id: 2024-09-17-dynamic-vs-static-ip-addresses
slug: dynamic-vs-static-ip-addresses
title: "Dynamic vs static IP addresses: when to use which, and how to configure them on Linux"
excerpt: "Dynamic or static? When you use which IP method, how DHCP works, and how you set fixed IPs on Linux — including troubleshooting and network best practices."
date: "2024-09-17T09:00:00+01:00"
updated: "2026-01-17T10:00:00+01:00"
author:
  name: "László Kovács"
  handle: "lkovacs"
category: ["network"]
tags: ["netzwerk", "ip-adressen", "dhcp", "statische-ip", "dynamische-ip", "linux-networking", "troubleshooting", "heimnetzwerk", "server-konfiguration", "netzwerk-management"]
toc: true
reading_time: 18
---

When you connect a device to the internet — a smartphone, a laptop or a smart TV — that device gets a unique number: the <span class="nb-accent">IP address.</span> That address works like a house number and lets other devices talk to yours.

**There are two main ways your device can get an IP address:** dynamically (assigned automatically and changeable) or statically (set by hand and unchanged until you change it). You do not need special prior knowledge. If you want to go deeper into networking, read the article on the [OSI model](/en/network/the-osi-model-a-detailed-introduction-to-the-7-layers){.badge-link-text}.

**Two paths to an IP address**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Two paths to an IP address                                │
│                                                             │
│   ┌────────────────┐                                        │
│   │ Dynamic IP     │  -->  Router assigns IP automatically  │
│   └───────┬────────┘                                        │
│           │  like a rented flat                             │
│           ▼                                                 │
│   ┌────────────────┐                                        │
│   │ Static IP      │  -->  Admin sets the IP                │
│   └───────┬────────┘                                        │
│           │  like owning the house                          │
└─────────────────────────────────────────────────────────────┘
```

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** Everyday picture:
</blockquote>

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Everyday picture                                          │
│                                                             │
│   Dynamic IP  -->  hotel room number changes every stay     │
│                          ▼                                  │
│   Static IP   -->  your home number stays the same          │
└─────────────────────────────────────────────────────────────┘
```

<blockquote class="infobox infobox--practice">
❗ **Important note:** This is a practice-oriented companion for self-study. It does not replace an official course. It helps you apply the concepts on real system-administration scenarios.
</blockquote>

### Topics and how to work through them

<span class="nb-accent">You will cover the following topics:</span>

* Basics of IP addresses
* Dynamic and static IPs compared in detail
* Practical setup and troubleshooting on Linux

**Especially useful for beginners:** typical pitfalls and concrete examples so you can start immediately.

**Who this is for**

<span class="nb-accent">You will get the most from it if you are:</span>

* a Linux beginner who wants to learn networks
* a system administrator who wants to deepen existing knowledge
* an IT professional who wants a clear overview
* anyone who prefers practice-oriented explanations

**How you get the most out of it**

<span class="nb-accent">Follow these tips:</span>

* Read step by step and test the examples in a virtual machine
* Note the commands and try them
* Use the ASCII diagrams as a visual aid
* Ask in forums when questions come up

## Introduction to IP addresses

An <span class="nb-accent">IP address</span> is like a digital identity card for your device on the network. Without it, targeted data exchange between computers would be impossible — imagine sending a letter when nobody has an address. The following sections unpack that step by step so you understand why IP addresses are the foundation of every network conversation.

<span class="nb-accent">First of all:</span> IP stands for <span class="nb-accent">Internet Protocol</span>, the standard that gets data packets through the network. Every IP address identifies a device uniquely and enables <span class="nb-accent">routing</span> — forwarding data from source to destination. When you open a web page, your browser sends a request to the server’s IP address, and the server answers under yours.

**There are two common versions:** <span class="nb-accent">IPv4</span> and <span class="nb-accent">IPv6</span>. IPv4 is the classic most people still know, but IPv6 matters more and more because the old addresses are running out. The next two sections show how each is built.

### Structure of an IPv4 address

An <span class="nb-accent">IPv4 address</span> consists of four number blocks, separated by dots. Each block runs from `0` to `255` — theoretically more than 4 billion addresses. Why exactly 0 to 255? **That comes from binary representation:** computers think in bits (`0` or `1`), and each block is 8 bits long. 2^8 minus 1 is 255.

**Example:** structure of an IPv4 address

```markdown
┌─────────────────────────────────────────────────────────────┐
│   IPv4 address structure                                    │
│                                                             │
│   ┌─────────┬─────────┬─────────┬─────────┐                 │
│   │   192   │   168   │    1    │   100   │                 │
│   └─────────┴─────────┴─────────┴─────────┘                 │
│         Four number blocks (each block: 0 to 255)           │
└─────────────────────────────────────────────────────────────┘
```

**In binary that looks like this:** `192` is `11000000`, `168` is `10101000`, `1` is `00000001` and `100` is `01100100`. **Together:** `11000000.10101000.00000001.01100100`. That is the language routers and switches work in.

<blockquote class="infobox infobox--info">
💡 **Tip:** To convert an IP to binary on Linux you can use `ipcalc`. Install it with `sudo apt install ipcalc` on Debian-based systems and try `ipcalc 192.168.1.100`.
</blockquote>

### Structure of an IPv6 address

IPv6 is the successor and solves address scarcity. Instead of `32 bits` (as with IPv4) it uses `128 bits`, which yields about 340 undecillion addresses — enough for every device on earth and more. An <span class="nb-accent">IPv6 address</span> looks like eight groups of four hexadecimal digits (0-9, A-F), separated by colons. **Example:** `2001:0db8:0000:0000:0000:ff00:0042:8329`.

To shorten it you can drop leading zeros or replace consecutive zero groups with `::`: `2001:db8::ff00:42:8329`

**Structure of an IPv6 address**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   IPv6 address structure                                    │
│                                                             │
│      ┌──────┬──────┬──────┬──────┐                          │
│      │ 2001 │ 0db8 │ 0000 │ 0000 │                          │
│      ├──────┼──────┼──────┼──────┤                          │
│      │ 0000 │ ff00 │ 0042 │ 8329 │                          │
│      └──────┴──────┴──────┴──────┘                          │
│         Eight hex groups (each group: 0000 to FFFF)         │
└─────────────────────────────────────────────────────────────┘
```

🔧 **Practical example:** In a modern dual-stack network (IPv4 and IPv6 in parallel) you see both.

**Check your own IP with:**

```bash
ip addr show
```

Look for `inet` for IPv4 and `inet6` for IPv6. If you only see IPv4, your network is not yet on IPv6 — but that is changing.

### Why IP addresses matter

Picture a large shopping mall. Without shop names and numbers you would search forever for a specific store. Computers likewise need unique addresses to send and receive data. Without IP, your email client would not know where the message should go, and your browser could not load a page.

Here is a simple diagram of network communication:

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Packet exchange between two hosts                         │
│                                                             │
│   ┌──────┐                                   ┌──────┐       │
│   │ PC-A │  ------------------------------>  │ PC-B │       │
│   └──────┘                                   └──────┘       │
│   "I am 192.168.1.100"      "Ah, the message is for me!"    │
│              data packet (with source and dest IP)          │
└─────────────────────────────────────────────────────────────┘
```

Every data packet contains the `source IP` (sender) and `destination IP` (receiver). Routers look at that and forward until it arrives. If the IP is wrong, the message is lost — like a letter without an address.

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** Think of IP addresses as an addressing system:
</blockquote>

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Street system vs IP system                                │
│                                                             │
│   Street system  -->  city | street name | house number     │
│                          ▼                                  │
│   IP system      -->  network part | subnet | host ID       │
└─────────────────────────────────────────────────────────────┘
```

The network part identifies the large net (like the city), the subnet a subdivision (like the district) and the host ID the individual device (like the house number).

### Private and public IP addresses

Before dynamic and static, you need the difference between private and public IPs. That is decisive for understanding how your home network is separated from the internet.

Public IPs are globally unique and assigned by Internet Service Providers (ISPs). They are like the street address of your house — anyone on the internet can reach you through them. Private IPs are valid only in your local network, like room numbers in a building. They are not routed on the internet, which provides security.

Think of your home network as a large office building. The public IP is the street address of the building, while the private IPs are the office numbers inside. The router (like the receptionist) translates between them using NAT (Network Address Translation).

**Internet and your home network**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Internet                                                  │
│   (public IP: 203.0.113.17)                                 │
│                         ▼                                   │
│                    ┌──────────┐                             │
│                    │  Router  │                             │
│                    └──────────┘                             │
│                         ▼                                   │
│   Private IP addresses:                                     │
│   ┌───────┐   ┌───────┐   ┌───────┐                         │
│   │ PC    │   │ Phone │   │ Smart │                         │
│   │ .100  │   │ .101  │   │ .102  │                         │
│   └───────┘   └───────┘   └───────┘                         │
└─────────────────────────────────────────────────────────────┘
```

<span class="nb-accent">Private IPv4 ranges</span> (per RFC 1918): `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`. For IPv6 there are Unique Local Addresses (ULA) such as `fc00::/7`.

🔧 **Practical example:**

Check your public IP with:

```bash
curl ifconfig.me
```

And your private IP with `ip addr show`. NAT makes all devices in your net share one public IP — economical and safer, because attackers from outside cannot reach private IPs directly.

<blockquote class="infobox infobox--practice">
❗ **Watch out:** In enterprise networks you often mix private IPs with VPNs for secure access. If you host a server, you need a public IP or port forwarding.
</blockquote>

<blockquote class="infobox infobox--info">
💡 **Tip:** For more detail on private vs public IPs, see [Public vs private IP addresses](/en/network/public-vs-private-ip-addresses-the-main-differences){.badge-link-text}.
</blockquote>

With these basics you are ready for the next step: comparing dynamic and static IPs.

## Dynamic vs static IP addresses in detail

Now that you have the IP basics — structure, the role in communication, private and public variants — the core question is how those addresses are actually assigned. That is where <span class="nb-accent">dynamic</span> and <span class="nb-accent">static</span> IPs come in. The following sections go through the mechanisms, then <span class="nb-accent">advantages</span> and <span class="nb-accent">disadvantages</span>, and end with practical scenarios including a comparison table.

### How dynamic IPs work

<span class="nb-accent">Automation through DHCP</span>

Dynamic IPs are assigned automatically, which keeps the process simple and low-maintenance. The heart of that is the <span class="nb-accent">DHCP protocol (Dynamic Host Configuration Protocol)</span>, which works like a smart landlord: it hands out IPs from a pool without you intervening by hand. Picture checking into a hotel — the room (the IP) is assigned to you, and on your next visit it might be a different one.

The sequence runs in four steps, known as <span class="nb-accent">DORA (Discover, Offer, Request, Acknowledge)</span>:

* 1. **Discover:** Your device sends a broadcast: <span class="nb-accent">Hey, I need an IP!</span>
* 2. **Offer:** The DHCP server answers: <span class="nb-accent">Here is this IP, plus subnet mask, gateway and DNS server.</span>
* 3. **Request:** Your device confirms: <span class="nb-accent">Yes, I will take that one.</span>
* 4. **Acknowledge:** The server finalises: <span class="nb-accent">Okay, the IP is reserved for you.</span>
* 5. **Release:** After the lease expires, the server frees the IP again.

Lease times matter: typically 24 hours in home networks, shorter on public WLANs. After expiry the lease renews automatically, but the IP can change if the pool is tight.

**DHCP sequence visualised**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   DHCP DORA sequence                                        │
│                                                             │
│   ┌────────────┐                     ┌────────────┐         │
│   │  Client    │                     │ DHCP server│         │
│   └────────────┘                     └────────────┘         │
│        │  Discover (broadcast)            │                 │
│        │ ------------------------------>  │                 │
│        │                                  │                 │
│        │      Offer (IP proposal)         │                 │
│        │ <------------------------------  │                 │
│        │                                  │                 │
│        │  Request (acceptance)            │                 │
│        │ ------------------------------>  │                 │
│        │                                  │                 │
│        │    Acknowledge (confirmation)    │                 │
│        │ <------------------------------  │                 │
└─────────────────────────────────────────────────────────────┘
```

🔧 **Practical example:** In a home network with many devices (laptop, smartphone, smart TV) DHCP keeps everything connected without you assigning addresses.

**Check your dynamic IP on Linux with:**

```bash
ip addr show | grep inet
```

**Or force a renewal with:**

```bash
sudo dhclient -r && sudo dhclient
```

That is useful when you have connection problems — it fetches a fresh IP.

<span class="nb-accent">Advantages of dynamic IPs:</span>

* **Simplicity:** no manual work, ideal for beginners or large nets.
* **Scalability:** the server avoids conflicts automatically by reusing IPs.
* **Flexibility:** perfect for mobile devices that connect here and there.
* **Resource efficiency:** in times of IPv4 scarcity, DHCP hands out IPs efficiently.

<span class="nb-accent">Disadvantages:</span>

* **Unpredictability:** the IP can change, which can break connections.
* **Dependence on the server:** if the DHCP server fails, new devices cannot get an IP.
* **Security risks:** rogue DHCP servers (attackers handing out wrong IPs).

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** If you look at DHCP settings in your router (usually `192.168.1.1` in the browser), you see the IP pool, for example `192.168.1.100` to `192.168.1.200`. Those are the addresses handed out dynamically.
</blockquote>

### How static IPs work: manual stability

By contrast, <span class="nb-accent">static IPs</span> are set by hand — you decide which address a device gets, and it stays until you change it. That is like a fixed address at your own house: <span class="nb-accent">reliable and predictable.</span>

Configuration happens on the device itself or centrally via tools. On Linux you edit files such as `/etc/netplan/` (on Ubuntu) or use commands such as `nmcli`. You do not only set the IP, but also the subnet mask (for example `255.255.255.0` for `/24`), gateway (router IP) and DNS servers (for example `8.8.8.8` for Google).

**Example of a static configuration in Netplan**
(YAML file under */etc/netplan/01-netcfg.yaml*):

```yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [192.168.1.50/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
```

**Apply with:**

```bash
sudo netplan apply
```

**Static IP assignment**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Static IP assignment                                      │
│                                                             │
│   ┌─────────┐                        ┌─────────┐            │
│   │  Admin  │                        │ Device  │            │
│   └─────────┘                        └─────────┘            │
│        │  Configures IP by hand           │                 │
│        │ ------------------------------>  │                 │
│        │  (e.g. via config file)          │                 │
│        │                                  │                 │
│        │  Stays fixed, no change          │                 │
│        │ <------------------------------  │                 │
│        │    until a manual adjustment     │                 │
└─────────────────────────────────────────────────────────────┘
```

🔧 **Practical example:** For a web server or printer on your network, static is ideal — you can always reach it under the same IP, for example for port forwarding on the router.

**Test reachability with:**

```bash
ping 192.168.1.50
```

<span class="nb-accent">Advantages of static IPs:</span>

* **Reliability:** perfect for devices that must always be reachable.
* **Remote access:** no surprises from IP changes; you can configure DNS records precisely.
* **Optimisation:** in enterprise nets you reserve IPs for critical systems to set priorities.
* **Debugging:** fixed IPs make troubleshooting easier because you know where each device “lives”.

<span class="nb-accent">Disadvantages:</span>

* **Effort:** every assignment needs manual work, which is time-consuming in large nets.
* **Conflict risk:** if two devices get the same IP, a conflict occurs — nothing communicates any more.
* **Less flexibility:** not suitable for temporary devices, because you must manage the pool by hand.
* **Scaling problems:** when you grow you must replan IPs, which can cause outages.

<blockquote class="infobox infobox--practice">
❗ **Watch out:** Never mix static IPs from the DHCP pool — reserve separate ranges, for example .1–.50 static, .51–.254 dynamic.
</blockquote>

<blockquote class="infobox infobox--info">
💡 **Tip:** On Fedora or Red Hat-based systems use nmcli for static IPs:
</blockquote>

```bash
sudo nmcli con mod "Wired connection 1" ipv4.addresses 192.168.1.50/24 ipv4.method manual
sudo nmcli con up "Wired connection 1"
```

### Comparison and use cases

<span class="nb-accent">When to choose which?</span>

To make the decision easier, here is a direct comparison. **Remember:** the choice depends on your scenario — home net vs server environment.

**Comparison: dynamic vs static**

```markdown
┌─────────────────────────────────────────────────────────────┐
│ Comparison: dynamic vs static IP                            │
├──────────────┬──────────────────────┬───────────────────────┤
│ Aspect       │ Dynamic IP (DHCP)    │ Static IP             │
├──────────────┼──────────────────────┼───────────────────────┤
│ Assignment   │ Automatic by server  │ Manual by admin       │
│ Change       │ Can change           │ Stays fixed           │
│ Effort       │ Low                  │ High (config + docs)  │
│ Suited for   │ Mobiles, home nets   │ Servers, printers     │
│ Advantages   │ Scalable, no clash   │ Reliable, predictable │
│ Drawbacks    │ Unpredictable, deps  │ Conflicts, inflexible │
│ Security     │ Rogue-server risk    │ Easier to lock down   │
└──────────────┴──────────────────────┴───────────────────────┘
```

<span class="nb-accent">Use cases:</span>

* **Home net:** dynamic for everything — your router handles it, and you save time.
* **Small office:** dynamic for laptops, static for printers and file servers so print jobs are not lost.
* **Enterprise:** dynamic for user devices, static for critical infrastructure such as databases.
* **Server hosting:** always static, or static leases in DHCP, so domains such as example.com always point at the same IP.

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** Start with dynamic in a VM (for example VirtualBox with Ubuntu) to experiment. Disable `DHCP` on the router and see what happens — devices no longer get an IP.
</blockquote>

## Setup and troubleshooting on Linux

With the theoretical foundation on <span class="nb-accent">dynamic</span> and <span class="nb-accent">static</span> IPs you can now go straight into practice — on Linux, where network configuration is a core piece of system administration. As a beginner you learn step by step how you set IPs, find typical errors and lock down your setup. The sections cover common distributions such as Ubuntu, Debian and Fedora, with a focus on tools such as Netplan, nmcli and systemd-networkd. Each step is explained so you can follow and try it without programming knowledge.

### Setting up dynamic IPs: enabling and configuring DHCP

<span class="nb-accent">Dynamic IPs</span> are the entry point for most Linux newcomers because they run automatically. On Linux the DHCP client (for example `dhclient` or `systemd-networkd`) talks to the server. On a freshly installed system `DHCP` is often enabled by default — but you should check and adjust it.

**First:** identify your <span class="nb-accent">network interface</span>. On Linux these are typically named `enp0s3` (Ethernet) or `wlp2s0` (Wi-Fi).

**Find them with:**

```bash
ip link show
```

That lists all interfaces, including status (up/down).

**For Ubuntu/Debian (with Netplan, default from Ubuntu 18.04):**

Edit the config file under `/etc/netplan/`.
Create or edit a YAML file, for example `01-netcfg.yaml`:

```yaml
network:
  version: 2
  renderer: networkd  # Or NetworkManager for desktops
  ethernets:
    enp0s3:  # Replace with your interface
      dhcp4: yes  # Enables DHCP for IPv4
      dhcp6: yes  # Optional for IPv6
```

**Apply the changes:**

```bash
sudo netplan try  # Tests, rollback on errors
sudo netplan apply
```

If something goes wrong you have 120 seconds to abort — useful for beginners so you do not panic.

For Fedora/Red Hat (with `NetworkManager`): use `nmcli`, a command-line tool for graphical and server environments.

```bash
sudo nmcli con mod "Wired connection 1" ipv4.method auto  # Sets DHCP
sudo nmcli con up "Wired connection 1"
```

`Wired connection 1` is the default name; adjust it with `nmcli con show`.

On older Debian systems (without Netplan, with `/etc/network/interfaces`):

```bash
sudo nano /etc/network/interfaces
```

**Add:**

```
auto enp0s3
iface enp0s3 inet dhcp
```

**Then:**

```bash
sudo ifup enp0s3
```

🔧 **Practical example:** On a home-server setup with Ubuntu, enable DHCP for a temporary test interface. Connect to a WLAN hotspot and watch the IP being assigned automatically.

**Watch the process with:**

```bash
sudo journalctl -u systemd-networkd -f  # Shows logs in real time
```

Look for `DHCP lease obtained` — that confirms success.

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** If you use Wi-Fi you need wpa_supplicant for authentication. Configure it in `/etc/wpa_supplicant.conf` and start with `wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant.conf`, then run dhclient on top.
</blockquote>

<span class="nb-accent">If you want to host the DHCP server yourself</span>

**Install isc-dhcp-server on Ubuntu:**

```bash
sudo apt update && sudo apt install isc-dhcp-server
```

**Configure `/etc/dhcp/dhcpd.conf`:**

```
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;
  option routers 192.168.1.1;
  option domain-name-servers 8.8.8.8;
}
```

**Start the service:**

```bash
sudo systemctl start isc-dhcp-server
sudo systemctl enable isc-dhcp-server
```

**DHCP server setup**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   DHCP server setup                                         │
├────────────────────────┬────────────────────────────────────┤
│ 1. Install the package │ $ sudo apt install isc-dhcp-server │
│ 2. Edit the config     │ /etc/dhcp/dhcpd.conf               │
│ 3. Start the service   │ $ sudo systemctl start isc-dhcp... │
└────────────────────────┴────────────────────────────────────┘
```

<blockquote class="infobox infobox--practice">
❗ **Watch out:** Test this in a VM so you do not disturb your real network — conflicts with the router DHCP are common.
</blockquote>

### Setting up static IPs

<span class="nb-accent">Manual configuration per distribution</span>

Static IPs need more steps, but they give you control. Important: pick an IP outside the DHCP pool to avoid conflicts. Take for example `192.168.1.50` if the pool starts at `.100`.

**For Ubuntu with Netplan:**

Extend the YAML file:

```yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [192.168.1.50/24]  # IP with subnet
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
```

Apply as above. <span class="nb-accent">For IPv6:</span> add `addresses: [2001:db8::50/64]`, `gateway6: 2001:db8::1`.

**For Debian (older, with interfaces):**
In `/etc/network/interfaces`:

```
auto enp0s3
iface enp0s3 inet static
  address 192.168.1.50/24
  gateway 192.168.1.1
  dns-nameservers 8.8.8.8 8.8.4.4
```

Restart: `sudo ifdown enp0s3 && sudo ifup enp0s3`.

**For Fedora with nmcli:**

```bash
sudo nmcli con mod "Wired connection 1" ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4"
sudo nmcli con up "Wired connection 1"
```

<span class="nb-accent">For IPv6 add:</span> `ipv6.method manual` `ipv6.addresses 2001:db8::50/64` and so on.

On pure `systemd-networkd`, for example <span class="nb-accent">Arch Linux</span>

Create `/etc/systemd/network/10-static.network`:

```ini
[Match]
Name=enp0s3

[Network]
Address=192.168.1.50/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4
```

Restart: `sudo systemctl restart systemd-networkd`.

🔧 **Practical example:** Set a static IP for a Raspberry Pi as NAS.
Connect via SSH (after a temporary dynamic IP), set it static and test with `ip addr show` — the IP should stay fixed.

**Static config steps**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Static configuration steps                                │
├───────────────────────────────┬─────────────────────────────┤
│ 1. Identify the interface     │ $ ip link show              │
│ 2. Edit the config file       │ /etc/netplan/...            │
│ 3. Test                       │ $ ip addr show              │
└───────────────────────────────┴─────────────────────────────┘
```

<blockquote class="infobox infobox--info">
💡 **Tip:** For hybrid setups reserve IPs on the DHCP server (`fixed-address` in dhcpd.conf). That way you combine automation with stability.
</blockquote>

### Troubleshooting

<span class="nb-accent">Finding and fixing common problems</span>

Network problems are frustrating, but they are solvable systematically.
**Always start with the basics:** Is the cable plugged in? LED on the port lit?

1. **No IP assigned**

* For dynamic, check DHCP logs: `sudo journalctl -u isc-dhcp-client`.
* For static: compare `ip addr` with the config.

2. **IP conflict:**

* Symptoms: intermittent connections.
* Find duplicates with `arping -D -I enp0s3 192.168.1.50` — a reply means a conflict.

3. **Connection test:**

* Ping local (`127.0.0.1`), then the router (`192.168.1.1`)
* then external (`8.8.8.8`). For DNS: `nslookup google.com`.

```bash
ping -c 4 8.8.8.8  # Tests internet
traceroute 8.8.8.8  # Shows the route
```

4. **DNS problems:**
If ping to an IP works but domains do not: check `/etc/resolv.conf`.

**Set it manually:**

```bash
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
```

**Troubleshooting flowchart**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Problem: no network?                                      │
│    ↓                                                        │
│   Check cable / LEDs                                        │
│    ↓                                                        │
│   ip addr show (has an IP?)                                 │
│    ↓                                                        │
│   ping router (local OK?)                                   │
│    ↓                                                        │
│   ping 8.8.8.8 (internet?)                                  │
│    ↓                                                        │
│   nslookup (DNS?)                                           │
└─────────────────────────────────────────────────────────────┘
```

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** Use tcpdump for a deep dive: `sudo tcpdump -i enp0s3 port bootps` — that shows DHCP traffic.
</blockquote>

**Common errors:** wrong subnet mask (no local routing), gateway error (no internet). **On Wi-Fi:** wrong password in `wpa_supplicant`.

### Security aspects

<span class="nb-accent">Protecting your network</span>

Security goes hand in hand with configuration. Enable `firewalld` (Fedora) or `ufw` (Ubuntu):

```bash
sudo ufw allow from 192.168.1.0/24  # Allows local traffic
sudo ufw enable
```

Prevent IP spoofing with `rp_filter`:
Set `net.ipv4.conf.all.rp_filter=1` in `/etc/sysctl.conf` and run `sudo sysctl -p`.

**For DHCP:** enable DHCP authorization on the switch to block rogue servers.
**In static setups:** use MAC binding on the router.

<blockquote class="infobox infobox--practice">
❗ **Watch out:** Scan open ports with `nmap -sn 192.168.1.0/24` — close unnecessary ones.
</blockquote>

<blockquote class="infobox infobox--info">
💡 **Tip:** Back up configs before changes: `sudo cp /etc/netplan/* ~/backup/`.
</blockquote>

## Practical tips

After you have learned in practice how to set IPs on Linux and how to fix faults, the next step is concrete advice from a <span class="nb-accent">system administrator’s</span> daily work. These tips build on what you just learned and help you make networks not only functional, but also robust and future-proof.

If you have only just discovered the difference between dynamic and static, you will learn here how you manage IPs carefully, keep documentation and react to upcoming trends — with a focus on real scenarios such as a home server or a small company net.

### Assigning and structuring IP addresses

Good IP management starts with planning. Instead of assigning IPs at random, split your address space logically — that avoids chaos, especially when the network grows. In a typical `192.168.1.0/24` net (254 usable IPs) you could reserve ranges: low numbers for infrastructure, middle for servers, high for dynamic devices. That way you keep an overview and minimise conflicts.

**For example:** in your DHCP server (via the router UI or isc-dhcp-server) define fixed reservations for important devices. That combines the advantages of both worlds — automatic assignment, but stable IPs.

🔧 **Practical example:**

In a home net with NAS, printer and guest network you set it up like this:

* `192.168.1.1-50`: static for router, switches and critical devices (configure by hand).
* `192.168.1.51-100`: static leases for servers (pin in DHCP by MAC address).
* `192.168.1.101-150`: for printers and IoT devices (static, to make access easier).
* `192.168.1.151-254`: dynamic pool for laptops and phones.

Adjust that in `/etc/dhcp/dhcpd.conf`:

```
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.151 192.168.1.254;
  # Static lease example
  host nas {
    hardware ethernet aa:bb:cc:dd:ee:ff;  # MAC of the NAS
    fixed-address 192.168.1.51;
  }
}
```

Restart the service: `sudo systemctl restart isc-dhcp-server`.

Now your NAS always gets `.51`, even after a reboot.

**Network structuring**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Split IP ranges with a purpose                            │
├────────────────────┬────────────────────────────────────────┤
│ 192.168.1.1-50     │ Infrastructure / gateway               │
│ 192.168.1.51-100   │ Servers / NAS                          │
│ 192.168.1.101-150  │ Printers / IoT                         │
│ 192.168.1.151-254  │ DHCP pool                              │
└────────────────────┴────────────────────────────────────────┘
```

**Why this split?**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Why this split?                                           │
├──────────┬──────────────────────────────────────────────────┤
│ Range    │ Reason                                           │
├──────────┼──────────────────────────────────────────────────┤
│ 1-50     │ Stable base                                      │
│ 51-100   │ Important services                               │
│ 101-150  │ Peripherals                                      │
│ 151-254  │ Flexible devices                                 │
└──────────┴──────────────────────────────────────────────────┘
```

<blockquote class="infobox infobox--info">
💡 **Tip:** Use tools such as ipcalc for calculations: `ipcalc 192.168.1.0/24` shows you net details. For larger nets try phpIPAM (an open-source IP manager) — install it via Docker for easy tests.
</blockquote>

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** Start small. In your test VM split 10 IPs and simulate devices with `ip addr add 192.168.1.x/24 dev lo` — that way you see how conflicts arise when you assign twice.
</blockquote>

### Documentation

<span class="nb-accent">The key to long-term success</span>

Without documentation every network change becomes guesswork. As an admin, note every IP, MAC, device name and purpose — that saves hours when troubleshooting. Use simple tools such as a spreadsheet or Markdown files that you version in Git.

**Example of an IP list:**

* `.1` : Router (gateway, DHCP server)
* `.50`: Printer (HP LaserJet, static)
* `.51`: NAS (Synology, static lease)
* `.52`: IP camera (garage, static)

Create a table in LibreOffice or via Markdown.

**Network documentation**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   IP list                                                   │
├──────────┬──────────────────────────────────────────────────┤
│ .1   --> │ Router                                           │
│ .50  --> │ Printer HP                                       │
│ .51  --> │ NAS Synology                                     │
│ .52  --> │ IP cam garage                                    │
└──────────┴──────────────────────────────────────────────────┘
```

**Documentation tips:**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Documentation tips                                        │
├────────────────┬────────────────────────────────────────────┤
│ What           │ Why                                        │
├────────────────┼────────────────────────────────────────────┤
│ IP list        │ Fast lookup                                │
│ Changes        │ Version history                            │
│ Access data    │ Emergency access                           │
│ Network plan   │ Visual overview                            │
└────────────────┴────────────────────────────────────────────┘
```

🔧 **Practical example:** In a small office document changes with `git`: create a repo under `~/netdocs`, add your IP list and commit with `git commit -m "Added static IP for new printer"`. That way you track who changed what and when.

<blockquote class="infobox infobox--practice">
❗ **Watch out:** Protect sensitive data — encrypt the file with GPG: `gpg -c ip-list.md` and share it only with team members.
</blockquote>

<blockquote class="infobox infobox--info">
💡 **Tip:** Add diagrams with draw.io (free online) — draw your net with IPs to plan visually. Export as PNG and attach it to your docs.
</blockquote>

### Backing up your configuration

<span class="nb-accent">Never change without a backup</span>

Network changes can go wrong — a typo in the config and everything is offline.

**Therefore:** <span class="nb-accent">always back up!</span> Copy key files first and test in a staging environment.

**Strategy:** original → local backup → cloud backup (for example via `rsync` to a NAS).

**Important files:**

* `/etc/netplan/` (Ubuntu configs)
* `/etc/dhcp/dhcpd.conf` (DHCP settings)
* `/etc/network/interfaces` (older Debian)
* `/etc/resolv.conf` (DNS)

**Backup script example**
Save it as `backup-net.sh` and make it executable with `chmod +x`:

```bash
#!/bin/bash
BACKUP_DIR=~/net-backup/$(date +%Y-%m-%d)
mkdir -p $BACKUP_DIR
cp -r /etc/netplan/* $BACKUP_DIR/
cp /etc/dhcp/dhcpd.conf $BACKUP_DIR/
cp /etc/resolv.conf $BACKUP_DIR/
tar -czf $BACKUP_DIR.tar.gz $BACKUP_DIR
rm -r $BACKUP_DIR  # Optional: delete folder after archive
```

Run it with `sudo ./backup-net.sh`.

**For cloud:** `rsync -avz $BACKUP_DIR.tar.gz user@nas:/backups/`.

**Backup strategy**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Original                                                  │
│    └──► Local backup                                        │
│          └──► Cloud backup                                  │
└─────────────────────────────────────────────────────────────┘
```

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** Test backups by changing a config, rebooting and then restoring: `sudo cp backup/netplan.yaml /etc/netplan/ && sudo netplan apply`.
</blockquote>

### Security aspects

<span class="nb-accent">Protection against common pitfalls</span>

Security is not an afterthought — dynamic IPs can invite rogue servers, static ones allow precise but error-prone rules.

**Start with a checklist:**

* Firewall active? (ufw/firewalld)
* Unnecessary ports closed? (for example only `SSH` on `22` for static servers)
* Updates regular? (`sudo apt update && sudo apt upgrade`)
* Access locked down? (strong passwords, `SSH keys` instead of `password`)

**Avoid pitfalls:**

* **IP conflicts:** document and scan regularly with `nmap -sn 192.168.1.0/24`.
* **No access:** check firewall rules with `sudo ufw status`.
* **DNS problems:** test the resolver with `dig example.com`.

**Security checklist**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   □ Firewall active?                                        │
│   □ Ports closed?                                           │
│   □ Updates installed?                                      │
│   □ Access locked down?                                     │
└─────────────────────────────────────────────────────────────┘
```

**Avoid typical pitfalls:**

```markdown
┌─────────────────────────────────────────────────────────────┐
│   Typical pitfalls                                          │
├────────────────┬────────────────────────────────────────────┤
│ Error          │ Fix                                        │
├────────────────┼────────────────────────────────────────────┤
│ IP conflicts   │ Scan with nmap                             │
│ No access      │ ufw status                                 │
│ DNS problems   │ Test with dig                              │
└────────────────┴────────────────────────────────────────────┘
```

🔧 **Practical example:** In a mixed net set VLANs for separation (for example IoT separate) via the `vlan` package: install `vlan`, configure `/etc/network/interfaces` with `vlan_raw_device` and reboot.

<blockquote class="infobox infobox--info">
💡 **Tip:** For IPv6 security: enable `ip6tables` and set rules similar to `IPv4` — many people forget that on dual-stack.
</blockquote>

### Future trends: IPv6 and IoT in view

<span class="nb-accent">Networks evolve:</span> IPv6 becomes the standard because IPv4 addresses are running out. In dynamic setups `DHCPv6 Stateful` (like DHCP) or `Stateless` (SLAAC for autoconfig) is supported. Test with `ip -6 addr show` — many routers offer dual-stack.

<blockquote class="infobox infobox--warn">
⚠️ **For beginners:** Start with IPv6 in your VM: enable `dhcp6: yes` in Netplan and ping `ping6 ipv6.google.com`.
</blockquote>

### Golden rules for getting started

<span class="nb-accent">In short:</span>

<blockquote class="infobox infobox--info">
💡 **Golden rules**

* **1.** Always document
* **2.** Back up before changes
* **3.** Test step by step
* **4.** Prioritise security
</blockquote>

## Command Reference (Cheatsheet)

The following reference collects the essential commands for checking, assigning and troubleshooting IP addresses on Linux:

| Category | Command | Purpose |
| :--- | :--- | :--- |
| **Status** | `ip addr show` | Shows IPv4 (`inet`) and IPv6 (`inet6`) addresses |
| **Status** | `ip link show` | Lists interfaces and their up/down state |
| **Status** | `ip addr show \| grep inet` | Filters the current IP addresses |
| **Public IP** | `curl ifconfig.me` | Shows the public address seen from the internet |
| **DHCP** | `sudo dhclient -r && sudo dhclient` | Releases and renews a DHCP lease |
| **DHCP** | `sudo journalctl -u systemd-networkd -f` | Follows DHCP/networkd logs live |
| **Netplan** | `sudo netplan try` | Applies Netplan with automatic rollback |
| **Netplan** | `sudo netplan apply` | Applies Netplan permanently |
| **NetworkManager** | `nmcli con show` | Lists NetworkManager connections |
| **NetworkManager** | `sudo nmcli con mod "Wired connection 1" ipv4.method auto` | Sets a connection to DHCP |
| **NetworkManager** | `sudo nmcli con mod "Wired connection 1" ipv4.method manual ipv4.addresses 192.168.1.50/24` | Sets a static IPv4 address |
| **Reachability** | `ping 192.168.1.50` | Tests whether a host answers |
| **Reachability** | `ping -c 4 8.8.8.8` | Tests internet without DNS |
| **Routing** | `traceroute 8.8.8.8` | Shows the path to a destination |
| **DNS** | `nslookup google.com` | Checks name resolution |
| **DNS** | `dig example.com` | Tests the resolver in detail |
| **Conflicts** | `arping -D -I enp0s3 192.168.1.50` | Detects duplicate IPs on the LAN |
| **DHCP traffic** | `sudo tcpdump -i enp0s3 port bootps` | Captures DHCP packets |
| **Scan** | `nmap -sn 192.168.1.0/24` | Lists live hosts in the subnet |
| **Firewall** | `sudo ufw allow from 192.168.1.0/24` | Allows local traffic in ufw |
| **Spoofing** | `sudo sysctl -p` | Reloads `rp_filter` and other sysctl settings |
| **Calc** | `ipcalc 192.168.1.0/24` | Shows network, broadcast and host range |

## Further Resources

For deeper reading and further references, the following links give direct access to official sources and related articles:

| Resource | Description | Type |
| :--- | :--- | :--- |
| [RFC 1918: private IPv4 ranges](https://datatracker.ietf.org/doc/html/rfc1918){.badge-link-text} | Official definition of `10/8`, `172.16/12` and `192.168/16` | RFC |
| [Netplan documentation](https://netplan.readthedocs.io/){.badge-link-text} | YAML reference for DHCP and static addressing on Ubuntu | Documentation |
| [NetworkManager nmcli](https://networkmanager.dev/docs/api/latest/nmcli.html){.badge-link-text} | Command reference for Fedora/RHEL connection profiles | Documentation |
| [ISC DHCP](https://www.isc.org/dhcp/){.badge-link-text} | `dhcpd.conf` syntax, leases and `fixed-address` reservations | Documentation |
| [OSI model](/en/network/the-osi-model-a-detailed-introduction-to-the-7-layers){.badge-link-text} | Seven layers of network communication, from hardware to application | Article |
| [Public vs private IP addresses](/en/network/public-vs-private-ip-addresses-the-main-differences){.badge-link-text} | NAT, RFC 1918 ranges and the split between LAN and internet | Article |

## Conclusion

The choice between dynamic and static IP addresses depends on your needs: dynamic for convenience in changing environments, static for stability on fixed services. Both have strengths — dynamic saves time through automation, static gives you control. As a beginner start with dynamic in a test net, switch to static for servers, and mix them carefully. With the tips here you build solid nets. Try it, and you will see how IPs make daily work easier.
