# Network Interfaces

A slightly annoying change with centOS 7 is that the network interfaces have changed naming convention. You may notice when running ifconfig that the primary network interface is set to something like ens2344 or some other random number. This naming is dynamic typically by hardware id and we don’t want this to fluctuate when provisioning the blueprint in various VMware environments. Fortunately, there is a way to turn this functionality off and restore the interface back to eth0.

Firstly we need to adjust our bootloader to disable interface naming like this.

```
```
sed -i -e 's/quiet/quiet net.ifnames=0 biosdevname=0/' /etc/default/grub  
grub2-mkconfig -o /boot/grub2/grub.cfg
```
```

The above command adds a few arguments to the kernel args list (namely `net.ifnames=0` and `biosdevname=0`. It may be useful to view the `/etc/default/grub` file and ensure these settings were indeed applied.

The next step is to adjust the network-scripts in centOS. we need to ensure we have a file called `/etc/sysconfig/network-scripts/ifcfg-eth0`

Below is a script that we run on our packer builds to prepare the machines network configuration files.

```
```
export iface_file=$(basename "$(find /etc/sysconfig/network-scripts/ -name 'ifcfg*' -not -name 'ifcfg-lo' | head -n 1)")  
export iface_name=${iface_file:6}  
echo $iface_file  
echo $iface_name  
sudo mv /etc/sysconfig/network-scripts/$iface_file /etc/sysconfig/network-scripts/ifcfg-eth0  
sudo sed -i -e "s/$iface_name/eth0/" /etc/sysconfig/network-scripts/ifcfg-eth0  
sudo bash -c 'echo NM_CONTROLLED=\"no\" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
```
```

This script tries to ensure there is a new ifcfg-eth0 config created to replace the old ens config file. Please do verify this config exists after running. If it does not you will have to be sure to build one on your own.

```
```
TYPE=Ethernet  
DEVICE=eth0  
NAME=eth0  
ONBOOT=yes  
NM_CONTROLLED="no"  
BOOTPROTO="dhcp"  
DEFROUTE=yes
```
```
