1. Why You Need a Static IP
A static IP makes your server reachable at a predictable address, critical for services like Asterisk, SSH, and web apps. DHCP‑assigned addresses can change, breaking SIP registrations and firewall rules.
2. Prerequisites
A server or VM running a NetworkManager‑enabled distro.
sudo privileges or root access.
The nmtui utility (ships with NetworkManager‑text‑ui). Install if missing:
sudo apt install network-manager network-manager-gnome #Debian/Ubuntu
sudo dnf install NetworkManager-tui #RHEL/Fedora/Rocky3. Step‑by‑Step Guide
3.1 Launch nmtui
sudo nmtui3.2 Select Edit a connection
Use ↑/↓ keys to highlight Edit a connection and press Enter.
3.3 Choose the Network Interface
Highlight your active interface (eth0, ens18, enp1s0, etc.) → Enter.
3.4 Switch IPv4 Method to Manual
Move to IPv4 CONFIGURATION.
Press Enter, choose Manual.
3.5 Enter IP, Gateway & DNS
Fill the fields:
Field | Example |
|---|---|
Address |
|
Gateway |
|
DNS servers |
|
3.6 Save & Quit
Hit OK → Back → Quit.
3.7 Activate the Connection
sudo nmcli connection up <interface-name>Replace <interface-name> with the one you edited (e.g., ens18).
4. Verify the Static IP
ip a | grep -A2 <interface-name>You should see your new IP (192.168.1.50). Test connectivity:
ping -c 4 8.8.8.85. Apply Changes Without Reboot
If you skipped step 3.7:
sudo systemctl restart NetworkManagerOr simply disconnect/reconnect the NIC:
nmcli device disconnect <interface-name>
nmcli device connect <interface-name>6. Common Errors & Fixes
Error | Cause | Fix |
DNS not resolving | Wrong DNS servers | Edit connection → enter correct DNS (1.1.1.1) |
No network after reboot | Wrong subnet mask | Ensure |
Connection activation failed | IP conflict | Pick unused IP, check DHCP pool |
7. Conclusion & Next Steps
You now have a persistent static IP configured via the user‑friendly nmtui tool. This is an essential foundation before installing services like Asterisk or FreePBX.
8. TL;DR for Power Users
sudo nmtui
# Edit connection → <interface> → IPv4 CONFIG → Manual
# Address: 192.168.1.50/24
# Gateway: 192.168.1.1
# DNS: 1.1.1.1,8.8.8.8
sudo nmcli connection up <interface>Static IP vs. DHCP reservation
There are two common ways to give a machine a consistent address. You can set a static IP on the device itself (what this guide does), or you can configure a DHCP reservation on your router so it always hands the same address to that machine's MAC address. Setting it on the device is ideal for servers you fully control; a DHCP reservation is easier to manage centrally for many devices. Whichever you choose, pick an address outside your router's DHCP range to avoid IP conflicts.
Finding the right values to enter
Before editing anything, note your current network details so your static settings match the LAN. Find your default gateway with:
ip route | grep default
And your current address and subnet mask with:
ip a
Then choose a free address in the same subnet. If you're unsure which addresses are valid for your subnet mask, our subnet calculator works it out instantly.
Frequently asked questions
Will nmtui changes survive a reboot?
Yes. nmtui writes a persistent NetworkManager connection profile, so your static configuration is reapplied automatically every time the machine boots.
What if nmtui isn't installed?
Install the NetworkManager text UI using the commands near the top of this guide, or configure the connection directly with nmcli if you prefer the command line.
How do I switch back to DHCP?
Re-open sudo nmtui, edit the same connection, set the IPv4 method back to Automatic, then reactivate the connection.
Which subnet mask should I use?
Match whatever your LAN uses — most home and small-office networks use /24 (255.255.255.0). Confirm your host range with the subnet calculator linked above.
