How To Assign Ip Address In Linux

4 min read

Assigning a static IP address in Linux is a fundamental skill that every system administrator, developer, and advanced user should master. Which means whether you are setting up a home server, configuring a development environment, or managing a remote machine, understanding how to assign ip address in linux ensures that your device maintains a consistent network identity. But unlike dynamic IP assignment via DHCP, a static address remains fixed unless manually changed, making it ideal for services that require reliable connectivity such as web servers, databases, or network printers. In practice, in this guide, we will walk through the various methods available across different Linux distributions, explain the underlying network concepts, and provide troubleshooting tips for common obstacles. By the end, you will feel confident in permanently configuring an IP address using both command-line and graphical tools, made for your specific Linux flavor.

It sounds simple, but the gap is usually here.

Introduction

Before diving into the technical steps, it is the kind of thing that makes a real difference. In most home and office networks, devices rely on DHCP (Dynamic Host Configuration Protocol) to automatically receive an IP address, subnet mask, default gateway, and DNS settings. While convenient, DHCP can

change the assigned address periodically or when a device reconnects, which can break services like SSH or web servers that clients need to find consistently. A static IP eliminates this uncertainty, providing a permanent address that other devices and network services can rely on No workaround needed..

No fluff here — just what actually works.

The approach you take depends heavily on your Linux distribution and whether you prefer a command-line or graphical interface. Modern distributions like Ubuntu, CentOS, and Fedora have largely moved away from manual configuration files in favor of more manageable tools, while older systems or specific setups still use the traditional methods That's the part that actually makes a difference. That alone is useful..

Method 1: Using NetworkManager (nmcli) - The Modern Standard

For most contemporary desktop and server distributions, NetworkManager is the default. Its command-line tool, nmcli, offers a powerful and scriptable way to configure connections without needing to edit configuration files directly That's the part that actually makes a difference..

First, identify the connection you want to modify. Still, g. Run nmcli connection show to list all configured connections. Now, note the exact name of the one you wish to change (e. , "Wired connection 1").

To assign a static IP, you will modify the connection's IPv4 settings. The command below sets a static address, gateway, and DNS server. Replace the placeholders with your network details.

nmcli connection modify "Connection_Name" ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8

After applying the changes, you must bring the connection down and back up for them to take effect.

nmcli connection down "Connection_Name"
nmcli connection up "Connection_Name"

Method 2: Editing Configuration Files - The Traditional Approach

On servers or minimal installations, you may need to edit configuration files directly. The location and format vary by distribution.

On Debian/Ubuntu-based systems, the primary file is /etc/network/interfaces. You would change the relevant stanza from dhcp to static and add the necessary parameters Worth knowing..

auto eth0
iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4

On Red Hat/CentOS/Fedora systems, the configuration is split into separate files within /etc/sysconfig/network-scripts/. For an interface named eth0, you would edit the file ifcfg-eth0:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
ONBOOT=yes

After editing these files, you typically need to restart the networking service with systemctl restart networking or bring the interface down and up with ifdown eth0 && ifup eth0 Not complicated — just consistent..

Method 3: Graphical Tools

For desktop users, the NetworkManager applet provides a straightforward GUI. Click the network icon, select "Settings," choose your connection, manage to the IPv4 tab, change the method from "Automatic (DHCP)" to "Manual," and enter your IP address, netmask, gateway, and DNS servers Small thing, real impact..

Verification and Troubleshooting

After applying any method, verify your configuration with ip addr show or the older ifconfig command. Test connectivity by pinging your gateway (ping 192.On top of that, 8). In real terms, 1. In practice, 8. Which means 8. You should see your new static IP assigned to the interface. 1) and an external site (ping 8.In real terms, 168. If you encounter issues, double-check for typos in the configuration, ensure the interface is active, and verify that the IP address does not conflict with another device on the network.

Conclusion

Mastering static IP assignment in Linux is a cornerstone of reliable network management. In practice, whether you make use of the modern nmcli tool for its flexibility, edit distribution-specific configuration files for granular control, or prefer the graphical interface for simplicity, the goal remains the same: to provide your system with a permanent, predictable network identity. By following the methods outlined for your specific environment, you can confirm that critical services remain accessible and your network infrastructure operates with the stability that static addressing provides.

Just Made It Online

Just Went Live

Similar Territory

Also Worth Your Time

Thank you for reading about How To Assign Ip Address In Linux. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home