CentOS7 network settings

It seems that command setting is recommended in CentOS7. Set using the nmcli command. It is assumed that the IP address of the local network and router is "192.168.1.1".

First, check the device with "nmcli d".

DEVICE      TYPE      STATE     CONNECTION   
enp0s3 ethernet disconnected--         
lo loopback no management--         

Check enp0s3. Since enp0s3 is a device name, it depends on the device you want to set.

The file to actually set. This is the default. /etc/sysconfig/network-scripts/ifcfg-enp0s3

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=d980175f-0b3e-4fs2-8fe5-4532bbb31b315f
DEVICE=enp0s3
ONBOOT=no

Type the command above to set it.

Step ① Enable the interface

nmcli c m enp0s3 connection.autoconnect yes

Change ONBOOT = no → yes. If no, the network cannot be used.

Step ② IP address setting

nmcli c modify enp0s3 ipv4.address 192.168.1.11/24

IPADDR=192.168.1.11 PREFIX=24 The IP address and subnet mask are set.

Step ③ Setting the default gateway

nmcli c modify enp0s3 ipv4.gateway 192.168.1.1

GATEWAY=192.168.1.1

Step ④ DNS settings

nmcli c modify enp0s3 ipv4.dns 192.168.1.1

DNS=192.168.1.1

Step ⑤ Fix the IP address

nmcli c modify enp0s3 ipv4.method manual

BOOTPROTO = dhcp → changed to none

Step ⑥ Network restart

nmcli c down enp0s3;nmcli c up enp0s3

The settings will not be reflected unless you restart. After restarting, check the settings with the following command.

nmcli d show enp0s3

Step ⑦ Associate the host name and IP address

Add to/etc/hosts.

192.168.1.1 router #router
192.168.1.11 Host name#Own host name

Step ⑧ Check /etc/resolv.conf

nameserver 192.168.1.1

By setting DNS = 192.168.1.1 in step ④, the IP address automatically enters the nameserver.

Procedure ⑨ Confirm communication through ping (local)

ping (-c 3) 192.168.1.11 or own host name
ping (-c 3) 192.168.1.1 or router

OK if there is no packet loss

Step ⑩ Confirm communication through ping (DNS)

ping (-c 3) google.com

Check if ping can be passed to the outside. Access google to try.

Recommended Posts

CentOS7 network settings
CentOS8 bind settings
centos7 Initial settings
CentOS8 USB LAN adapter network settings
CentOS7 initial settings
Network install CentOS 8 with Kickstart.
RuboCop settings
Ruby settings 1