技术文档

帮助中心 > 技术文档 >

Debian 如何修改DNS,设置DNS?

2023-12-28 作者:简米科技 阅读量:0 所属分类:技术文档

一、临时设置

直接修改 /etc/resolv.conf,例如直接添加nameserver 8.8.8.8。

注意:系统重启或resolvconf重启后会刷新该配置文件。

二、 永久配置

/etc/resolv.conf是一个链接,指向/run/resolvconf/resolv.conf,/run/resolvconf/resolv.conf的内容是由/etc/resolvconf/resolv.conf.d/base加载过去的。

参考:

①Ubuntu通过修改配置文件进行网络配置及ubuntu解决resolv.conf被重写问题和NetworkManager的关系;

②Debian DNS resolv.conf 重启失效/复写;

# 进入/etc/resolvconf/resolv.conf.d/文件夹

cd /etc/resolvconf/resolv.conf.d/

# 添加nameserver,也可以修改head或tail

vi /etc/resolvconf/resolv.conf.d/base

nameserver 8.8.8.8

# 刷新或重启

sudo resolvconf -u

sudo systemctl restart resolvconf

注:/etc/resolvconf/run/resolv.conf似乎也是指向/run/resolvconf/resolv.conf的链接,并且/etc/resolvconf/run/interface/systemd-resolved文件也会同时添加到/run/resolvconf/resolv.conf中,如果有大佬知道可以指点一下。

# 进入/etc/resolvconf/run/interface/文件夹

cd /etc/resolvconf/run/interface/

# 添加nameserver

vi /etc/resolvconf/run/interface/systemd-resolved

nameserver 8.8.8.8

# 刷新或重启

sudo resolvconf -u

sudo systemctl restart resolvconf

标签:

本文地址:https://www.iisidc.cn/help/719.html

简米科技服务器支持24小时免费测试


成为简米科技会员,享受出众的上云实践机会和周到的尊贵服务!