今天突然发现Fedora上⽆法联⽹了,分析⼀通发现直连IP是可以通的,所以只是单纯的解析不了域名。那这就好办了,设置下DNS即可解决。⼀般来说修改DNS常见有两种⽅法。
⽅法⼀、修改/etc/resolv.conf(推荐)
[root@bin ~]# vi /etc/resolv.confnameserver 8.8.8.8nameserver 8.8.4.4
修改后会⽴即⽣效,不需做任何额外处理!故,⽐较推荐此⽅法。
⽅法⼆、修改 /etc/sysconfig/network-scripts/ifcfg-eth0⽂件
[root@bin ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0ONBOOT=yes
BOOTPROTO=dhcpDNS2=8.8.4.4TYPE=EthernetDNS1=8.8.8.8IPV6INIT=noUSERCTL=noPEERDNS=yes
这种办法还要重启⽹卡才⽣效,重启⽹卡可以⽤以下命令:
service network restart
查看本机DNS的办法
1、查看/etc/resolv.con⽂件
[oboth@localhost ~]$ cat /etc/resolv.conf nameserver 114.114.114.114nameserver 8.8.8.8
2、使⽤nslookup命令查看DNS信息
[oboth@localhost ~]$ nslookup qq.comServer: 114.114.114.114Address: 114.114.114.114#53Name: qq.com
Address: 123.151.137.18Name: qq.com
Address: 61.129.7.47Name: 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
因篇幅问题不能全部显示,请点此查看更多更全内容