CentOS7.6 network configuration

First use the ifconfig command to view the name of the current network card, then use ethtool to view the network connection status, and finally edit the network card configuration file

vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
IPADDR="192.168.58.95"
GATEWAY="192.168.58.254"
NETMASK="255.255.255.0"
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="48ad6f70-cfcd-41cb-ba09-1276e9c6a4ad"
DEVICE="enp0s3"
ONBOOT="yes"

Configure domain name resolution service IP

Method 1) directly add DNS1="202.96.128.86" in the above configuration file, and then execute the command service network restart

Method 2) vi /etc/resolv.conf file, add the following content

nameserver 202.96.128.86

This method does not need to execute the above command

Reason: The service network restart command will write the nameserver 202.96.128.86 to the /etc/resolv.conf file according to the DNS1 parameter configuration in the configuration file

Note: ONBOOT must be yes, otherwise restarting the network service will fail

Guess you like

Origin blog.51cto.com/fengyuzaitu/2575591