반응형
참고:
테스트한 날: 2023년 1월 6일
테스트에 사용했던 OS: Ubuntu 22.04
Ubuntu OS를 Booting할 때마다 기존 /etc/resolv.conf 파일은 resolvconf.service와 systemd-resolved.service에 의해서 overwrite 된다.
따라서 nameserver를 내가 원하는 값으로 변경하고 싶으면, 아래와 같이 추가로 설정 작업을 해야 한다.
## ## root 계정 권한 갖기 ## $ sudo -s ## ## Ubuntu를 설치할 때 최소 설치 또는 기본 설정으로 설치했다면 ## 아래와 같이 resolvconf.service가 없어서 에러가 출력될 것이다. ## 따라서 resolvconf.service 부터 설치해야 한다. ## $ systemctl status resolvconf.service Unit resolvconf.service could not be found. $ ## ## NOTE: ## apt 명령으로 resolvconf를 설치하기 전에 임시로 /etc/resolv.conf 파일에 ## nameserver 항목에 1.1.1.1 값을 설정한다. ## $ cat /etc/resolv.conf ... 중간 생략 ... nameserver 1.1.1.1 ## <-- 이 부분을 수정할 것!!! options edns0 trust-ad $ apt install resolvconf $ systemctl status resolvconf ● resolvconf.service - Nameserver information manager Loaded: loaded (/lib/systemd/system/resolvconf.service; enabled; vendor preset: enabled) Active: active (exited) since Thu 2021-12-30 16:07:28 KST; 3min 14s ago ... 중간 생략 ... $ cat /etc/resolvconf/resolv.conf.d/head nameserver 1.1.1.1 nameserver 8.8.8.8 ## ## 위에서 설정한 값을 system에 반영하기 위해 아래와 같이 명령을 수행한다. ## $ resolvconf --enable-updates $ resolvconf -u $ cat /etc/resolv.conf nameserver 1.1.1.1 nameserver 8.8.8.8 $ ## ## 위 과정이 에러 없이 수행되었다면, OS를 Reboot해서 ## /etc/resolv.conf 설정 내용을 원하는 대로 반영되는지 확인해볼 것 !!! ## $ reboot ## Rebooting ... ## ... ## ... $ cat /etc/resolv.conf nameserver 1.1.1.1 nameserver 8.8.8.8 $
참고: 위 설정은 Ubuntu 18.04 와 Ubuntu 20.04 에서만 테스트했음. 다른 버전의 Ubuntu는 위 설명이 효과가 있는지 아직 모름.
(2021년 12월 30일에 테스트한 결과)
참고: 위와 같이 nameserver를 왜 변경해야 하는 상황이 있을까?
apt update 또는 apt install 명령을 수행하다보면, 아래 화면과 같이 Temporary failure resolving archive.ubuntu.com 이라는 에러가 발생하는 경우가 있다.

왜 이런 에러가 발생할까?
nameserver 기본 설정이 아래와 같이 127.0.0.53 으로 되어 있기 때문이다.
이 nameserver 값을 1.1.1.1 또는 8.8.8.8 과 같이 설정하면 apt install 명령을 잘 수행될 것이다.

'Ubuntu' 카테고리의 다른 글
iptables and netfilter (1) | 2021.07.10 |
---|---|
tcpdump로 HTTP Packet Decode 하기 및 tshark 사용법 (0) | 2021.07.10 |
sudoers 설정 (암호 입력 없이 root 사용자 권한 얻기) (0) | 2021.07.10 |
Configure DNAT(Port Forward) for KVM (to connect into VM from outer network) (0) | 2021.07.10 |
Sharing Desktop (원격 데스크탑) on Ubuntu (0) | 2021.07.10 |