ifconfig command not found at CentOS 7 minimal installation

The error “ifconfig command not found” occurs. Actually, the command of ifconfig is obsolete, and is unavailable at CentOS 7 minimal installation.

Assign an IP to access internet

If you insist on running this command, firstly, you might to assign an IP to your host as follows.

Get the interface name

Run “ip addr” to  get the interface name, for example “ens33”

Edit the interface configuration file

The configuration file will be “/etc/sysconfig/network-scripts/ifcfg-ens33”. There’re two methods to set its IP. One is to set an dynamic IP from DHCP, and another is to set a static IP.

Set an dynamic IP from DHCP

Change “ONBOOT=no” to “ONBOOT=yes”, and reboot the host, then it’ll access internet. The total context will be look like as follows.

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
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=ens33
UUID=8fffee13-4c86-46d1-9b34-84ca2074340e
DEVICE=ens33
ONBOOT=yes
[root@localhost ~]#

Set a static IP

Change “ONBOOT=no” to “ONBOOT=yes”, add a static IP into the configuration file, close DHCP feature, and reboot the host, then it’ll access internet.

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
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=ens33
UUID=8fcfea13-4c86-46de-9b34-84c92074340e
DEVICE=ens33
ONBOOT=yes
IPADDR0=192.168.1.131
PREFIX0=24
GATEWAY0=192.168.1.1
DNS1=192.168.1.1
[root@localhost ~]#

Install the command of ifconfig

Now the host has internet access, you’d run “yum install net-tools” to get the command of ifconfig.

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.