November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Nmcli

let’s start, Type “nmcli d” command in your terminal for quick identification of Ethernet cards installed in your machine.

[root@clusterserver1 ~]# nmcli d
DEVICE       TYPE      STATE      CONNECTION
eno16777736  ethernet  connected  eno16777736
lo           loopback  unmanaged  —

 

[root@clusterserver1 ~]# nmcli connection show
NAME         UUID                                  TYPE            DEVICE
eno16777736  040b2729-2cc5-4ded-af3a-c4ae09dd3563  802-3-ethernet  eno16777736
[root@clusterserver1 ~]# nmcli device show eno16777736
GENERAL.DEVICE:                         eno16777736
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:C4:97:7D
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eno16777736
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         ip = 192.168.1.20/24, gw = 192.168.1.254
IP4.DNS[1]:                             8.8.8.8
IP6.ADDRESS[1]:                         ip = fe80::20c:29ff:fec4:977d/64, gw = ::

 

[root@clusterserver1 ~]# nmcli device show eno16777736  |grep DNS
IP4.DNS[1]:                             8.8.8.8
[root@clusterserver1 ~]#nmcli [ OPTIONS ] OBJECT { COMMAND | help }

 

[root@clusterserver1 ~]# nmcli general status
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN
connected  full          enabled  enabled  enabled  disabled

 

[root@clusterserver1 ~]# nmcli device status
DEVICE       TYPE      STATE      CONNECTION
eno16777736  ethernet  connected  eno16777736
lo           loopback  unmanaged  —

 

Disconnect from network

[root@clusterserver1 ~]#nmcli device disconnect eno16777736

[root@clusterserver1 ~]# nmcli device connect eno16777736
Device ‘eno16777736’ successfully activated with ‘040b2729-2cc5-4ded-af3a-c4ae09dd3563’.
[root@clusterserver1 ~]#

Add ip address gateway details

nmcli connection add type ethernet con-name NAME_OF_CONNECTION ifname INTERFACE-NAME ip4 IP_ADDRESS gw4 GW_ADDRESS

nmcli connection add type ethernet con-name NEW_STATIC ifname eno16777736 ip4 192.168.1.11 gw4 192.168.1.1

nmcli connection modify NEW_STATIC ipv4.dns “8.8.8.8 8.8.4.4”

nmcli connection up NEW_STATIC ifname eno16777736

nmcli -p connection show NEW_STATIC

GUI Mode

Recommended for beginners
Step 1 » Type this command “nmtui” to open Network manager and press enter after choosing ” Edit a connection” ( Use TAB for choosing options ) .

[root@clusterserver1 ~]# nmtui
Command Mode
Step 1 » Network interface config files are located in /etc/sysconfig/network-scripts/ directory. Open eno16777736 file

[root@clusterserver1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=040b2729-2cc5-4ded-af3a-c4ae09dd3563
ONBOOT=yes
HWADDR=00:0C:29:C4:97:7D
IPADDR0=192.168.1.20
PREFIX0=24
GATEWAY0=192.168.1.254
DNS1=8.8.8.8
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

» DHCP configuration

Step 2 » For DHCP
Find the below lines in config File.
BOOTPROTO=none
ONBOOT=no
and replace with
BOOTPROTO=dhcp
ONBOOT=yes
Now Restart network service by typing below command.
systemctl restart network
Now your server will get IP Address from DHCP

» Static configuration

Step 3 » For Static IP.
Find the below lines in config File.
BOOTPROTO=none
ONBOOT=no
and replace with
BOOTPROTO=static
ONBOOT=yes
And add the below lines at the end of the file.
IPADDR0=192.168.1.20
GATEWAY0=192.168.1.254
DNS1=8.8.8.8

File will look like below after changes.
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s17
UUID=f0c5b37d-299a-43cb-b74b-618bb252d129
ONBOOT=yes
HWADDR=00:0C:29:A1:B5:CC
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.5

Now Restart network service by typing below command.
systemctl restart network
Now Interface will have static IP.
Additionally you can use /etc/sysconfig/network file for hostname and DNS .
HOSTNAME=cluster1.rmohan.com
DNS1=192.168.1.254
DNS2=8.8.8.8
SEARCH=rmohan.com

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>