linux怎么修改dns
时间:2022-01-27 15:19
方法:1、利用“vi /etc/resolv.conf”命令修改dns;2、利用“vi /etc/sysconfig/network-scripts/ifcfg-eth0”命令修改文件内的dns项内容,修改后重启网卡生效。 本教程操作环境:linux7.3系统、Dell G3电脑。 方法一、修改/etc/resolv.conf(推荐) 修改后会立即生效,不需做任何额外处理!故,比较推荐此方法。 方法二、修改 /etc/sysconfig/network-scripts/ifcfg-eth0文件 这种办法还要重启网卡才生效,重启网卡可以用以下命令: 查看本机DNS的办法 1、查看/etc/resolv.con文件 2、使用nslookup命令查看DNS信息 3、使用dig命令来查看DNS信息 相关推荐:《Linux视频教程》 以上就是linux怎么修改dns的详细内容,更多请关注gxlcms其它相关文章!linux怎么修改dns
[root@bin ~]# vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
[root@bin ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
DNS2=8.8.4.4
TYPE=Ethernet
DNS1=8.8.8.8
IPV6INIT=no
USERCTL=no
PEERDNS=yes
service network restart
[oboth@localhost ~]$ cat /etc/resolv.conf
nameserver 114.114.114.114
nameserver 8.8.8.8
[oboth@localhost ~]$ nslookup qq.com
Server: 114.114.114.114
Address: 114.114.114.114#53
Name: qq.com
Address: 123.151.137.18
Name: qq.com
Address: 61.129.7.47
Name: qq.com
Address: 183.3.226.35
[oboth@localhost ~]$ dig
; <<>> DiG 9.11.25-RedHat-9.11.25-2.fc33 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27276
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 3359 IN NS l.root-servers.net.
. 3359 IN NS j.root-servers.net.
. 3359 IN NS g.root-servers.net.
. 3359 IN NS a.root-servers.net.
. 3359 IN NS i.root-servers.net.
. 3359 IN NS f.root-servers.net.
. 3359 IN NS k.root-servers.net.
. 3359 IN NS h.root-servers.net.
. 3359 IN NS e.root-servers.net.
. 3359 IN NS b.root-servers.net.
. 3359 IN NS d.root-servers.net.
. 3359 IN NS m.root-servers.net.
. 3359 IN NS c.root-servers.net.
;; Query time: 59 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: 一 2月 01 18:02:15 CST 2021
;; MSG SIZE rcvd: 239