I'm connected to a company network with domain exampldom.com. Our servers has cool host names like apolo01, apolo-p02 etc. Full domain names of those servers are apolo01.exampldom.com etc.
My colleagues with Windows OS were able to accces those servers just with their hostname, but I, from my Fedora24 laptop, I always had to specify a "long host name" to be able to access them for example via ssh.
I was wondering how this automatic adding of a domain to a hostname works and after a while I found it out.
At first I thought I will solve it via creating an aliases for those "short names". Because instead of using proper naming and realizing that I have host name and domain name in front of my eyes, I called it short name and long name with domain or mayble little bit differenty but still not correctly ;) Therefore I was googling things like "linux alias for a domain" or similar. But with this I was only getting results about what can and can't be done via /etc/hosts file. After a while I asked a colleague who takes care of linux servers and he pointed me to the right direction.
The secret (it's not a secret ;) lies in configuraton of resolver - file /etc/resolv.conf.
When I opened that file on my PC I saw:
» cat /etc/resolv.conf # Generated by NetworkManager search rz.exampldom.com nameserver 100.100.128.12 nameserver 100.100.128.9After reading man pages for "resolv.conf" it was quite clear.
Whenever a system gets a hostname without a domain name to resolve it's IP address, it tries to add the domains which are set in the search configuration option after the hostname.
This search value is received from DHCP server and our DHCP server sends the search option just with value "rz.exampldom.com" and not "exampldom.com", that's the reason why I had to specify the FQDN always when I wanted to access the server which uses the exampldom.com in it's FQDN.
I assume that on windows machines of my colleagues is the exampldom.com domain somehow added.
I've contacted our network guys and asked them if they can add the exampldom.com to the search option of the DHCP server, but because I don't know if it's possible and how long it will take, I wanted to change this option on my laptop on my own.
Changing the /etc/resolv.conf file directly would have no effect, because it's generated by network manager and it would be overwritten after it's restart, but luckily this configuration can be found in the GUI of the network configuration manager.
Edit Connections -> [eth connection] -> Edit -> IPv4 Settings - Additional search domains
And after restart of the NetworkManager my search option was there in the resolv.conf
» sudo systemctl restart NetworkManager.service » » cat /etc/resolv.conf # Generated by NetworkManager search exampldom.com rz.exampldom.com nameserver 100.100.128.12 nameserver 100.100.128.9
That's it, from now on I can ping the servers just via hostname without specifying the domain.
No comments:
Post a Comment