# 20210423 Setting hostname via reverse DNS lookups ## On FCOS 33 ``` dig +short -x 192.168.122.33 rdnsname33. getent -s hosts:files hosts 192.168.122.33 getent -s hosts:resolve hosts 192.168.122.33 192.168.122.33 rdnsname33 getent -s hosts:myhostname hosts 192.168.122.33 192.168.122.33 localhost getent -s hosts:dns hosts 192.168.122.33 192.168.122.33 rdnsname33 resolvectl query 192.168.122.33 192.168.122.33: rdnsname33 -- link: ens2 -- Information acquired via protocol DNS in 502us. -- Data is authenticated: no [core@localhost ~]$ [core@localhost ~]$ rpm -q systemd systemd-246.7-1.fc33.x86_64 ``` ## On FCOS 34 All kinds of random behavior, unless I fully disable systemd-resolved ``` dig +short -x 192.168.122.33 rdnsname33. getent -s hosts:files hosts 192.168.122.33 getent -s hosts:resolve hosts 192.168.122.33 getent -s hosts:myhostname hosts 192.168.122.33 getent -s hosts:dns hosts 192.168.122.33 192.168.122.33 rdnsname33 resolvectl query 192.168.122.33 192.168.122.33: rdnsname33 -- link: ens2 -- Information acquired via protocol DNS in 943us. -- Data is authenticated: no; Data was acquired via local or encrypted transport: no -- Data from: network rpm -q systemd systemd-248-2.fc34.x86_64 ``` ## On Fedora VM: ``` # grep hosts /etc/nsswitch.conf # Valid databases are: aliases, ethers, group, gshadow, hosts, hosts: files myhostname resolve [!UNAVAIL=return] dns ``` See https://bugzilla.redhat.com/show_bug.cgi?id=1943199 for the recent changes in this line. - NM goes through interfaces - prefers one with default route, but - multiple interfaces can have a default route - As it iterates through interfaces: - checks DHCP, then rDNS on each Assume one network, you do get an answer for host_name from DHCP and the other you don't. If `myhostname` is used then in `/etc/nsswitch.conf` and the wrong interface is randomly chosen, then you end up with `localhost` or `fedora` as your hostname.