zoukankan      html  css  js  c++  java
  • Kubernetes-dns 域名解析问题

    问题描述:nginx不能解析域名,但是使用nslookup却可以解析域名

    ./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
    

    问题分析

    使用tcpdump进行抓包查看网络请求过程
    nginx抓包分析

    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却会帮你尽可能的去尝试搜索所有域名,知道找到结果为止。

  • 相关阅读:
    1JavaScript的历史
    扯扯 require .js
    查看js 执行效率工具
    php 输入输出流
    词法分析096
    Python基础综合练习
    096
    大数据概述
    熟悉常用的Linux操作
    实验一、词法分析实验
  • 原文地址:https://www.cnblogs.com/biglittleant/p/7463553.html
Copyright © 2011-2022 走看看