/etc/resolv.conf 및 ping 결과를 인쇄하는 스크립트를 만들었습니다.www.reddit.com매 초. 우리나라에서는 Reddit이 차단되어 있어서 Cloudflare의 DNS(1.1.1.1)를 사용했는데, DNS를 이용하면 우회가 가능합니다. 데스크탑에 로그인한 후 약 10초 후에 DNS가 기본 게이트웨이(192.168.1.1)로 돌아가는 것 같습니다. DNS를 1.1.1.1로 유지하려면 어떻게 해야 합니까?
내 스크립트:
#! /bin/bash
while true
do
cat /etc/resolv.conf
ping -c 1 www.reddit.com | grep "ping statistics" | sed "s/--- /$(date) /" | sed "s/ ping statistics ---//"
sleep 1
done
다시 시작하고 로그인한 후 즉시 결과를 실행하십시오.
# Generated by NetworkManager
nameserver 1.1.1.1
nameserver 1.0.0.1
Sat Aug 19 11:19:49 AM WIB 2023 reddit.map.fastly.net
# Generated by NetworkManager
nameserver 1.1.1.1
nameserver 1.0.0.1
Sat Aug 19 11:19:58 AM WIB 2023 reddit.map.fastly.net
# Generated by NetworkManager
nameserver 1.1.1.1
nameserver 1.0.0.1
Sat Aug 19 11:20:07 AM WIB 2023 reddit.map.fastly.net
# Generated by NetworkManager
nameserver 1.1.1.1
nameserver 1.0.0.1
Sat Aug 19 11:20:16 AM WIB 2023 trustpositif.kominfo.go.id
# Generated by NetworkManager
nameserver 1.1.1.1
nameserver 1.0.0.1
Sat Aug 19 11:20:17 AM WIB 2023 trustpositif.kominfo.go.id
# Generated by NetworkManager
nameserver 1.1.1.1
nameserver 1.0.0.1
Sat Aug 19 11:20:18 AM WIB 2023 trustpositif.kominfo.go.id
추가 정보:
❯ nslookup www.reddit.com 1.1.1.1
Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
www.reddit.com canonical name = reddit.map.fastly.net.
Name: reddit.map.fastly.net
Address: 151.101.129.140
Name: reddit.map.fastly.net
Address: 151.101.1.140
Name: reddit.map.fastly.net
Address: 151.101.65.140
Name: reddit.map.fastly.net
Address: 151.101.193.140
❯ nslookup www.reddit.com 192.168.1.1
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
www.reddit.com canonical name = trustpositif.kominfo.go.id.
Name: trustpositif.kominfo.go.id
Address: 27.54.116.70
❯ grep hosts /etc/nsswitch.conf
hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns
❯ resolvectl
Global
Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: foreign
Current DNS Server: 1.0.0.1
DNS Servers: 1.1.1.1 1.0.0.1
Fallback DNS Servers: 1.1.1.1#cloudflare-dns.com 9.9.9.9#dns.quad9.net 8.8.8.8#dns.google 2606:4700:4700::1111#cloudflare-dns.com 2620:fe::9#dns.quad9.net
2001:4860:4860::8888#dns.google
Link 2 (enp5s0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 4 (wlan0)
Current Scopes: DNS LLMNR/IPv4 mDNS/IPv4
Protocols: +DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.1.1
DNS Servers: 192.168.1.1
답변1
시스템은 systemd-resolved
기본 DNS 확인자(앞의 키워드 resolve
)를 사용하고 있으므로 실행 중이 아닌 경우에만 사용됩니다.dns
nsswitch.conf
/etc/resolv.conf
systemd-resolved
resolvectl
실제 DNS 설정을 보려면 실행하세요 .
/etc/resolv.conf
시스템에서 사실상 더 이상 사용되지 않습니다.