Update: Add IPv6 DNS

This commit is contained in:
Chongyun Lee
2022-04-22 15:06:55 +08:00
parent 80908237d8
commit 8298333eb5
2 changed files with 36 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ export PATH=/system/bin
echo "127.0.0.1 localhost $(busybox hostname)" > /system/etc/hosts echo "127.0.0.1 localhost $(busybox hostname)" > /system/etc/hosts
echo "::1 ip6-localhost" >> /system/etc/hosts echo "::1 ip6-localhost" >> /system/etc/hosts
# IPv4
for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do
ip_addr=$(busybox nslookup -type=a "$host" 8.8.8.8 | busybox awk '/^Address: / { print $2 ; exit }') ip_addr=$(busybox nslookup -type=a "$host" 8.8.8.8 | busybox awk '/^Address: / { print $2 ; exit }')
@@ -15,3 +16,20 @@ for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^
echo "$ip_addr $host" | busybox tee -a /system/etc/hosts echo "$ip_addr $host" | busybox tee -a /system/etc/hosts
done done
# Check whether IPv6 is available.
busybox wget http://[2606:4700:4700::1111] >/dev/null 2>&1
if [[ $? != 0 ]]; then
exit
fi
# IPv6
for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do
ip_addr=$(busybox nslookup -type=aaaa "$host" 2001:4860:4860::8888 | busybox awk '/^Address: / { print $2 ; exit }')
if [ -z "$ip_addr" ]; then
echo "Can't resolve '$host'." >&2
continue
fi
echo "$ip_addr $host" | busybox tee -a /system/etc/hosts
done

View File

@@ -5,6 +5,7 @@ export PATH=/system/bin
echo "127.0.0.1 localhost $(busybox hostname)" > /system/etc/hosts echo "127.0.0.1 localhost $(busybox hostname)" > /system/etc/hosts
echo "::1 ip6-localhost" >> /system/etc/hosts echo "::1 ip6-localhost" >> /system/etc/hosts
# IPv4
for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do
ip_addr=$(busybox nslookup -type=a "$host" 8.8.8.8 | busybox awk '/^Address: / { print $2 ; exit }') ip_addr=$(busybox nslookup -type=a "$host" 8.8.8.8 | busybox awk '/^Address: / { print $2 ; exit }')
@@ -15,3 +16,20 @@ for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^
echo "$ip_addr $host" | busybox tee -a /system/etc/hosts echo "$ip_addr $host" | busybox tee -a /system/etc/hosts
done done
# Check whether IPv6 is available.
busybox wget http://[2606:4700:4700::1111] >/dev/null 2>&1
if [[ $? != 0 ]]; then
exit
fi
# IPv6
for host in $(busybox cat /system/etc/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do
ip_addr=$(busybox nslookup -type=aaaa "$host" 2001:4860:4860::8888 | busybox awk '/^Address: / { print $2 ; exit }')
if [ -z "$ip_addr" ]; then
echo "Can't resolve '$host'." >&2
continue
fi
echo "$ip_addr $host" | busybox tee -a /system/etc/hosts
done