[LINUX] CentOS 7 network initialization


After installing CentOS7.7 How to configure network settings I think there is a part to worry about, so I will specify the procedure.


Condition: CentOS 7.7 is already installed Select Infrastructure Server for software at installation



First, log in with an account that has administrator privileges.


localhost login:

Confirmation of administrator privileges

Make sure the prompt is "#". If it is "$", log in as a user who does not have administrator privileges. Since it is, log in again as root.


[root@localhost ~]#

Check NIC

Check the NIC information to be set.


[root@localhost ~]#nmcli d

Check network information

Check the C network information to be set.


[root@localhost ~]#nmcli c show 

network settings

Enter the network setting command.

Here, the network settings are as follows. IP address: Subnet: Gateway: DNS: NIC: eth0


[root@localhost ~]#nmcli c mod eth0 ipv4.method manual ipv4.addresses ipv4.gateway ipv4.dns connection.autoconnect yes

Of course, you can set them separately.


#Enabling the interface called eth0(If it is disabled, communication is not possible even if the IP address is set.)
[root@localhost ~]#nmcli c modify eth0 connection.autoconnect yes

#eth0 IP address and subnet settings
[root@localhost ~]#nmcli c modify eth0 ipv4.addresses 

#Setting the default gateway for eth0
[root@localhost ~]#nmcli c modify eth0 ipv4.gateway

#Disable DHCP for eth0
[root@localhost ~]#nmcli c modify eth0 ipv4.method manual

#DNS settings for eth0
[root@localhost ~]#nmcli c modify eth0 ipv4.dns

Restart NetworkManager service

Enter the following command to restart the NetworkManager service.


[root@localhost ~]#systemctl restart NetworkManager

Restart network services

Enter the following command to restart the network service


[root@localhost ~]#systemctl restart NetworkManager

Check for network settings updates

Check if the network settings are set correctly.

It is OK if the following settings are reflected. BOOTPROTO = no (DHCP disabled) IPADDR = (IP address) PREFIX = 24 (subnet) ONBOOT = yes (NIC enabled: enabled after reboot) GATEWAY = (gateway) DNS1= (Google Public DNS)


[root@localhost ~]#cat /etc/sysconfig/network-script/ifcfg-eth0

NIC activation confirmation

(Just in case) Check if the NIC is enabled with the following command.


#It is OK if eth0 is connected.
[root@localhost ~]#nmcli d 

Communication confirmation by PING

Return to the CentOS screen and ping (Google Public DNS).


#If the ping is successful, you have successfully connected to the external network.
#If it fails, you must first disable selinux settings and Firewalld services.
[root@localhost ~]#ping

At the end

If you have created CentOS 7.7 with a hypervisor, Check that the NIC value may be different.

Also, if communication is not possible even after enabling the NIC, If the NIC settings on the hypervisor side are disabled, or Even if the NIC is not assigned on the virtual machine in the first place Please check it because it is there.

The basic settings after network settings are as follows. Initial network settings for CentOS 7 after installation In addition, I referred to the following site. [How to set up the network with NetworkManager_CLI_ (nmcli) ](How to set up the network with http://www.maruko2.com/mw/NetworkManager_CLI(nmcli)_)

That is all.

Recommended Posts

CentOS 7 network initialization
CentOS 7 basic settings after network settings
[RHEL / CentOS 8] Network settings memo
[CentOS] Network check / change command [RHEL]
Network settings and confirmation in CentOS7
Disable IPv6 on network interface on CentOS Linux 8
Relational Network
CentOS8 server construction (network opening and package update)