TOPIC: ROUTING
Automatically enabling your network connection at startup on CentOS 7
15th August 2014CentOS 7's release sparked my curiosity, so I tried it in a VirtualBox virtual machine. It uses GNOME Shell in classic mode, making it feel similar to GNOME 2. One thing to note is that it requires at least VirtualBox version 4.3.14, or the Guest Additions kernel drivers won't compile. This might seem surprising when you learn it uses kernel version 3.10.x and GNOME Shell 3.8.4. Like Debian production releases, CentOS chooses established versions for stability, fitting its enterprise-focused user base. Despite this conservative approach, it still looks good, though trying to change the desktop background froze the machine. Otherwise, most things work well.
However, there are surprises, including one I noticed: network connectivity needed switching on every time the VM started. This occurs with the default installation and has been a known issue since at least CentOS 6. It's not difficult to fix once you know how.
What you need to do is look for the relevant configuration file in /etc/sysconfig/network-scripts/
and update that. Using the ifconfig
command, I found that the name of the network interface. Usually, this is something like eth0, but it was enp0s3
in my case, so I had to look for a file named ifcfg-enp0s3 and edit that. The text that is sought is ONBOOT=no
and that needs to become ONBOOT=yes
for network connections to start automatically. To do something similar from the command line, CentOS had suggested the following:
sed -i -e 's@^ONBOOT="no@ONBOOT="yes@' ifcfg-enp0s3
This uses sed
for an inline (and case-insensitive) edit of the file to change 'no' to 'yes' after accessing the /etc/sysconfig/network-scripts/
directory. I edited manually with Gedit, which also works. Note that file editing needs superuser privileges, so switch to root with the su
command or use sudo
.