After fresh Linux installation, specially on virtual environment such as VM Ware, VirtualBox etc , interface configuration file may be missing on the system. Here I’m going to guide how to fix missing ifcfg-eth0 or network interface configuration file in Linux.
1) Find available physical interfaces
Following command will output all connected physical interfaces.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@localhost]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:a6:80:73 brd ff:ff:ff:ff:ff:ff inet 192.168.2.25/24 brd 192.168.2.255 scope global ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fea6:8073/64 scope link valid_lft forever preferred_lft forever |
2) Create interface configuration file
you can obtain MAC of the interface from above “ip addr” and it is “00:0C:29:A6:80:73” so HWADDR value is 00:0C:29:A6:80:73 later this value will be added to configuration file. After that you should generate UUID value for the interface from below command.
1 2 |
[root@localhost]#uuidgen eth0 afe22b5c-63f7-411b-b0a3-542eebb0e23 |
vim /etc/sysconfig/network-scripts/ifcfg-eth0
below is completed interface config file
1 2 3 4 5 6 7 8 9 10 |
HWADDR=00:0C:29:A6:80:73 TYPE=Ethernet BOOTPROTO=static NAME=eth0 UUID=afe22b5c-63f7-411b-b0a3-542eebb0e23 ONBOOT=yes IPADDR=192.168.10.25 NETMASK=255.255.255.0 GATEWAY=192.168.10.1 DNS1=8.8.8.8 |
3) Activate new interface
1 |
[root@localhost]#service network restart |
🙂
Note :- Linux physical interface name varies. It can be ens192 etc.. particularly VM Ware environment. Most important fact is, Linux is capable to add multiple IP address to single physical interface by creating virtual interface .