MANAGING NETWORKING
Published: 2022-10-02 06:30:31

###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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rgowr88w9epfm59yl4pf.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/141am0hxu110b49sg7fr.jpg)

####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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fjk2o0si72n5cmpqxmln.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pt79y4ckn59ur00g5h4j.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxm37s3vqxi3hcqjyk8r.jpg)

####Controlling Network Connection
to activate the connection name can use the command **nmcli con up _name_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxgln64de0kodzt1xr3v.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0d55vcbis0hp3jbqvbwf.jpg)

####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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbyctlijpj5cq82i45i1.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2p4stksgxwcof4yuojgy.jpg)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e5e0omfy1mbor7gmf775.jpg)

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.