DEV Community

indhaprls
indhaprls

Posted on

MANAGING NETWORKING

Configuring Networking from the Command Line

IP (Internet Protocol) configuration can be done in several ways, starting from configuring the GUI (Graphical User Interface) or manually by changing files, as well as using NMTUI (Network Manager Text User Interface), and NMCLI (Network Manager Command Line Interface). NMCLI is a command line utility used to control the Network Manager daemon used to configure network interfaces.
With the NMCLI utility, you can view, create, enable, and disable network interfaces or connections. This is especially useful for headless servers and systems that don't have a GUI.
Network Manager is a daemon that unifies and manages network settings. In addition to the daemon, there is the GNOME Notification Area applet that provides network status information. Command line and graphical tools talk to NetworkManager and save configuration files in the /etc/sysconfig/network-scripts directory.

Who Can Modify Network Settings?

only root users can make necessary network configuration changes with NMCLI. Normal users logged in using SSH do not have access to change network permissions without being root.

Viewing Network Information

to be able to see the status of all network devices, you can use the command nmcli dev status

Image description

To be able to see a list of all connections, you can use the command nmcli con show.add --active option to see active connections.

Image description

Add Network Connection

use the nmcli con add command to add a new network connection. The command can add a new connection named eno2 interface eno2, which gets IPv4 network information using DHCP and auto-connection at startup. The configuration file name is based on the value of the con-name option, eno2, and is saved to the /etc/sysconfig/network-scripts/ifcfg-eno2 file.

Image description

you can create an eno2 connection for eno2 device with a static IPv4 address, using the IPv4 address and default IPv4 gateway. but it still auto-connects on startup and saves its configuration into the same file.

Image description

you can also create eno2 connections for eno2 devices with static IPv6 and IPv4 addresses, using IPv6 addresses, default IPv6 gateways, IPv4 addresses, and default IPv4 gateways.

Image description

Controlling Network Connection

to activate the connection name can use the command nmcli con up name

Image description

to disconnect or disable the network interface can use the command nmcli dev dis device. you can also use the nmcli con down name command, but the nmcli con down name command is not the best way to disable network interfaces as it degrades the connection.

Image description

Modifying Network Connection Settings

to see in detail the connection can use the command nmcli con show name. name is the connection name.

Image description

to change the connection settings, you can use the command nmcli con mod name. You can also add some options. for example, nmcli con mod name by adding ipv4 address options and default ipv4 gateway or you can also add ipv6 address options and default ipv6 gateway

Image description

Image description

If the connection that gets IPv4 information from the DHCPv4 server is changed to get it from a static configuration file only, the ipv4.method setting must also be changed from auto to manual. Likewise for connections getting their IPv6 information by SLAAC or a DHCPv6 server, the ipv6.method setting must also be changed from auto or dhcp to manual. If you want to change the connection settings to static, you can use the command nmcli con mod name ipv4.method manual

Delete Network Connection

to delete a connection, you can use the command nmcli con del name. the command can disconnect it from the device and delete the file.

Top comments (0)