correction to work with first peer
This commit is contained in:
parent
b278771582
commit
bad469b33e
@ -3,7 +3,7 @@
|
||||
## Server
|
||||
```sh
|
||||
pkg_add wireguard-tools
|
||||
pkg_add qrencode #optional
|
||||
pkg_add libqrencode #optional
|
||||
sh wireguard_server.sh
|
||||
```
|
||||
### For each client
|
||||
|
@ -14,11 +14,16 @@ client=$1
|
||||
server_ip=$(curl ipinfo.io/ip)
|
||||
interface="wg0"
|
||||
config_file="/etc/wireguard/${interface}.conf"
|
||||
interface_config_file="/etc/hostname.${interface}"
|
||||
clients_dir="/etc/wireguard/clients"
|
||||
server_port=$(grep "ListenPort" ${config_file} | awk '{print $3}')
|
||||
|
||||
last_ip=$(tail -n 1 ${config_file} |\
|
||||
grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}")
|
||||
if ! [ -n "$last_ip" ]; then
|
||||
# if it's the first peer, config file don't have any IP
|
||||
last_ip=$(head -n 1 ${interface_config_file} | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -n 1)
|
||||
fi
|
||||
new_ip=$(echo "$last_ip" | awk -F. '{print $1"."$2"."$3"."$4+1}')
|
||||
client_ip="${new_ip}/32"
|
||||
|
||||
|
0
wireguard_server.sh
Normal file → Executable file
0
wireguard_server.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user