From 4a4cadf8fb03403fe1590ac466aaf05b3be0c430 Mon Sep 17 00:00:00 2001 From: yanglc Date: Wed, 30 Aug 2023 08:33:44 +0800 Subject: [PATCH] update client config --- wginstall.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wginstall.sh b/wginstall.sh index b447272..095c6d3 100644 --- a/wginstall.sh +++ b/wginstall.sh @@ -44,6 +44,10 @@ generate_keys() { # 生成WireGuard私钥和公钥 echo "正在生成WireGuard私钥和公钥..." wg genkey | tee privatekey | wg pubkey > publickey && cat privatekey && cat publickey + echo "生成客户端私钥和公钥" + wg genkey | tee cprivatekey | wg pubkey > cpublickey + client1=$(cat cprivatekey) + client2=$(cat cpublickey) } create_server_config() { @@ -71,6 +75,19 @@ create_server_config() { echo "AllowedIPs = $client_internal_ip/32,$client_internal_ipv6/128" >> /etc/wireguard/wg0.conf echo "WireGuard服务器端配置文件已成功创建在 /etc/wireguard/wg0.conf。" + cat > /etc/wireguard/client.conf <<-EOF +[Interface] +PrivateKey = $client1 +Address = client_internal_ip/32,$client_internal_ipv6/128 +DNS = 8.8.8.8 +MTU = 1420 +[Peer] +PublicKey = $(cat /etc/wireguard/publickey) +Endpoint = $server_public_ip:$server_port +AllowedIPs = 0.0.0.0/0, ::0/0 +PersistentKeepalive = 25 +EOF + echo "自动生成客户端配置文件在" } create_client_config() {