[CentOS] how to activate the network after an installation

Mon Jan 21 10:56:52 UTC 2019
Gianluca Cecchi <gianluca.cecchi at gmail.com>

On Mon, Jan 21, 2019 at 11:40 AM Ralf Prengel <ralf.prengel at rprengel.de>

> Hallo,
> I can t find the switch to activate the network after an installation
> without gui.
> service network start doesn t work and I don t find any other commands.
> Thanks for a hint.
> Ralf
Possibly during install you set the network connection but you didn't check
the auto start check box, that is in the first label at the left of the
network configuration page for that interface.
If this is the case, if you are connected from console, and you defaulted
to use NetworkManager (you can verify with "systemctl status
NetworkManager"), these would be the commands:

You have devices and connections, that are different things; in my case an
automatic install has created a device named ens192 and also a connection
with the same name.

- device information
[root at c7 ~]# nmcli dev status
virbr0      bridge    connected  virbr0
ens192      ethernet  connected  ens192
lo          loopback  unmanaged  --
virbr0-nic  tun       unmanaged  --
[root at c7 ~]#

Last column gives connection name; one device could have many connections
associated to it and you decide which is started in automatic for example

- connections information
[root at c7 ~]# nmcli con show
NAME    UUID                                  TYPE            DEVICE
ens192  9fb1de04-fda3-4db9-820e-d266e151ac73  802-3-ethernet  ens192
virbr0  343ede6f-b7b0-4f73-a6f7-2bc9aee34d4a  bridge          virbr0
[root at c7 ~]#

- configuration of start type for the connection ens192
[root at c7 ~]# nmcli con show ens192 | grep -i connection.auto
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-slaves:          -1 (default)
[root at c7 ~]#

- set to auto if it is not so yet
[root at c7 ~]# nmcli con mod ens192 autoconnect yes

- down and up
[root at c7 ~]# nmcli con down ens192
[root at c7 ~]# nmcli con up ens192

- reboot to verify that autoconnects