Browsing this Thread:   1 Anonymous Users






Wireguard ddns ip check
#1
Just can't stay away
Just can't stay away


See User information
#!/bin/bash

wgconf="wg0"
ddnshost="ddns.xlxz.org"
iptype="a" # ipv6 aaaa | ipv4 a

digIP=$(dig +short "$ddnshost" "$iptype

wgip=$(wg show "$wgconfendpoints)
echo 
"wgip->  $wgip"

cip=$(echo "$wgipgrep --o $digIP)

echo 
"cip-> $cip"
echo "digip-> $digIP"

     
if [ "$wgip== "" ];
     
then
    
echo "wg not run"
     
elif "$digIP!= "$cip
     
then
         
echo "update ip"
      
/usr/bin/wg-quick down "$wgconf"
      
/usr/bin/wg-quick up  "$wgconf"
     
else
        echo 
"not need update ip"
     
fi

Posted on: 2021/5/26 9:33

Edited by eyex on 2021/5/26 16:21:43
Edited by eyex on 2021/5/29 12:34:23
Edited by eyex on 2021/5/29 12:38:42
Top


Re: Wireguard ddns ip check
#2
Just can't stay away
Just can't stay away


See User information
[Interface]
# Name = relay1.wg.example.com
Address 192.0.2.1/24
ListenPort 
51820
PrivateKey 
oJpRt2Oq27vIB5/UVb7BRqCwad2YMReQgH5tlxz8YmI=
DNS 1.1.1.1,8.8.8.8
PostUp 
iptables -A FORWARD -i wg0 -j ACCEPTiptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEip6tables -A FORWARD -i wg0  -j ACCEPTip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown 
iptables -D FORWARD -i wg0 -j ACCEPTiptables -t nat -D POSTROUTING -o eth0 -j MASQUERADEip6tables -D FORWARD -i wg0 -j ACCEPTip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
# Name = peer1.wg.example.com
PublicKey I+hXRAJOG/UE2IQvIHsou2zTgkUyPve2pzvHTnd/2Gg=
AllowedIPs 192.0.2.2/32

Posted on: 2022/1/22 11:30
Top








friend links
Themes

(2 themes)
Login
Username:

Password:


Lost Password?
Register now!
Categories
Xoops (11)
--Modules (2)
--Themes (0)
Article (8)