Mastering CentOS 7 Network Configuration: ifconfig, ifup, ifdown & More
This guide explains how to use ifconfig to view and modify network interfaces, manage them with ifup/ifdown, and configure CentOS 7 networking through key files such as /etc/sysconfig/network-scripts, plus essential supplementary ip commands and troubleshooting tips for virtual machine MAC address issues.
1. ifconfig Network Parameters
ifconfig allows you to manually start, observe, and modify network interface parameters.
[root@linux ~]# ifconfig {interface} {up|down} # Observe and start interface
[root@linux ~]# ifconfig interface {options} # Set and modify interface
# Parameters:
# Interface – network device name (e.g., eth0, eth1, ppp0)
# Options – up/down, mtu, netmask, broadcast, etc.
# Example: view all interfaces
[root@linux ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0F:EA:A3:06:A2
inet addr:192.168.10.100 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20f:eaff:fe73:682/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3439 errors:0 dropped:0 overruns:0 frame:0
TX packets:2735 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:646935 (631.7 KiB) TX bytes:562313 (549.1 KiB)Running ifconfig without arguments lists all active interfaces, regardless of whether they have an IP address. Specifying an interface name (e.g., ifconfig eth0) shows detailed data for that interface.
eth0 – interface name (also lo for loopback). HWaddr – hardware (MAC) address. inet addr – IPv4 address; Bcast and Mask represent broadcast and netmask. inet6 addr – IPv6 address (not covered here). RX – received packets, errors, dropped, etc. TX – transmitted packets and related statistics. collisions – packet collisions count. txqueuelen – length of the transmit queue. RX Bytes / TX Bytes – total bytes received and transmitted. Interrupt, Memory – hardware interrupt and memory address information.
2. ifup and ifdown
To apply configuration files located in /etc/sysconfig/network-scripts (e.g., ifcfg-eth0), use ifup to bring an interface up and ifdown to bring it down.
[root@linux ~]# ifup {interface}
[root@linux ~]# ifdown {interface}
[root@linux ~]# ifup eth0ifup and ifdown are simple scripts that search for the corresponding ifcfg- file in /etc/sysconfig/network-scripts . Ensure the configuration file exists; otherwise the command will fail. After modifying an interface with ifconfig , use ifconfig eth0 down to deactivate it, because ifdown compares the current state with the ifcfg- file and will abort if they differ.
3. CentOS 7 Network Configuration Files
/etc/resolv.conf – DNS configuration. /etc/hosts – hostname to IP mappings. /etc/sysconfig/network – global network and routing information (only the last gateway is effective). /etc/sysconfig/network-scripts/ifcfg‑* – per‑interface configuration files.
Each network interface should have a single configuration file; if multiple files exist, the later one overrides earlier settings. Avoid placing gateway information in the per‑interface file; configure it in /etc/sysconfig/network instead.
4. Default Interface Configuration File in CentOS 7
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
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=eno16777736
UUID=f47bde51-fa78-4f79-b68f-d5dd90cfc698
DEVICE=ens33
ONBOOT=no
HWADDR="00:0C:29:EB:90:72"5. Additional Useful Commands
ip [options] {link|addr|route...}
# ip addr show – display IP information
# ip addr add 192.168.0.1/24 dev eth0 – assign IP
# ip addr del 192.168.0.1/24 dev eth0 – remove IP
# ip link show – display link information
# ip link set eth0 up – bring interface up
# ip link set eth0 down – bring interface down
# ip link set eth0 promisc on – enable promiscuous mode
# ip link set eth0 promisc off – disable promiscuous mode
# ip link set eth0 txqueuelen 1200 – set queue length
# ip link set eth0 mtu 1400 – set MTU
# ip route show or ip route list or route -n – display routing table
# ip route add 192.168.4.0/24 via 192.168.0.254 dev eth0 – add route
# ip route add default via 192.168.0.254 dev eth0 – set default gateway
# ip route del 192.168.4.0/24 – delete route
# ip route del default – delete default route6. Summary
Cloned virtual machines often encounter network issues due to mismatched MAC addresses. Check the new MAC in the VM's network adapter settings, update the HWADDR field in the corresponding file under /etc/sysconfig/network-scripts , and restart the network with systemctl start network . If problems persist, verify or clean the MAC entries in /etc/udev/rules.d/70-persistent-ipoib.rules .
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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
