Linux System Network Management with ifconfig, ip, and nmcli
This guide explains Linux network fundamentals, shows how to view and configure network interfaces using ifconfig, ip, and the nmcli tool, and provides step‑by‑step examples of editing ifcfg files and applying changes on CentOS 7 systems.
Network Basics
IP addresses identify machines on a network (IPv4/IPv6). DNS resolves domain names to IP addresses, and a gateway (router) connects local networks to external networks.
Viewing Interface Information
Use ifconfig to list all interfaces, ifconfig ens33 for a specific NIC, or ip addr for detailed address information.
Network Interface Configuration Files
Configuration files are located in /etc/sysconfig/network-scripts. For example, ens33 corresponds to ifcfg-ens33 and ens35 to ifcfg-ens35.
TYPE="Ethernet"<br/>PROXY_METHOD="none"<br/>BROWSER_ONLY="no"<br/>BOOTPROTO="none" ## none static static, dhcp dynamic<br/>DEFROUTE="yes" ## default route<br/>IPV4_FAILURE_FATAL="no"<br/>IPV6INIT="yes"<br/>IPV6_AUTOCONF="yes"<br/>IPV6_DEFROUTE="yes"<br/>IPV6_FAILURE_FATAL="no"<br/>IPV6_ADDR_GEN_MODE="stable-privacy"<br/>NAME="ens33" ## interface name<br/>UUID="e20ba92f-11c2-49b4-8542-36b5a3879173" ## unique UUID<br/>DEVICE="ens33"<br/>ONBOOT="yes" ## enable on boot<br/>IPADDR=192.168.1.199 ## IP address<br/>NETMASK=255.255.255.0 ## subnet maskOn CentOS 7, restart the network service with systemctl restart network.
Using nmcli nmcli c reload<br/>nmcli c up xxx Experiment: Adding a Test NIC
Copy an existing configuration file, modify the IP address, netmask, and gateway, then bring the interface up.
cp ifcfg-ens33 ifcfg-ens37 [root@myserver network-scripts]# cat ifcfg-ens37<br/>TYPE="Ethernet"<br/>PROXY_METHOD="none"<br/>BROWSER_ONLY="no"<br/>BOOTPROTO="none"<br/>DEFROUTE="yes"<br/>IPV4_FAILURE_FATAL="no"<br/>IPV6INIT="yes"<br/>IPV6_AUTOCONF="yes"<br/>IPV6_DEFROUTE="yes"<br/>IPV6_FAILURE_FATAL="no"<br/>IPV6_ADDR_GEN_MODE="stable-privacy"<br/>NAME="ens37"<br/>DEVICE="ens37"<br/>ONBOOT="yes"<br/>IPADDR=192.168.1.188<br/>NETMASK=255.255.255.0<br/>GATEWAY=192.168.1.1 nmcli c reload<br/>ifdown ens37<br/>ifup ens37After bringing the interface up, ifconfig ens37 shows the new IP configuration.
[root@myserver ~]# cd /etc/sysconfig/network-scripts/<br/>[root@myserver network-scripts]# ls<br/>ifcfg-ens33 ifcfg-ens37 ifcfg-ens37-1<br/>[root@myserver network-scripts]# mv ifcfg-ens37 ifcfg-ens37~~~~<br/>[root@myserver network-scripts]# ls<br/>ifcfg-ens33 ifcfg-ens37~~~~ ifcfg-ens37-1<br/>[root@myserver ~]# nmcli connection modify ens37 ipv4.addresses 192.168.1.189<br/>[root@myserver ~]# ifconfig ens37<br/>ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500<br/> inet 192.168.1.188 netmask 255.255.255.255 broadcast 0.0.0.0<br/> inet6 fe80::20c:29ff:fe94:173a prefixlen 64 scopeid 0x20<link><br/> ether 00:0c:29:94:17:3a txqueuelen 1000 (Ethernet)<br/> RX packets 449 bytes 47699 (46.5 KiB)<br/> TX packets 530 bytes 59159 (57.7 KiB)<br/>[root@myserver ~]# nmcli connection reload<br/>[root@myserver ~]# nmcli connection up ens37<br/>Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)<br/>[root@myserver ~]# ifconfig ens37<br/>ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500<br/> inet 192.168.1.189 netmask 255.255.255.255 broadcast 0.0.0.0<br/> inet6 fe80::20c:29ff:fe94:173a prefixlen 64 scopeid 0x20<link><br/> ether 00:0c:29:94:17:3a txqueuelen 1000 (Ethernet)<br/> RX packets 500 bytes 52058 (50.8 KiB)<br/> TX packets 582 bytes 64767 (63.2 KiB)Common nmcli Commands
# nmcli connection # list connections<br/># nmcli con xxx # show details of a connection<br/># nmcli connection show xxx # show interface details<br/># nmcli connection show --active# list active connections<br/># nmcli connection delete ens37 # delete a connection<br/># nmcli connection modify ens37 ipv4.addresses 192.168.1.189<br/># nmcli connection modify ens37 ipv4.addresses 192.168.1.189/24 # set netmask<br/># nmcli connection modify ens37 ipv4.method manual # set static method<br/># nmcli connection modify ens37 +ipv4.addresses 192.168.1.189/24<br/># nmcli connection modify ens37 -ipv4.addresses 192.168.1.189/24<br/># nmcli connection modify ens37 ipv4.gateway 192.168.0.2<br/># nmcli connection modify ens37 ipv4.dns 114.114.114.114<br/># nmcli connection modify ens37 -ipv4.dns 114.114.114.114<br/># nmcli c reload<br/># nmcli c up ens37The article concludes with a reminder to follow the DevOps Cloud Academy for more content.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
