linux修改dns

linux修改dns
John Doe修改 Debian DNS
临时修改
编辑 /etc/resolv.conf 文件
vim /etc/resolv.conf
修改后保存即可
nameserver 223.5.5.5
nameserver 223.6.6.6
永久修改
编辑 /etc/dhcp/dhclient.conf 文件
vim /etc/dhcp/dhclient.conf
在末尾添加一行
supersede domain-name-servers 223.5.5.5, 223.6.6.6;
service networking restart
或者 sudo systemctl restart networking
#重启网络
首先修改 /etc/systemd/resolved.conf 文件,在其中添加dns信息
DNS=8.8.8.8
DNS=114.114.114.114
然后退出保存。
然后以root身份在ubuntu终端中依次执行如下命令:
systemctl restart systemd-resolved
systemctl enable systemd-resolved
mv /etc/resolv.conf /etc/resolv.conf.bak
ln -s /run/systemd/resolve/resolv.conf /etc/
再查看/etc/resolv.conf文件就可以看到新的dns信息已经写入其中了。
当然,错误的时钟也会给网络带来问题:
sudo ntpdate [edu.ntp.org.cn](http://edu.ntp.org.cn/) # ntp同步时钟
完整的代码如下:
```shell
# VSCode终端
hexo clean; hexo s
hexo clean; hexo g; hexo d
git add .; git commit -m "npm publish"; npm version patch;
git push
# Cmder终端
hexo clean && hexo s
hexo clean && hexo g && hexo d
git add . && git commit -m "npm publish" && npm version patch
git push
\```
\```shell
# VSCode终端
hexo clean; hexo s
hexo clean; hexo g; hexo d
git add .; git commit -m "npm publish"; npm version patch;
git push
# Cmder终端
hexo clean && hexo s
hexo clean && hexo g && hexo d
git add . && git commit -m "npm publish" && npm version patch
git push
\```