diff --git a/wginstall.sh b/wginstall.sh index ba4a4f8..b447272 100644 --- a/wginstall.sh +++ b/wginstall.sh @@ -50,15 +50,17 @@ create_server_config() { # 服务器端配置 read -p "请输入服务器的公网IP地址: " server_public_ip read -p "请输入服务器的内网IP地址: " server_internal_ip + read -p "请输入服务器的内网IPv6地址:(fd86::1/48) " server_internal_ipv6 read -p "请输入WireGuard服务器端口号: " server_port read -p "请输入客户端的公钥: " client_public_key read -p "请输入客户端的内网IP地址: " client_internal_ip + read -p "请输入客户端的内网IPv6地址:(fd86::2/48) " client_internal_ipv6 eth=$(ls /sys/class/net| grep ^e | head -n1) # 创建服务器端配置文件 echo "[Interface]" > /etc/wireguard/wg0.conf echo "PrivateKey = $(cat /etc/wireguard/privatekey)" >> /etc/wireguard/wg0.conf - echo "Address = $server_internal_ip/24" >> /etc/wireguard/wg0.conf + echo "Address = $server_internal_ip/24,$server_internal_ipv6/48" >> /etc/wireguard/wg0.conf echo "PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o $eth -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o $eth -j MASQUERADE" >> /etc/wireguard/wg0.conf echo "PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o $eth -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o $eth -j MASQUERADE" >> /etc/wireguard/wg0.conf echo "ListenPort = $server_port" >> /etc/wireguard/wg0.conf @@ -66,7 +68,7 @@ create_server_config() { echo "" >> /etc/wireguard/wg0.conf echo "[Peer]" >> /etc/wireguard/wg0.conf echo "PublicKey = $client_public_key" >> /etc/wireguard/wg0.conf - echo "AllowedIPs = $client_internal_ip/32" >> /etc/wireguard/wg0.conf + echo "AllowedIPs = $client_internal_ip/32,$client_internal_ipv6/128" >> /etc/wireguard/wg0.conf echo "WireGuard服务器端配置文件已成功创建在 /etc/wireguard/wg0.conf。" }