cat > /root/nat64-dns64.sh << 'EOF'
#!/bin/bash
set -e

echo "[+] Installing packages..."
apt update
apt install -y tayga bind9 iptables iproute2

echo "[+] Enable forwarding..."
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1

sed -i 's/^#\?net.ipv4.ip_forward=.*/net.ipv4.ip_forward=1/' /etc/sysctl.conf
sed -i 's/^#\?net.ipv6.conf.all.forwarding=.*/net.ipv6.conf.all.forwarding=1/' /etc/sysctl.conf

echo "[+] Configure tayga..."
cat > /etc/tayga.conf << TAYGA
tun-device nat64
ipv4-addr 192.168.255.1
prefix 64:ff9b::/96
dynamic-pool 192.168.255.0/24
data-dir /var/lib/tayga
TAYGA

mkdir -p /var/lib/tayga
tayga --mktun || true

ip link set nat64 up || true
ip addr add 64:ff9b::1/96 dev nat64 || true

systemctl enable tayga
systemctl restart tayga

echo "[+] Configure iptables..."
EXT_IF=$(ip route | awk '/default/ {print $5; exit}')
iptables -t nat -C POSTROUTING -s 192.168.255.0/24 -o $EXT_IF -j MASQUERADE 2>/dev/null || \
iptables -t nat -A POSTROUTING -s 192.168.255.0/24 -o $EXT_IF -j MASQUERADE

echo "[+] Configure bind9 DNS64..."
cat > /etc/bind/named.conf.options << BIND
options {
    directory "/var/cache/bind";
    listen-on-v6 { any; };
    listen-on { none; };
    allow-query { any; };
    recursion yes;

    dns64 64:ff9b::/96 {
        clients { any; };
        mapped { any; };
        exclude { ::ffff:0:0/96; };
    };

    forwarders {
        2001:4860:4860::8888;
        2001:4860:4860::8844;
    };
};
BIND

systemctl enable bind9
systemctl restart bind9

echo "[+] Set local DNS..."
echo "nameserver ::1" > /etc/resolv.conf

echo "[✓] NAT64 + DNS64 setup completed."
EOF


执行

chmod +x /root/nat64-dns64.sh
bash /root/nat64-dns64.sh