How to Change IP Address in Ubuntu

The Cryptographic Routing Override Vector

When you deploy an Ubuntu server into a production environment—whether it is hosting a MySQL database, an Nginx web server, or a Docker swarm—relying on the local router to dynamically assign an IP address (DHCP) is mathematically catastrophic. If the router reboots and assigns the server a different IP, all internal DNS routing instantly collapses, taking your applications offline. You must instruct the Linux kernel to permanently ignore DHCP broadcasts and lock the Network Interface Card (NIC) to a specific, hard-coded static IP address.

How to Change IP Address in Ubuntu

Modern Ubuntu Server architectures (20.04 LTS and newer) have completely deprecated the legacy `/etc/network/interfaces` file. All core routing telemetry is now governed by the Netplan utility, which parses strict YAML configuration files.

1. Open your terminal application or connect to the server via SSH.
2. Phase 1: The Target Acquisition (Identifying the NIC):
* You must mathematically identify the exact hardware name of your active ethernet or Wi-Fi interface.
* Type exactly: ip a
* Press Enter. Note the name of the primary interface (e.g., `eth0`, `enp3s0`, or `ens33`). You will need this string.
3. Phase 2: Accessing the Netplan Architecture:
* The master configuration files are stored in a specific directory. You must use a text editor (like Nano) with root privileges to modify them.
* Type exactly: ls /etc/netplan/
* Press Enter to view the filename (usually `00-installer-config.yaml` or `50-cloud-init.yaml`).
* Type exactly: sudo nano /etc/netplan/00-installer-config.yaml (replace the filename with yours).
4. Phase 3: The YAML Injection Protocol:
* Critical Warning: YAML architecture relies entirely on precise physical indentation (spaces, not tabs). A single misaligned space will crash the network daemon.
* Modify the file to look exactly like this structure, substituting your specific NIC name (`eth0`) and target IP (`192.168.1.50`):

network:
version: 2
ethernets:
eth0:
dhcp4: false
addresses: [192.168.1.50/24]
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]

* Press Ctrl + O, then Enter to save. Press Ctrl + X to exit Nano.
5. Phase 4: The Execution and Verification:
* You must command the Netplan utility to parse the new YAML logic and inject it into the active kernel.
* Type exactly: sudo netplan apply
* Press Enter. (If you are connected via SSH, your session will instantly freeze and drop if you changed the IP. You must reconnect using the new static IP).
* Type ip a to mathematically verify the new IP is locked onto the interface.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.