問題描述:nginx不能解析域名,可是使用nslookup卻能夠解析域名node
./sbin/nginx -t nginx: [emerg] host not found in upstream "nodejs.default.svc.cluster.local" in /data/app/nginx/conf/nginx.conf:45 nginx: configuration file /data/app/nginx/conf/nginx.conf test failed
sh-4.2# nslookup nodejs.default.svc.cluster.local Server: 10.254.0.10 Address: 10.254.0.10#53 Name: nodejs.default.svc.cluster.local Address: 10.254.195.180
問題分析nginx
使用tcpdump進行抓包查看網絡請求過程
nginx抓包分析shell
tcpdump host 10.254.0.10 -nnn 01:49:23.099223 IP 10.10.12.2.52250 > 10.254.0.10.53: 20393+ A? nodejs.default.svc.cluster.local.cluster.local. (72) 01:49:23.099921 IP 10.254.0.10.53 > 10.10.12.2.52250: 20393 NXDomain 0/1/0 (165)
nslookup抓包分析網絡
tcpdump host 10.254.0.10 -nnn 01:49:31.740858 IP 10.10.12.2.35727 > 10.254.0.10.53: 15055+ A? nodejs.default.svc.cluster.local.default.svc.cluster.local. (84) 01:49:31.741433 IP 10.254.0.10.53 > 10.10.12.2.35727: 15055 NXDomain 0/1/0 (177) 01:49:31.741670 IP 10.10.12.2.53645 > 10.254.0.10.53: 40936+ A? nodejs.default.svc.cluster.local.svc.cluster.local. (76) 01:49:31.741986 IP 10.254.0.10.53 > 10.10.12.2.53645: 40936 NXDomain 0/1/0 (169) 01:49:31.742326 IP 10.10.12.2.47267 > 10.254.0.10.53: 55514+ A? nodejs.default.svc.cluster.local.cluster.local. (72) 01:49:31.742624 IP 10.254.0.10.53 > 10.10.12.2.47267: 55514 NXDomain 0/1/0 (165) 01:49:31.742835 IP 10.10.12.2.49354 > 10.254.0.10.53: 22220+ A? nodejs.default.svc.cluster.local. (58) 01:49:31.743119 IP 10.254.0.10.53 > 10.10.12.2.49354: 22220* 1/0/0 A 10.254.195.180 (74)
分析發現nginx默認只會搜索一個cluster.local若是沒有返回,則會報錯,nslookup卻會幫你儘量的去嘗試搜索全部域名,知道找到結果爲止。app