Master CentOS7 Network Configuration: ifconfig, ifup/down, and Essential Commands
This guide explains how to use ifconfig, ifup, and ifdown to view and modify network interfaces on CentOS7, details the relevant configuration files, provides default NIC settings, lists additional ip commands, and offers troubleshooting tips for virtual machine network issues.
1. ifconfig network parameters
ifconfig can manually start, view, 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 – possible arguments such as:
up or down – bring the interface up or down (no other parameters)
mtu – set MTU size, e.g., mtu 1500 (bytes)
netmask – subnet mask
broadcast – broadcast address
Example – list 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)
Interrupt:209 Memory:fb000000-0Running ifconfig without arguments lists all active interfaces, showing hardware address, IP, broadcast, netmask, and traffic statistics.
eth0 – interface name (also lo for loopback). HWaddr – MAC address. inet addr – IPv4 address; Bcast and Mask are broadcast and netmask. inet6 addr – IPv6 address (not covered here). RX – received packets, errors, dropped, etc. TX – transmitted packets and related stats. collisions – packet collisions count. txqueuelen – transmit queue length. RX Bytes / TX Bytes – total bytes received and transmitted. Interrupt, Memory – hardware IRQ and memory address.
2. ifup and ifdown
Use ifup and ifdown to apply settings from configuration files located in /etc/sysconfig/network-scripts, such as ifcfg-eth0.
[root@linux ~]# ifup {interface}
[root@linux ~]# ifdown {interface}
[root@linux ~]# ifup eth0ifup and ifdown are simple scripts that read the corresponding ifcfg-ethX file and apply its settings. Ensure the config file exists; otherwise the operation fails. After modifying an interface with ifconfig , use ifconfig eth0 down to deactivate it, because ifdown compares current parameters with the config file and aborts if they differ.
3. CentOS7 network configuration files
/etc/resolv.conf – DNS configuration file /etc/hosts – hostname to IP mapping /etc/sysconfig/network – global network and routing information (only the last gateway is effective) /etc/sysconfig/network-scripts/ifcfg- interface – per‑interface configuration
Each NIC should have a single configuration file; if multiple files exist, the later one overrides earlier settings.
4. Default NIC configuration file (CentOS7)
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 # show interface IP info
# ip addr add 192.168.0.1/24 dev eth0 # add IP address
# ip addr del 192.168.0.1/24 dev eth0 # delete IP address
# ip link show # show link info
# 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 transmit queue length
# ip link set eth0 mtu 1400 # set MTU
# ip route show # 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 a new MAC address. Update the HWADDR in the configuration file under /etc/sysconfig/network-scripts/ and restart the network with systemctl start network . If problems persist, check or delete the MAC entry 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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
