Thursday 2 April 2020

NMCLI - Network Manager Command Line Interface

To troubleshooting network in Linux we need to first find the status of the device. here i am using the virtual box for it
to find the status of the device
nmcli device status 
nmcli connection show # shows connection profiles






to add the new profile  #must run with sudo privileges
nmcli connection add type ethernet con-name <profile name> ifname enp0s3

adding the ip address to profile manual method not DHCP
nmcli connection modify <profile name> ipv4.addresses 192.168.2.1/24 ipv4.gateway 192.168.2.254 ipv4.dns 192.168.2.254 +ipv4.dns 4.4.4.4 (2nd DNS) connection.autoconnect yes ipv4.method manual

nmcli connection up <profile name> #to bring up connection


if it still cause any issue one option is to restart network with the current configuration files
systemctl restart newtwork

Here is more nmcli commands to troubleshoot

view the configuration file list
/etc/sysconfig/network-scripts
Configure a network card using Text Based User Interface:

backp the configuration  
cp /etc/sysconfig/network-scripts/ifcfg-enp0s3 /tmp/
sudo nmtui # configure the ip addresses using the TUI
edit the configuration as required
deactivate and then reactivate
sudo ifdown enp0s3
sudo ifup enp0s3 
 
see the changes 
 
ip addr show enp0s3  #to display interface details
ip route  #to display the ip route


No comments:

Post a Comment