修复:修改Interface地址后新增peer地址不会改变
修复了修改Interface地址后,新增peer地址不会改变随Interface改变而改变的问题
This commit is contained in:
parent
0e06513eb5
commit
a74a8e96f3
1 changed files with 3 additions and 2 deletions
|
@ -150,19 +150,20 @@ new_client_setup () {
|
|||
fi
|
||||
key=$(wg genkey)
|
||||
psk=$(wg genpsk)
|
||||
ipTop=$(cat /etc/wireguard/wg0.conf| grep -oE "([0-9]{1,3}\.){2}[0-9]{1,3}" | head -1)
|
||||
# Configure client in the server
|
||||
cat << EOF >> /etc/wireguard/wg0.conf
|
||||
# BEGIN_PEER $client
|
||||
[Peer]
|
||||
PublicKey = $(wg pubkey <<< $key)
|
||||
PresharedKey = $psk
|
||||
AllowedIPs = 10.7.0.$octet/32$(grep -q 'fddd:2c4:2c4:2c4::1' /etc/wireguard/wg0.conf && echo ", fddd:2c4:2c4:2c4::$octet/128")
|
||||
AllowedIPs = $ipTop.$octet/32$(grep -q 'fddd:2c4:2c4:2c4::1' /etc/wireguard/wg0.conf && echo ", fddd:2c4:2c4:2c4::$octet/128")
|
||||
# END_PEER $client
|
||||
EOF
|
||||
# Create client configuration
|
||||
cat << EOF > ~/"$client".conf
|
||||
[Interface]
|
||||
Address = 10.7.0.$octet/24$(grep -q 'fddd:2c4:2c4:2c4::1' /etc/wireguard/wg0.conf && echo ", fddd:2c4:2c4:2c4::$octet/64")
|
||||
Address = $ipTop.$octet/24$(grep -q 'fddd:2c4:2c4:2c4::1' /etc/wireguard/wg0.conf && echo ", fddd:2c4:2c4:2c4::$octet/64")
|
||||
DNS = $dns
|
||||
PrivateKey = $key
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue