CentOS RHEL 7 NIC START ONBOOT NMCLI COMMAND LINE

Most posts will tell you to edit the ifcfg-XXX file and set ONBOOT=yes. However for better 7 CENTOS/RHEL scripting, I think it is better to use the NMCLI command line to set the ONBOOT option.

To set the onboot option without directly modifying the ifcfg-xxx file:

nmcli con mod eno16777984 connection.autoconnect yes

This will change the ONBOOT=no to ONBOOT=yes in the default file /etc/sysconfig/network-scripts/ifcfg-eno16777984

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777984
UUID=2dd06c83-77d3-4219-ad26-69c33cb7aa1b
DEVICE=eno-ansible
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no