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"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none" ## none static static, dhcp dynamic
DEFROUTE="yes" ## default route
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33" ## interface name
UUID="e20ba92f-11c2-49b4-8542-36b5a3879173" ## unique UUID
DEVICE="ens33"
ONBOOT="yes" ## enable on boot
IPADDR=192.168.1.199 ## IP address
NETMASK=255.255.255.0 ## subnet maskOn CentOS 7, restart the network service with systemctl restart network .
Using nmcli
nmcli c reload
nmcli c up xxxExperiment: 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
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens37"
DEVICE="ens37"
ONBOOT="yes"
IPADDR=192.168.1.188
NETMASK=255.255.255.0
GATEWAY=192.168.1.1 nmcli c reload
ifdown ens37
ifup ens37After bringing the interface up, ifconfig ens37 shows the new IP configuration.
[root@myserver ~]# cd /etc/sysconfig/network-scripts/
[root@myserver network-scripts]# ls
ifcfg-ens33 ifcfg-ens37 ifcfg-ens37-1
[root@myserver network-scripts]# mv ifcfg-ens37 ifcfg-ens37~~~~
[root@myserver network-scripts]# ls
ifcfg-ens33 ifcfg-ens37~~~~ ifcfg-ens37-1
[root@myserver ~]# nmcli connection modify ens37 ipv4.addresses 192.168.1.189
[root@myserver ~]# ifconfig ens37
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.188 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::20c:29ff:fe94:173a prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:94:17:3a txqueuelen 1000 (Ethernet)
RX packets 449 bytes 47699 (46.5 KiB)
TX packets 530 bytes 59159 (57.7 KiB)
[root@myserver ~]# nmcli connection reload
[root@myserver ~]# nmcli connection up ens37
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)
[root@myserver ~]# ifconfig ens37
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.189 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::20c:29ff:fe94:173a prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:94:17:3a txqueuelen 1000 (Ethernet)
RX packets 500 bytes 52058 (50.8 KiB)
TX packets 582 bytes 64767 (63.2 KiB)Common nmcli Commands
# nmcli connection # list connections
# nmcli con xxx # show details of a connection
# nmcli connection show xxx # show interface details
# nmcli connection show --active# list active connections
# nmcli connection delete ens37 # delete a connection
# nmcli connection modify ens37 ipv4.addresses 192.168.1.189
# nmcli connection modify ens37 ipv4.addresses 192.168.1.189/24 # set netmask
# nmcli connection modify ens37 ipv4.method manual # set static method
# nmcli connection modify ens37 +ipv4.addresses 192.168.1.189/24
# nmcli connection modify ens37 -ipv4.addresses 192.168.1.189/24
# nmcli connection modify ens37 ipv4.gateway 192.168.0.2
# nmcli connection modify ens37 ipv4.dns 114.114.114.114
# nmcli connection modify ens37 -ipv4.dns 114.114.114.114
# nmcli c reload
# nmcli c up ens37The article concludes with a reminder to follow the DevOps Cloud Academy for more content.
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.