summaryrefslogtreecommitdiff
path: root/src/etc/dhcp/dhclient-enter-hooks.d/04-vyos-resolvconf
blob: ea5562ea8f6730b52b5cc04ff3c62d0e2a64bb84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# modified make_resolv_conf () for Vyatta system below
make_resolv_conf() {
    if [ -n "$new_domain_name" ]; then
        logmsg info "Adding search-domain \"$new_domain_name\" via vyos-hostsd-client"
        /usr/bin/vyos-hostsd-client --set-host-name --search-domain $new_domain_name
    fi

    if [ -n "$new_dhcp6_domain_search" ]; then
        logmsg info "Adding search-domain \"$new_dhcp6_domain_search\" via vyos-hostsd-client"
        /usr/bin/vyos-hostsd-client --set-host-name --search-domain $new_dhcp6_domain_search
    fi

    if [ -n "$new_domain_name_servers" ] && ! cli-shell-api existsEffective system disable-dhcp-nameservers && [ "$new_domain_name_servers" != "$old_domain_name_servers" ] ; then
        logmsg info "Deleting nameservers with tag \"dhcp-$interface\" via vyos-hostsd-client"
        vyos-hostsd-client --delete-name-servers --tag dhcp-$interface
        NEW_SERVERS=""
        for nameserver in $new_domain_name_servers; do
            NEW_SERVERS="$NEW_SERVERS --name-server $nameserver"
        done
        logmsg info "Adding nameservers \"$NEW_SERVERS\" with tag \"dhcp-$interface\" via vyos-hostsd-client"
        /usr/bin/vyos-hostsd-client --add-name-servers $NEW_SERVERS --tag dhcp-$interface
    fi

    if [ -n "$new_dhcp6_name_servers" ] && ! cli-shell-api existsEffective system disable-dhcp-nameservers && [ "$new_dhcp6_name_servers" != "$old_dhcp6_name_servers" ] ; then
        logmsg info "Deleting nameservers with tag \"dhcpv6-$interface\" via vyos-hostsd-client"
        vyos-hostsd-client --delete-name-servers --tag dhcpv6-$interface
        NEW_SERVERS=""
        for nameserver in $new_dhcp6_name_servers; do
            NEW_SERVERS="$NEW_SERVERS --name-server $nameserver"
        done
        logmsg info "Adding nameservers \"$NEW_SERVERS\" with tag \"dhcpv6-$interface\" via vyos-hostsd-client"
        /usr/bin/vyos-hostsd-client --add-name-servers $NEW_SERVERS --tag dhcpv6-$interface
    fi

    if cli-shell-api existsEffective service dns forwarding; then
        logmsg info "Enabling DNS forwarding"
        /usr/libexec/vyos/conf_mode/dns_forwarding.py --dhclient
    fi
}