linux怎么修改dns
方法一:
修改/etc/resolv.conf(推荐)
[root@bin ~]# vi /etc/resolv.conf nameserver 8.8.8.8 nameserver 8.8.4.4
修改后会立即生效,不需做任何额外处理!故,比较推荐此方法。
方法二:
修改 /etc/sysconfig/network-scripts/ifcfg-eth0文件
[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
查看本机DNS的办法
1、查看/etc/resolv.con文件
[oboth@localhost ~]$ cat /etc/resolv.conf nameserver 114.114.114.114 nameserver 8.8.8.8
2、使用nslookup命令查看DNS信息
[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
3、使用dig命令来查看DNS信息
[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
转载请注明:IT运维空间 » linux » linux怎么修改dns
发表评论