site A

mkdir -p /opt/wireguard/siteA
cd /opt/wireguard/siteA
umask 077
wg genkey > privatekey-siteA
wg pubkey < privatekey-siteA > publickey-siteA
wg genpsk > presharedkey-siteA

ip link add dev wg0 type wireguard
ip address add dev wg0 192.168.2.1/24
ip address add dev wg0 192.168.2.1 peer 192.168.2.2
wg set wg0 listen-port 51820 private-key /opt/wireguard/siteA/privatekey-siteA peer $publickey allowed-ips 192.168.88.0/24 endpoint $$:51829
ip link set up dev wg0

site B

mkdir -p /opt/wireguard/siteB
cd /opt/wireguard/siteB
umask 077
wg genkey > privatekey-siteB
wg pubkey < privatekey-siteB > publickey-siteB
wg genpsk > presharedkey-siteB

ip link add dev wg0 type wireguard
ip address add dev wg0 192.168.2.2/24
ip address add dev wg0 192.168.2.2 peer 192.168.2.1
wg set wg0 listen-port 51820 private-key /opt/wireguard/siteA/privatekey-siteB peer $publickey allowed-ips 192.168.66.0/24 endpoint $$:51829
ip link set up dev wg0
最后修改:2023 年 11 月 03 日
如果觉得我的文章对你有用,请随意赞赏