Function: dns-set-servers
dns-set-servers is a byte-compiled function defined in dns.el.gz.
Signature
(dns-set-servers)
Documentation
Set dns-servers to a list of DNS servers or nil if none are found.
Parses "/etc/resolv.conf" or calls "nslookup".
Source Code
;; Defined in /usr/src/emacs/lisp/net/dns.el.gz
(defun dns-set-servers ()
"Set `dns-servers' to a list of DNS servers or nil if none are found.
Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
(setq dns-servers nil)
(or (when (file-exists-p "/etc/resolv.conf")
(with-temp-buffer
(insert-file-contents "/etc/resolv.conf")
(goto-char (point-min))
(while (re-search-forward "^nameserver[\t ]+\\([^ \t\n]+\\)" nil t)
(push (match-string 1) dns-servers))
(setq dns-servers (nreverse dns-servers))))
(when (executable-find "nslookup")
(with-temp-buffer
(call-process "nslookup" nil t nil "-retry=0" "-timeout=2" "localhost")
(goto-char (point-min))
(when (re-search-forward
"^Address:[ \t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\|[[:xdigit:]:]*\\)" nil t)
(setq dns-servers (list (match-string 1)))))))
(setq dns-servers-valid-for-interfaces (network-interface-list)))