29 Nisan 2019 Pazartesi

etc/resolv.conf dosyası - DNS Sunucuları Listesi

Giriş
Bu dosyada DNS sunucuları sıralanır. Bu dosya dhclient, dnsmasq veya Network Manager tarafından yaratılır. C kütüphaneleri bu dosyayı okuyup DNS sorgusu yaparlar. Ancak bu dosya ilerleyen zamanlarda artık direkt elle değiştirilemeyecek. Açıklaması şöyle
Back in the days, whenever you wanted to configure DNS resolvers in Linux you would simply open the /etc/resolv.conf file, edit the entries, save the file and you are good to go. This file still exists but it is a symlink controlled by the systemd-resolved service and should not be edited manually.
Çünkü bilgisayarlar artık yavaş yavaş systemd-resolved servisini kullanmaya başlayacaklar. Açıklaması şöyle.
systemd-resolved is a service that provides DNS name resolution to local services and applications and it can be configured with Netplan, the default network management tool on Ubuntu 18.04.

Netplan configuration files are stored in the /etc/netplan directory. You’ll probably find one or two YAML files in this directory. The file name may differ from setup to setup. Usually, the file is named either 01-netcfg.yaml or 50-cloud-init.yaml but in your system, it may be different.

These files allow you to configure the network interface, including the IP address, gateway, DNS nameservers, and so on.
nameserver Alanı
DNS sunucusunu belirtir. /etc/resolv.conf dosyası benim sistemimde şöyle görünüyor. Yani WIFI modem'in IP adresi
nameserver 127.0.0.53
Ancak aslında ben 8.8.8.8 yani Google DNS sunucusunu kullanıyorum. Yani etc/resolv.conf dosyasında bu bilgi yok!

ndots Alanı
Elimizde şöyle bir dosya olsun
nameserver 100.64.0.10
search namespace.svc.cluster.local svc.cluster.local cluster.local eu-west-1.compute.internal
options ndots:5

Açıklaması
şöyle
As you can see there are three directives:
1. The nameserver IP is the Kubernetes service IP of kube-dns
2. There are 4 local search domains specified
3. There’s a ndots:5 option
Açıklaması şöyle. Yani eğer aranılan isimde 5'ten az nokta ile ayrılmış alan varsa search ile tanımlı alanlar ilave edilerek arama yapılır
This means that if ndots is set to 5 and the name contains less than 5 dots inside it, the syscall will try to resolve it sequentially going through all local search domains first and - in case none succeed - will resolve it as an absolute name only at last.
Örnek
Şöyledir.
cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 200.200.200.1
nameserver 200.200.200.2
nameserver 200.200.200.3
Örnek
search domain1.com domain2.com domain3.com
nameserver 10.10.10.10
nameserver 10.10.10.11
options ndots:5
Örnek
Bu dosyayı baştan yaratmak için şöyle yaparız
rm /etc/resolv.conf
echo "nameserver 192.168.1.1" > /etc/resolv.conf

Hiç yorum yok:

Yorum Gönder