[Linux] linux | modify dns | modify network card dns

1. Description

1. For business needs, you need to modify the dns address of the service.
2. Change it to Ali’s

2. Operation

  1. Query the network card that needs to modify dns

ifconfig
Note 1: Pay attention to ens192, which is the name of the network card
  1. View network card configuration file information

cd /etc/sysconfig/network-scripts
ll
  1. backup

cp /etc/sysconfig/network-scripts/ifcfg-ens192 /etc/sysconfig/network-scripts/ifcfg-ens192.bak
  1. edit

vi /etc/sysconfig/network-scripts/ifcfg-ens192
  1. Edit content and save

PEERDNS=no
DNS1=223.6.6.6
1. PEERDNS=no, that is, the dns configuration is not obtained from the DHCP service
. 2. 233.6.6.6 is Ali’s
. 3. Search for others by yourself
  1. restart service

systemctl restart network
  1. view dns

cat /etc/resolv.conf
  1. Description of the situation where the configuration is restored to the default after restarting

1. If it is a virtual machine, there is no problem with this configuration.
2. If it is a cloud host, the above configuration may be reset to the default configuration; even if PEERDNS is changed to 0, it is useless.
3. The final configuration result: It is still used By default, the cloud server configuration
is at the leader's place

Guess you like

Origin blog.csdn.net/myloverisxin/article/details/129398915