fix mistake
parent
4a4cadf8fb
commit
f773a36873
14
wginstall.sh
14
wginstall.sh
|
@ -45,20 +45,18 @@ generate_keys() {
|
||||||
echo "正在生成WireGuard私钥和公钥..."
|
echo "正在生成WireGuard私钥和公钥..."
|
||||||
wg genkey | tee privatekey | wg pubkey > publickey && cat privatekey && cat publickey
|
wg genkey | tee privatekey | wg pubkey > publickey && cat privatekey && cat publickey
|
||||||
echo "生成客户端私钥和公钥"
|
echo "生成客户端私钥和公钥"
|
||||||
wg genkey | tee cprivatekey | wg pubkey > cpublickey
|
wg genkey | tee cprivatekey | wg pubkey > cpublickey && cat cprivatekey && cat cpublickey
|
||||||
client1=$(cat cprivatekey)
|
|
||||||
client2=$(cat cpublickey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create_server_config() {
|
create_server_config() {
|
||||||
# 服务器端配置
|
# 服务器端配置
|
||||||
read -p "请输入服务器的公网IP地址: " server_public_ip
|
read -p "请输入服务器的公网IP地址: " server_public_ip
|
||||||
read -p "请输入服务器的内网IP地址: " server_internal_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 "请输入WireGuard服务器端口号: " server_port
|
||||||
read -p "请输入客户端的公钥: " client_public_key
|
read -p "请输入客户端的公钥: " client_public_key
|
||||||
read -p "请输入客户端的内网IP地址: " client_internal_ip
|
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)
|
eth=$(ls /sys/class/net| grep ^e | head -n1)
|
||||||
|
|
||||||
# 创建服务器端配置文件
|
# 创建服务器端配置文件
|
||||||
|
@ -77,8 +75,8 @@ create_server_config() {
|
||||||
echo "WireGuard服务器端配置文件已成功创建在 /etc/wireguard/wg0.conf。"
|
echo "WireGuard服务器端配置文件已成功创建在 /etc/wireguard/wg0.conf。"
|
||||||
cat > /etc/wireguard/client.conf <<-EOF
|
cat > /etc/wireguard/client.conf <<-EOF
|
||||||
[Interface]
|
[Interface]
|
||||||
PrivateKey = $client1
|
PrivateKey = $(cat /etc/wireguard/cprivatekey)
|
||||||
Address = client_internal_ip/32,$client_internal_ipv6/128
|
Address = $client_internal_ip/32,$client_internal_ipv6/128
|
||||||
DNS = 8.8.8.8
|
DNS = 8.8.8.8
|
||||||
MTU = 1420
|
MTU = 1420
|
||||||
[Peer]
|
[Peer]
|
||||||
|
@ -87,7 +85,7 @@ Endpoint = $server_public_ip:$server_port
|
||||||
AllowedIPs = 0.0.0.0/0, ::0/0
|
AllowedIPs = 0.0.0.0/0, ::0/0
|
||||||
PersistentKeepalive = 25
|
PersistentKeepalive = 25
|
||||||
EOF
|
EOF
|
||||||
echo "自动生成客户端配置文件在"
|
echo "自动生成客户端配置文件在 /etc/wireguard/client.conf"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_client_config() {
|
create_client_config() {
|
||||||
|
|
Loading…
Reference in New Issue