How to use Search domain in Fedora24 / 08 Jul 2016 / Author: Haim Ari

    Estimated read time: 1 min

    Sometimes you want you DNS configuration to be configured in a specific way For example at work i need a specific “search domain” in order to use short names in aliases and such. There are many other reasons to need this…

    The problem is that if you add a search domain or a favorite DNS server, NetworkManager will overwrite /etc/resolv.conf each time it runs, and replace it’s content with the dhcp published nameservers. and in the Network Manager there is no option to add a “DOMAIN”

    Also if you will try to add it to your interfaces: DOMAIN=”your-domain.com”

    it will not work.

    I order to still allow dhcp to update the DNS and avoid issues in different WIFI networks such as in Hotels, Use a dispatcher script which appends your dns records to any Ethernet interface / WIFI network.

    put a script here and grant it with execute permissions:

    vi /etc/NetworkManager/dispatcher.d/your-script.sh
    

    Copy these lines to it:

    #!/bin/bash
    echo "search your-domain.com" >> /etc/resolv.conf
    

    Save the file and grant permissions:

    chmod +x /etc/NetworkManager/dispatcher.d/your-script.sh
    

    This was tested on Fedora23-24