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.
分类:Default