DNS简单说明

KPS的NDS异常排查

今早看见KPS异常,前期我排查了,先ping是不通的,然后远端代理本机访问也是不行。

root@(none):~# ping www.baidu.com

ping: unknown host www.baidu.com

root@(none):~# psg kps

root       647  0.0  0.0      0     0 ?        S<   09:04   0:00 [kpsmoused]

root       973  0.0  1.6  67120 16728 ?        S    09:04   0:00 /usr/bin/python -u /root/kps/webapi.py

root       979  0.0  1.2 136192 12316 ?        Sl   09:04   0:00 /usr/bin/python -u /root/kps/kps.py --port 16816

root      1002  0.0  1.1 131964 11740 ?        Sl   09:04   0:00 /usr/bin/python -u /root/kps/kps.py --port 8080

root      1023  0.0  1.4  62824 14704 ?        S    09:04   0:00 /usr/bin/python -u /root/kps/process_monitor.py

root      1122  0.2  1.7 145468 17260 ?        Sl   09:04   0:01 /usr/bin/python /root/kps/webapi.py

root      1326  0.0  1.3 137312 13232 ?        Sl   09:04   0:00 python -u /root/kps/proxy.py --port 16817 --logfile proxy2

root      1360  0.2  2.8 685092 28720 ?        Sl   09:04   0:01 python -u /root/kps/proxy.py --port 16819 --logfile proxy4

root      3455  0.0  1.0  48084 10712 ?        S    09:10   0:00 /usr/bin/python -u /root/kps/auth.py

root      5763  0.1  1.2 132652 12404 ?        Sl   09:14   0:00 python -u /root/kps/socks.py --port 21083 --logfile socks4

root      5773  0.1  1.2 132688 12428 ?        Sl   09:14   0:00 python -u /root/kps/proxy.py --port 16818 --logfile proxy3

root      5783  0.1  1.2 132652 12404 ?        Sl   09:14   0:00 python -u /root/kps/socks.py --port 21080 --logfile socks1

root      5793  0.1  1.2 132652 12408 ?        Sl   09:14   0:00 python -u /root/kps/socks.py --port 21082 --logfile socks3

root      5804  0.1  1.2 132652 12408 ?        Sl   09:14   0:00 python -u /root/kps/socks.py --port 21081 --logfile socks2

root      5956  0.0  0.0   8140   944 pts/0    S+   09:15   0:00 grep --color=auto kps

jerrywang@transfer:~$ curl -v "https://www.baidu.com" -x   jerrywang:[email protected]:16816                                       * Rebuilt URL to: https://www.baidu.com/

* Hostname was NOT found in DNS cache

*   Trying 101.203.173.104...

* Connected to 101.203.173.104 (101.203.173.104) port 16816 (#0)

* Establish HTTP proxy tunnel to www.baidu.com:443

* Proxy auth using Basic with user 'kpstest'

> CONNECT www.baidu.com:443 HTTP/1.1> Host: www.baidu.com:443> Proxy-Authorization: Basic a3BzdGVzdDptNWc3aDV2aQ==> User-Agent: curl/7.38.0> Proxy-Connection: Keep-Alive> < HTTP/1.1 502 Bad Gateway< Server: KPS< Content-Length: 11< Connection: close

< * Received HTTP code 502 from proxy after CONNECT* Closing connection 0

curl: (56) Received HTTP code 502 from proxy after CONNECT

经过排查,是因为DNS故障所导致的。因为我们是通过域名访问的,DNS异常不解析域名导致域名无法访问,其实本机是有网的,只是DNS异常,如果通过ip访问是通的,解决方法修改为公网DNS就解决了。

排查步骤:

  1. 查看对应的DNS域名解析配置文件(/etc/resolv.conf)

           root@(none):~# 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

          nameserver 114.114.114.114

          nameserver 180.76.76.76

       2.ping对应的域名,如果不通,则说明域名有问题

          root@(none):~#ping 180.76.76.76

          

首先我们来说说什么是DNS?

DNS就是域名解析器,我们访问网站的时候,其实都是在访问一个IP主机,例如www.baidu.com,我们敲下去的是百度的网站,但实际转换的是该主机的IP地址,好处是我们访问网站或者说服务器时,不用记那些IP地址的数字串,而是记一些比较容易记的字符,如baidu.com。而DNS就是把域名转换为IP地址的东西

DNS配置文件: /etc/resolv.conf

这个配置文件中,一定有 nameserver关键字。作用是指定 DNS服务器的地方,不指定的话,无法通过敲 www.baidu.com 来访问百度,只能敲百度服务器的IP地址来访问他。

常用的 DNS服务器地址:114.114.114.114 

如:nameserver  114.114.114.114  (在配置文件中加上这句就行)

猜你喜欢

转载自blog.csdn.net/qq_41816540/article/details/84070305