update client config

main
yanglc 2023-08-30 08:33:44 +08:00
parent 6d10dee75d
commit 4a4cadf8fb
1 changed files with 17 additions and 0 deletions

View File

@ -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() {