aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-hooks/20-dns.conf
blob: d19c6a930e142bcb937d733b83e93b950909a68f (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
40
41
42
43
44
45
46
47
48
49
50
51
# Set net.<iface>.dnsN properties that contain the
# DNS server addresses given by the DHCP server.

if [[ $interface == p2p* ]]
    then
    intf=p2p
    else
    intf=$interface
fi

set_dns_props()
{
    case "${new_domain_name_servers}" in
    "")   return 0;;
    esac

    count=1
    for i in 1 2 3 4; do
        setprop dhcp.${intf}.dns${i} ""
    done

    count=1
    for dnsaddr in ${new_domain_name_servers}; do
        setprop dhcp.${intf}.dns${count} ${dnsaddr}
        count=$(($count + 1))
    done

    separator=" "
    if [ -z "$new_domain_name" ]; then
       separator=""
    else
        if [ -z "$new_domain_search" ]; then
            separator=""
        fi
    fi
    setprop dhcp.${interface}.domain "${new_domain_name}$separator${new_domain_search}"
}

unset_dns_props()
{
    for i in 1 2 3 4; do
        setprop dhcp.${intf}.dns${i} ""
    done

    setprop dhcp.${interface}.domain ""
}

case "${reason}" in
BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT)       set_dns_props;;
EXPIRE|FAIL|IPV4LL|RELEASE|STOP)                unset_dns_props;;
esac