fix mistake

main
yanglc 2023-08-30 09:06:25 +08:00
parent 4a4cadf8fb
commit f773a36873
1 changed files with 6 additions and 8 deletions

View File

@ -45,20 +45,18 @@ generate_keys() {
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)
wg genkey | tee cprivatekey | wg pubkey > cpublickey && cat cprivatekey && cat cpublickey
}
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 "请输入服务器的内网IPv6地址(fd86::1) " 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
read -p "请输入客户端的内网IPv6地址(fd86::2) " client_internal_ipv6
eth=$(ls /sys/class/net| grep ^e | head -n1)
# 创建服务器端配置文件
@ -77,8 +75,8 @@ create_server_config() {
echo "WireGuard服务器端配置文件已成功创建在 /etc/wireguard/wg0.conf。"
cat > /etc/wireguard/client.conf <<-EOF
[Interface]
PrivateKey = $client1
Address = client_internal_ip/32,$client_internal_ipv6/128
PrivateKey = $(cat /etc/wireguard/cprivatekey)
Address = $client_internal_ip/32,$client_internal_ipv6/128
DNS = 8.8.8.8
MTU = 1420
[Peer]
@ -87,7 +85,7 @@ Endpoint = $server_public_ip:$server_port
AllowedIPs = 0.0.0.0/0, ::0/0
PersistentKeepalive = 25
EOF
echo "自动生成客户端配置文件在"
echo "自动生成客户端配置文件在 /etc/wireguard/client.conf"
}
create_client_config() {