31
31
#
32
32
33
33
BIND_CONF_OPTIONS=/etc/bind/named.conf.options
34
- RESOLV_CONF=/etc/resolv.conf
35
34
NAT64_PREFIX=64:ff9b::/96
36
35
37
36
DNS64_NAMESERVER_ADDR=127.0.0.1
38
37
DNS64_CONF=" dns64 ` echo $NAT64_PREFIX | tr \" /\" \"\/\" ` { clients { any; }; recursive-only yes; };"
39
38
39
+ # Currently solution was verified only on raspbian and ubuntu.
40
+ #
41
+ without NAT64 || test $PLATFORM = ubuntu || test $PLATFORM = raspbian || die " dns64 is not tested under $PLATFORM ."
42
+
43
+ if [ $PLATFORM = raspbian ]; then
44
+ RESOLV_CONF_HEAD=/etc/resolv.conf.head
45
+ elif [ $PLATFORM = ubuntu ]; then
46
+ RESOLV_CONF_HEAD=/etc/resolvconf/resolv.conf.d/head
47
+ fi
48
+
49
+ dns64_update_resolvconf ()
50
+ {
51
+ if [ $PLATFORM = ubuntu ]; then
52
+ sudo resolvconf -u || true
53
+ elif [ $PLATFORM = raspbian ]; then
54
+ sudo systemctl restart dhcpcd || true
55
+ fi
56
+ }
57
+
40
58
dns64_install ()
41
59
{
42
60
with NAT64 && with DNS64 || return 0
43
61
44
62
test -f $BIND_CONF_OPTIONS || die ' Cannot find bind9 configuration file!'
45
63
sudo sed -i ' /^};/i\\tallow-recursion { any; };' $BIND_CONF_OPTIONS
46
64
sudo sed -i ' /^};/i\\t' " $DNS64_CONF " $BIND_CONF_OPTIONS
65
+
66
+ sudo sh -c " echo \" nameserver $DNS64_NAMESERVER_ADDR \" >> $RESOLV_CONF_HEAD "
67
+
68
+ if have systemctl; then
69
+ sudo systemctl enable bind9 || true
70
+ sudo systemctl is-enabled bind9 || die ' Failed to enable bind9!'
71
+ sudo systemctl start bind9 || die ' Failed to start bind9!'
72
+ fi
73
+
74
+ dns64_update_resolvconf
47
75
}
48
76
49
77
dns64_uninstall ()
50
78
{
51
79
with NAT64 && with DNS64 || return 0
52
80
53
- dns64_stop
81
+ dns64_stop
54
82
sudo sed -i ' /^\tallow-recursion/d' $BIND_CONF_OPTIONS
55
83
sudo sed -i ' /^\tdns64/d' $BIND_CONF_OPTIONS
84
+
85
+ sudo sed -i ' /^nameserver ' $DNS64_NAMESERVER_ADDR ' /d' $RESOLV_CONF_HEAD || true
86
+
87
+ dns64_update_resolvconf
88
+
89
+ if have systemctl; then
90
+ sudo systemctl stop bind9 || true
91
+ sudo systemctl disable bind9 || true
92
+ fi
56
93
}
57
94
58
95
dns64_start ()
59
96
{
60
97
with NAT64 && with DNS64 || return 0
61
98
62
- if have systemctl; then
99
+ if have systemctl; then
63
100
sudo systemctl start bind9 || die ' Failed to start bind9!'
64
101
fi
65
-
66
- sudo sed -i ' 1a nameserver ' $DNS64_NAMESERVER_ADDR $RESOLV_CONF
67
102
}
68
103
69
104
dns64_stop ()
@@ -73,6 +108,4 @@ dns64_stop()
73
108
if have systemctl; then
74
109
sudo systemctl stop bind9 || true
75
110
fi
76
-
77
- sudo sed -i ' /^nameserver\s' $DNS64_NAMESERVER_ADDR ' /d' $RESOLV_CONF
78
111
}
0 commit comments