Debian/centos系统
改dns并设置为只读
echo -e "nameserver 4.4.4.4(以实际为准)" > /etc/resolv.conf
chattr +i /etc/resolv.conf
取消只读并还原回谷歌dns
chattr -i /etc/resolv.conf
echo -e "nameserver 8.8.8.8" > /etc/resolv.conf
ubuntu系统
修改DNS
vi /etc/systemd/resolved.conf
输入
DNS=4.4.4.4(以实际为准)
:wq保存后
systemctl daemon-reload
systemctl restart systemd-resolved.service
mv /etc/resolv.conf /etc/resolv.conf.bak
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
移除并还原为谷歌DNS
修改DNS
vi /etc/systemd/resolved.conf
输入
DNS=8.8.8.8
DNS=1.1.1.1
:wq保存后
systemctl daemon-reload
systemctl restart systemd-resolved.service
mv /etc/resolv.conf /etc/resolv.conf.bak
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf