Ubuntu 17.04 服务器 DNS 配置

Ubuntu 17.04 服务器 DNS 配置

在哪里更改 DNS 以便它在重启后不会被覆盖?

# cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 103.241.42.2
nameserver 127.0.0.53
search xx

我不知道为什么,但是上面的两个 DNS 服务器都很烂。

# dig google.com @103.241.42.2; dig google.com @127.0.0.53; dig google.com @8.8.8.8

; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com @103.241.42.2
;; global options: +cmd
;; connection timed out; no servers could be reached

; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com @127.0.0.53
;; global options: +cmd
;; connection timed out; no servers could be reached

; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40430
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             299     IN      A       172.217.26.78

;; Query time: 15 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Jun 16 16:17:59 WIB 2017
;; MSG SIZE  rcvd: 55

答案1

假设你添加的是静态 IP/etc/network/interfaces

auto <interface>
iface <interface> inet static
    address <yourIP>
    network <yourNetmask>
    gateway <yourGateway>
    dns-nameservers 103.241.42.2 127.0.0.53

相关内容