Network Configuration After CentOS Minimal Installation
Getting Started
After installing CentOS minimal, the ifconfig command may not exist.
[root@localhost home]# ifconfig
bash: ifconfig: command not found
When checking the IP address with ip addr, the IP address may also not be assigned. This happens because the network has not been configured yet.
Configuring the NIC
First, switch to the root account and move to /etc/sysconfig/network-scripts. Then check the files.
cd /etc/sysconfig/network-scripts/
ls ifcfg*
The ifcfg-eth0 file contains the NIC configuration. The name eth0 can differ depending on the environment.
Dynamic Address
Change ONBOOT=no to ONBOOT=yes to enable DHCP.
Static Address
To use a static address, change BOOTPROTO=dhcp to BOOTPROTO=static and add values such as the following.
IPADDR=192.168.100.123
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
DNS1=168.126.63.1
DNS2=168.126.63.2
Restarting the Network Service
Restart the network service.
service network restart
ip addr show
If configured correctly, the interface will show an assigned IP address.
Installing Network Tools
After confirming connectivity, install network tools to use ifconfig.
yum install net-tools
net-tools is a collection of basic networking utilities. Modern Linux systems often use replacement commands such as ip addr instead of ifconfig, ip route instead of route, and ip neigh instead of arp.