DNS 설정 점검

Prev Next

VPC 환경에서 이용 가능합니다.

네이버 클라우드 플랫폼에서 제공하는 DNS 설정을 사용하지 않으면, 내부 관리를 위해서 제공되는 서버와 정상 통신이 안될 수 있습니다. 가급적 별도 DNS 설정을 하지 않는 것을 권고합니다. 고객 측에서 별도의 DNS 설정을 하시면 내서버 이미지로 서버를 생성 하거나 관리자 비밀번호 설정하는 과정 등 네이버 클라우드 플랫폼 서비스를 사용하는 여러 상황에서 오류가 발생할 수 있습니다.

네이버 클라우드 플랫폼에서 제공되고 있는 RedHat 계열의 OS에서 아래의 가이드를 통해서 DNS 설정값 및 파일을 점검해 주십시오.

참고

해당 가이드에서 지원하는 OS는 CentOS 7.8, Rocky Linux 8.6 입니다.

  1. DHCP에서 받아온 네이버 클라우드 플랫폼 DNS 설정값을 확인해 주십시오. VPC 환경에서 제공되는 DNS 서버의 IP는 169.254.169.53169.254.169.54 입니다.

    [root@centos78 ~]# grep domain-name /var/lib/dhclient/dhclient--eth0.lease
    option domain-name-servers 169.254.169.53,169.254.169.54;
    option domain-name-servers 169.254.169.53,169.254.169.54;
    
    Plain text
  2. /etc/resolv.conf 파일 설정 및 내용을 확인해 주십시오.
    파일의 내용이 아래와 상이할 경우 네이버 클라우드 플랫폼 DNS 서버와 정상 통신이 안될 수 있습니다. 단, 파일 수정 후 OS 리부팅하면 DHCP로 부터 받아온 네이버 클라우드 플랫폼 설정값으로 초기화됩니다.

    [root@centos78 ~]# cat /etc/resolv.conf
    ; generated by /usr/sbin/dhclient-script
    nameserver 169.254.169.53
    nameserver 169.254.169.54
    
    Plain text
  3. nslookup 명령어로 DNS 쿼리 동작을 확인해 주십시오.
    정상적으로 쿼리가 동작할 경우 169.254.170.48이 출력됩니다.

    [root@centos78 ~]# nslookup repo.gov-ncloud.com
    Server:		169.254.169.53
    Address:	169.254.169.53#53
    
    Non-authoritative answer:
    repo.gov-ncloud.com	canonical name = repo.gov-ncloud.grm.ncloud.com.
    Name:	repo.gov-ncloud.grm.ncloud.com
    Address: 169.254.170.48
    
    Plain text

    만약 네이버 클라우드 플랫폼에서 제공하는 DNS를 사용하지 않고, 다른 DNS를 사용한다면 전혀 다른 IP를 받게됩니다.

    [root@centos78 ~]# nslookup repo.gov-ncloud.com 8.8.8.8
    Server:		8.8.8.8
    Address:	8.8.8.8#53
    
    Non-authoritative answer:
    repo.gov-ncloud.com	canonical name = repo.gov-ncloud.grm.ncloud.com.
    Name:	repo.gov-ncloud.grm.ncloud.com
    Address: 10.250.69.32
    
    Plain text

네이버 클라우드 플랫폼에서 제공되고 있는 Ubuntu 18.04, Ubuntu 20.04는 systemd-resolved를 사용합니다. 아래의 가이드를 통해서 DNS 설정값 및 파일을 점검해 주십시오.

참고

해당 가이드에서 지원하는 OS는 Ubuntu 18.04, Ubuntu 20.04 입니다.

  1. /etc/resolv.conf 파일 설정 및 내용을 확인해 주십시오.
    파일의 Symbolic Link 여부 확인를 확인해 주십시오.

    root@ubuntu2004:~# ll /etc/resolv.conf
    lrwxrwxrwx 1 root root 39 Jan 24  2022 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
    
    Plain text
  2. 파일의 내용을 확인해 주십시오. 단, options edns0 trust-ad 옵션은 OS 버전에 따라서 없거나 옵션 항목이 다를 수 있습니다.

    • Ubuntu 18.04
      root@ubuntu1804:~# cat /etc/resolv.conf
      # This file is managed by man:systemd-resolved(8). Do not edit.
      ... 생략 ...
      nameserver 127.0.0.53
      options edns0
      
      Plain text
    • Ubuntu 20.04
      root@ubuntu2004:~# cat /etc/resolv.conf
      # This file is managed by man:systemd-resolved(8). Do not edit.
      ... 생략 ...
      nameserver 127.0.0.53
      options edns0 trust-ad
      
      Plain text
  3. DHCP에서 받아온 네이버 클라우드 플랫폼 DNS 설정값을 확인해 주십시오.

    root@ubuntu2004:~# cat /run/systemd/resolved.conf.d/isc-dhcp-v4-eth0.conf
    [Resolve]
    DNS=169.254.169.53 169.254.169.54
    
    Plain text
  4. OS상에서 설정된 DNS 설정값을 확인해 주십시오.
    VPC 환경에서 제공되는 DNS 서버의 IP는 169.254.169.53169.254.169.54 입니다.

    root@ubuntu2004:~# cat /run/systemd/resolve/resolv.conf
    ... 생략 ...
    nameserver 169.254.169.53
    nameserver 169.254.169.54
    
    Plain text

    만약 아래와 같이 보인다면, DNS 서버 설정이 정상적으로 안된 상태입니다.

    root@ubuntu2004:~# tail -2 /run/systemd/resolve/resolv.conf
    
    # No DNS servers known.
    
    Plain text

    아래와 같이 처리 가능합니다.

    root@ubuntu2004:~# cat /run/systemd/resolved.conf.d/isc-dhcp-v4-eth0.conf
    [Resolve]
    DNS=169.254.169.53 169.254.169.54
    
    root@ubuntu2004:~# systemctl restart systemd-resolved
    root@ubuntu2004:~# tail -2 /run/systemd/resolve/resolv.conf
    nameserver 169.254.169.53
    nameserver 169.254.169.54
    
    Plain text
  5. systemd-resolved 데몬의 기동 여부 및 상태 확인해 주십시오.
    설치된 unit 목록에서 systemd-resolved 데몬이 enabled 상태여야 부팅 후에도 정상 동작 가능합니다.

    root@ubuntu2004:~# systemctl list-unit-files | grep systemd-resolved.service
    systemd-resolved.service               enabled         enabled
    
    Plain text

    systemd-resolved 데몬이 active 상태여야 정상 동작이 가능합니다.

    root@ubuntu2004:~# systemctl status systemd-resolved.service
    ● systemd-resolved.service - Network Name Resolution
         Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
         Active: active (running) since Sat 2023-01-07 00:29:09 KST; 2 months 4 days ago
           Docs: man:systemd-resolved.service(8)
                 https://www.freedesktop.org/wiki/Software/systemd/resolved
                 https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
                 https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
       Main PID: 587 (systemd-resolve)
         Status: "Processing requests..."
          Tasks: 1 (limit: 9421)
         Memory: 4.7M
         CGroup: /system.slice/systemd-resolved.service
                 └─587 /lib/systemd/systemd-resolved
    
    Plain text

    IP 주소 127.0.0.53의 연결 상태 확인해 주십시오.
    systemd-resolve 서비스에 의해 53(nameservice port) 포트를 통해 LISTEN 중인 것을 확인해 주십시오.

    root@ubuntu2004:~# netstat -anp | grep 127.0.0.53
    tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      587/systemd-resolve
    udp        0      0 127.0.0.53:53           0.0.0.0:*                           587/systemd-resolve
    
    Plain text
  6. systemd-resolve 서비스에서 DNS 설정값 확인해 주십시오.
    아래의 명령어로 쿼리를 날리는 DNS 서버 정보를 확인해 주십시오.

    • Ubuntu 18.04
      root@ubuntu1804:~# systemd-resolve --status
      Global
               DNS Servers: 169.254.169.53
                            169.254.169.54
       ... 생략 ...
      
      Plain text
    • Ubuntu 20.04
      root@ubuntu2004:~# systemd-resolve --status
      Global
             LLMNR setting: no                 
      MulticastDNS setting: no                 
        DNSOverTLS setting: no                 
            DNSSEC setting: no                 
          DNSSEC supported: no                 
        Current DNS Server: 169.254.169.54     
               DNS Servers: 169.254.169.53     
                            169.254.169.54
      ... 생략 ...
      
      Plain text
  7. /etc/hosts 파일의 권한을 확인해 주십시오.
    /etc/hosts 파일의 Other User에 read 권한을 부여해야 systemd-resolved 데몬이 정상 동작 가능합니다. 기본 설정으로 /etc/hosts 파일의 권한은 644로 되어있습니다.

    root@ubuntu2004:~# ls -l /etc/hosts
    -rw-r--r-- 1 root root 186 Jan 24  2022 /etc/hosts
    
    Plain text
  8. nslookup 명령어로 DNS 쿼리 동작을 확인해 주십시오.
    정상적으로 쿼리가 동작할 경우 169.254.170.48이 출력됩니다.

    root@ubuntu2004:~# nslookup repo.gov-ncloud.com
    Server:		127.0.0.53
    Address:	127.0.0.53#53
    
    Non-authoritative answer:
    repo.gov-ncloud.com	canonical name = repo.gov-ncloud.grm.ncloud.com.
    Name:	repo.gov-ncloud.grm.ncloud.com
    Address: 169.254.170.48
    
    Plain text

    만약 네이버 클라우드 플랫폼에서 제공하는 DNS를 사용하지 않고, 다른 DNS를 사용한다면 전혀 다른 IP를 받게됩니다.

    root@ubuntu2004:~# nslookup repo.gov-ncloud.com 8.8.8.8
    Server:		8.8.8.8
    Address:	8.8.8.8#53
    
    Non-authoritative answer:
    repo.gov-ncloud.com	canonical name = repo.gov-ncloud.grm.ncloud.com.
    Name:	repo.gov-ncloud.grm.ncloud.com
    Address: 10.250.69.32
    
    Plain text
[root@ncp-server ~]# nslookup repo.gov-ncloud.com
Server:		169.254.169.53
Address:	169.254.169.53#53

Non-authoritative answer:
repo.gov-ncloud.com	canonical name = repo.gov-ncloud.grm.ncloud.com.
repo.gov-ncloud.grm.ncloud.com	canonical name = kr1-vpc-init.gov-ncloud.grm.ncloud.com.
Name:	kr1-vpc-init.gov-ncloud.grm.ncloud.com
Address: 169.254.170.48

nslookup: isc_socket_bind: address in use
Plain text

해당 이슈는 고객 서비스 네트워크 환경에 비해 ip_local_port_range 값이 너무 작거나, 현재 사용 중인 socket port가 과도하게 많은 경우에 발생합니다.
ip_local_port_range는 아래와 같이 확인이 가능합니다. 기본값으로는 최소 포트 32768, 최대 포트 60999로 설정되어 있습니다.

[root@ncp-server ~]# sysctl net.ipv4.ip_local_port_range
net.ipv4.ip_local_port_range = 32768    60999
Plain text

리부팅 가능한 서버일 경우에는, 운영 체제에서 리부팅을 하시고 불가능한 경우에는 현재 사용 중인 소켓 개수를 확인하여 불필요한 소켓을 정리하거나 ip_local_port_range 값을 늘리는 것을 권장드립니다.
정상 상태에서 DNS 질의할 경우에는 아래와 같이 출력되는 것을 확인할 수 있습니다.

[root@ncp-server ~]# nslookup repo.gov-ncloud.com
Server:		169.254.169.53
Address:	169.254.169.53#53

Non-authoritative answer:
repo.gov-ncloud.com	canonical name = repo.gov-ncloud.grm.ncloud.com.
repo.gov-ncloud.grm.ncloud.com	canonical name = kr1-vpc-init.gov-ncloud.grm.ncloud.com.
Name:	kr1-vpc-init.gov-ncloud.grm.ncloud.com
Address: 169.254.170.48
Plain text