Linux 拨号vps windows公众号手机端

Debian 9 修改 DNS 的方法

lewis 5年前 (2021-01-26) 阅读数 7 #网络运维

本文目录导读:

  1. <"http://#id1" title="修改 code/etc/resolv.conf/code 文件" "">修改 /etc/resolv.conf 文件
  2. <"http://#id2" title="使用 NetworkManager 修改 DNS" "">使用 NetworkManager 修改 DNS

在 Debian 9 中,修改 DNS 是一项常见的网络配置任务,DNS(Domain Name System)用于将域名转换为 IP 地址,以便在网络上正确地解析和访问网站,在本文中,我们将从多个方面详细介绍如何在 Debian 9 上修改 DNS 设置。

修改 /etc/resolv.conf 文件

1、打开终端并以管理员权限登录到 Debian 9 系统。

2、使用文本编辑器(如 nano 或 vi)打开 /etc/resolv.conf 文件,使用 nano 编辑器可以运行以下命令:

sudo nano /etc/resolv.conf

3、在打开的文件中,您可以修改或添加 DNS 服务器地址,常见的 DNS 服务器地址包括 Google DNS(8.8.8.8 和 8.8.4.4)和 Cloudflare DNS(1.1.1.1),在文件中添加以下行:

nameserver 8.8.8.8

nameserver 8.8.4.4

或者

nameserver 1.1.1.1

4、保存并关闭文件。

5、重启网络服务以使更改生效,运行以下命令:

sudo systemctl restart networking

使用 NetworkManager 修改 DNS

如果您使用 NetworkManager 管理网络连接,则可以使用以下步骤修改 DNS 设置:

1、打开终端并以管理员权限登录到 Debian 9 系统。

2、打开 NetworkManager 的配置文件,运行以下命令:

sudo nano /etc/NetworkManager/NetworkManager.conf

3、在文件中找到 [main] 部分,并添加或修改以下行:

dns=dn**asq

4、保存并关闭文件。

5、重启 NetworkManager 以使更改生效,运行以下命令:

sudo systemctl restart NetworkManager

6、在 NetworkManager 中设置自定义 DNS 服务器地址,运行以下命令:

sudo nmcli connection modify "Wired connection 1" ipv4.dns "8.8.8.8,8.8.4.4" ipv4.ignore-auto-dns yes ipv4.dhcp-use-dns yes ipv4.method manual ipv4.addresses "0/0" no ipv4.gateway "0/0" no ipv4.dns-search no ipv6.method none ipv6.ignore-auto-dns yes ipv6.dhcp-use-dns yes ipv6-addresses no ipv6-gateway no ipv6-dns no ipv6-search no ipv6-method manual ipv6-addresses no ipv6-gateway no ipv6-dns no ipv6-search no ipv6-method none connection-type ethernet connection-uuid "" device-type ethernet ip4-config ip4-mode static ip6-config ip6-mode static ipv4-family ipv4 ipv6-family ipv6 connection-active yes connection-uuid "" connection-interface "eth0" connection-speed "1000" connection-master yes connection-slave yes connection-lldp-enabled no connection-lldp-tx-interval "300" connection-lldp-tx-hold "3" connection-lldp-rx-interval "300" connection-lldp-rx-hold "3" connection-lldp-disabled no connection-lldp-tx-interval-present no connection-lldp-tx-hold-present no connection-lldp-rx-interval-present no connection-lldp-rx-hold-present no connection-lldp-disabled-present no connection-lldp-tx-interval-managed yes connection-lldp-tx-hold-managed yes connection-lldp-rx-interval-managed yes connection-lldp-rx-hold-managed yes connection-lldp-disabled-managed no connection-lldp2plus2enabled no connection-lldp2plus2txinterval "300" connection
版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门