Polish below
This project defines a wrapper on DNS resolution, allowing the user to define "fake" domain name addresses which map to mac addresses on a local network. DNS calls on these addresses then returns the IP address of the device with that mac.
The project was intended for Arch Linux, but you might be able to get it to work on other Linux distributions.
To install the application on ArchLinux simply run:
$ yay -S localdns-git
If you'd rather use the version that updates /etc/hosts you can skip this part.
For the operating system to incorporate this into DNS resolution we need to set it up correctly. We provide one way to do so, you may be able to do it differently.
First we need to add the server to the list of servers, to do so in accordance with good practice we'll need openresolv.
Install it with:
$ sudo pacman -S openresolv
If you want to choose another process (like NetworkManager) to be able to provide name servers follow: wiki openresolv.
Add the following lines to /etc/resolvconf.conf:
resolv_conf_local_only=NO
name_servers=127.0.0.1
(If you want to hardcode another nameserver look at the relevant wiki).
Run:
$ sudo resolvconf -u
In /etc/resolv.conf there should be:
# Generated by resolvconf
As well as:
nameserver 127.0.0.1
To configure the program open each of the files in /etc/local_dns/ and fill them in, following the instructions in the comments.
Installation defines a systemd process. For the project to work you need to start it up:
$ sudo systemctl start local-dns.service
And for it to start on startup of system:
$ sudo systemctl enable local-dns.service
For the version updating /etc/hosts/ substitute local-dns with local-dns-hosts in the following commands.
This project defines a custom DNS server on localhost that answers standard DNS queries by passing them to a real DNS server and acting as a proxy to that server. When it receives a DNS name ending with .localdns it answers with the IP assigned to the mac address defined in /etc/local_dns/DnsMapUser.config
The server sends one ARP ping packet to every single IP on the subnet specified by the user, concurrently. Another thread is constantly listening for the reply packets, hence if that MAC is present on the subnet, eventually we will receive an answer from the target IP. Additionally, the answers are cached consistently so that we can just retrieve the IP from it if the actual ARP pings were executed relatively recently ("relatively" is configured by the user, default is 30 days).
Ten projekt pozwala użytkownikowi definiować adresy DNS, które zamiast poprzez globalny DNS, będą rozstrzygane na lokalnej sieci poprzez odpowiednie adresy MAC.
Projekt był pisany z myslą o Arch Linuksie, być może działałby również na innych dystrybucjach Linuksa.
Aby zainstalować aplikację użyj:
$ yay -S localdns-git
Ta część nie jest potrzebna jeśli chcesz używać wersji edytującej /etc/hosts. Aby wkomponować nasz projekt w DNS na linuksie trzeba dodać localhosta do listy serwerow DNS. Pokazujemy jedną opcję jak to zrobić.
Aby to zrobić zgodnie z dobrą praktyką użyjemy openresolv.
Zainstaluj go przez:
$ sudo pacman -S openresolv
Jeżeli chcesz użyć innego programu (na przykład NetworkManager), który definiuje dynamicznie dostępne serwery DNSu, zobacz wiki openresolv.
Dopisz do /etc/resolvconf.conf:
resolv_conf_local_only=NO
name_servers=127.0.0.1
(Jeżeli chcesz zakodować więcej niż jeden statyczny serwer DNS, zobacz to wiki).
Uruchom:
$ sudo resolvconf -u
Sprawdź czy w /etc/resolv.conf jest:
# Generated by resolvconf
Jak i:
nameserver 127.0.0.1
Aby zkonfigurować localdns otwórz wszystkie pliki w /etc/local_dns/ i wypełnij je zgodnie z instrukcjami.
Po instalacji zdefiniowany zostaje proces systemowy. Uruchom go:
$ sudo systemctl start local-dns.service
Aby startował razem z systemem, uruchom:
$ sudo systemctl enable local-dns.service
Zamień local-dns na local-dns-hosts przy wersji edytującej /etc/hosts.
Definiujemy własny server DNS działający na localhoscie, który odpowiada na standardowe query DNSowe jako proxy do prawdziwego serwera. Na query z adresami zakończonymi .localdns, odpowiada zgodnie z zawartoscią /etc/local_dns/DnsMapUser.config.
Serwer wysyła jeden ARP ping pakiet do każdego IP w podsieci wybranej przez użytkownika, równolegle. Inny wątek ciągle słucha pakietów przychodzących, więc jeśli poszukiwany MAC jest w podsieci, dostaniemy odpowiedź od odpowiedniego IP. Dodatkowo, odpowiedzie są zapisywane w cache. Wówczas wyciągamy IP z tego cache jeśli prawdziwe ARP pingi były wykonane relatywnie niedawno ("relatywnie" jest konfigurowane przez użytkownika, domyślnie 30 dni).