Adding a virtual bridge using nmcli involves several steps. A virtual bridge is commonly used in networking to connect multiple virtual or physical network interfaces.
Learn how to easily convert your IP address from DHCP to static using NMCLI. Follow our step-by-step guide for seamless configuration on Linux systems.
Are you tired of dealing with fluctuating IP addresses assigned by your DHCP server? Maybe you’re setting up a server or a networked device that needs a stable, static IP address. Fear not! In this guide, we’ll walk you through the process of converting your IP address from DHCP to static using NMCLI.
Before we delve into the conversion process, let’s quickly distinguish between DHCP and static IP addresses:
Dynamic Host Configuration Protocol (DHCP): This protocol automatically assigns IP addresses to devices within a network. It’s convenient for environments where devices frequently join and leave the network, as it manages IP address allocation dynamically.
Static IP Address: In contrast, a static IP address is manually configured for a device and remains constant. It’s beneficial for devices that require a consistent IP address for tasks like hosting servers or accessing networked services reliably.
There are several reasons why you might want to switch from DHCP to a static IP address:
Reason | Description |
---|---|
Server Configuration | Ensures consistent accessibility when setting up a server. |
Networked Devices | Required for devices like printers, NAS, or IoT devices for reliable communication. |
Port Forwarding | Essential for enabling external access to specific services via port forwarding on your network. |
NMCLI, or Network Manager Command-Line Interface, is a powerful tool for managing network configurations in Linux-based systems. Here’s how you can use NMCLI to convert your IP address from DHCP to static:
Before making any changes, it’s essential to know your current network configuration. Open a terminal window and enter the following command:
nmcli connection show
NAME UUID TYPE DEVICE
Wired connection 1 2193e2e3-933e-30cd-9923-835f65f8788c ethernet eno1
lo 2c17ece3-8e43-451a-ba10-83a283138dea loopback lo
Verizon_7X8KZK daadd47b-31fa-494c-b951-d0409be5d620 wifi --
This command will display (see sample output above) a list of network connections along with their settings.
Identify the network connection for which you want to switch to a static IP address. Note down its name; it usually follows the format “enoX” or “ethX,” or “enpX”, where X is a number.
Now, let’s convert the selected connection to use a static IP address. Replace “ConnectionName” with the name of your network connection and adjust the IP address, gateway, and DNS servers according to your network configuration:
sudo nmcli connection modify ConnectionName ipv4.method manual ipv4.address 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8
In this command:
ipv4.method manual
sets the IP address assignment method to manual (static).ipv4.address
specifies the desired static IP address and subnet mask.ipv4.gateway
defines the default gateway for the network.ipv4.dns
sets the DNS server address.Apply the changes to activate the new network configuration:
sudo nmcli connection up ConnectionName
Congratulations! You’ve successfully converted your IP address from DHCP to static using NMCLI.
Converting your IP address from DHCP to static provides stability and control over your network configuration. With NMCLI, the process is straightforward and can be accomplished with just a few commands in the terminal. Whether you’re setting up a server or configuring networked devices, switching to a static IP address ensures consistent connectivity and smoother operations.
Did you find this article useful? Your feedback is invaluable to us! Please feel free to share your thoughts in the comments section below.
Related Posts
Adding a virtual bridge using nmcli involves several steps. A virtual bridge is commonly used in networking to connect multiple virtual or physical network interfaces.
In the article, we’ll delve into how to manage network connections using the NMCLI utility, a powerful command-line tool for configuring and controlling NetworkManager, which
Discover the convenient and efficient way to change IPv4 addresses on your Linux machine using the nmcli utility, and take control of your network settings