Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Configure Network Connection Using nmcli Tool in Linux

October 28, 2022
in Blog, Linux
0
ADVERTISEMENT

Table of Contents

NetworkManager Command Line Interface nmcli

Abbreviated as nmcli, the network manager command-line interface is a nifty and easy to use tool that saves you lots of time when you need to configure an IP address.

It’s strongly recommended to set static IP address on your Linux system specially on servers. The main benefit of static IP address is that it will be persistent across the reboots.

To display all the active network interfaces on your Linux system execute the command.

sudo nmcli connection show
Note Note that con is the truncated form of connection, and you will still end up with the same result as shown.
sudo nmcli con show
# sudo nmcli con show
NAME    UUID                                  TYPE      DEVICE
ens160  143be423-aa84-393f-87e2-9a1866acf705  ethernet  ens160

Also, you can run the command below to display both active and inactive interfaces.

sudo nmcli dev status
# nmcli dev status
DEVICE  TYPE      STATE      CONNECTION
ens160  ethernet  connected  ens160
lo      loopback  unmanaged  --

Set Static IP Address Using nmcli Tool

Using nmcli tool, you can modify a network interface to use a static IP address. In this example, we will modify the network interface ens160 to use a static IP.

# sudo nmcli con show
NAME    UUID                                  TYPE      DEVICE
ens160  143be423-aa84-393f-87e2-9a1866acf705  ethernet  ens160

The current IP address is 192.168.1.104 with a CIDR of /24. We are going to configure a static IP with the following values:

# ip -br -4 a
lo               UNKNOWN        127.0.0.1/8
ens160           UP             10.10.5.91/16
IP address:		      192.168.1.10/24
Default gateway:      192.168.1.1
Preferred DNS:		  8.8.8.8, 1.1.1.1
IP addressing: 		  static

1. First, run the following commands below to set up the IP address, default gateway and DNS servers for the network interface named ens160.

sudo nmcli con modify 'ens160' ipv4.addresses 192.168.1.10/24
sudo nmcli con modify 'ens160' ipv4.gateway 192.168.1.1
sudo nmcli con modify 'ens160' ipv4.dns "1.1.1.1,8.8.8.8"

2. Next, change the addressing from DHCP to static.

sudo nmcli con modify 'ens160' ipv4.method manual

3. To save the changes and apply the configurations, run the following command:

Note Note: If you're connecting to the server remotely, your ssh session will be disconnected. You need open another remote section with new ip address.
sudo nmcli con up 'ens160'

4. To confirm the IP address was changed, once again run the command:

# ip -br -4 a
lo               UNKNOWN        127.0.0.1/8
ens160           UP             10.10.5.92/16

And this concludes this guide on configuring network connection using nmcli command-line tool on Linux. We hope you found this guide helpful.

ADVERTISEMENT
5/5 - (1 vote)
Previous Post

How to Use NMState Networking Config Tool in Linux

Next Post

How to Fix The ifconfig Command Not Found Error in Linux

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory