VPS host.domain.tld Issue

General support questions
scnlabs
Posts: 1
Joined: 2018/01/20 19:17:07

VPS host.domain.tld Issue

Postby scnlabs » 2018/01/20 20:16:56

So I've been having issues with this VPS on a LX* container, everytime i do a reboot i have to manually change the host and domain name. My resolv.conf file also gets reset, i assume this is done by the container provider. My question is what would be the best solution to work around this? I want to setup a rDNS zone in BIND and i feel like this is going to cause trouble for me. I notice there's a little bit on reseting host-names and such in the 'network-scripts' file. I assume this is irrelevant as i have set all the variants of my FQDN in the appropriate locations.



Code: Select all

is_hostname_set ()
{
    case "${HOSTNAME}" in
        '(none)' | 'localhost' | 'localhost.localdomain')
            # Hostname NOT set:
            return 1
            ;;
        *)
            # Hostname IS set:
            return 0
            ;;
    esac
}

need_hostname ()
{
    # Should we avoid obtaining hostname from DHCP? (user override)
    is_true "${NO_DHCP_HOSTNAME}" && return 1

    if is_hostname_set; then
        # Hostname is already set, we do not need to acquire it:
        return 1
    else
        # Hostname is NOT set, we need to acquire it:
        return 0
    fi
}

set_hostname_options ()
{
    # User explicitly requires to *not* send DHCP_HOSTNAME, DHCP_FQDN or HOSTNAME:
    is_false "${DHCP_SEND_HOSTNAME}" && return

    if [[ -n "${DHCP_HOSTNAME}" && -n "${DHCP_FQDN}" ]]; then
        net_log $"Both 'DHCP_HOSTNAME=${DHCP_HOSTNAME}' and 'DHCP_FQDN=${DHCP_FQDN}' are configured... Using DHCP_FQDN." warning
    fi

    local hostname_options=''

    # DHCP_FQDN takes precedence before DHCP_HOSTNAME -- as it does in NetworkManager,
    # and DHCP_HOSTNAME takes precedence before HOSTNAME:
    if [[ -n "${DHCP_FQDN}" ]]; then
        hostname_options="-F ${DHCP_FQDN}"
    elif [[ -n "${DHCP_HOSTNAME}" ]]; then
        hostname_options="-H ${DHCP_HOSTNAME}"
    elif is_hostname_set; then
        # We need to truncate the hostname in case it is the FQDN:
        hostname_options="-H ${HOSTNAME%%.*}"
    else
        # Nothing to send to the DHCP server:
        # ['(none)', 'localhost' or 'localhost.localdomain' are not valid]
        return
    fi

    # Append the hostname options to the content of passed variable name:
    eval "$1='${!1} ${hostname_options}'"