• 陪伴互联网运营小白共同探索成长,与IT爱好者共享探索乐趣
  • 建站只为分享,欢迎在PC端文章面打赏支持
  • 使用Ctrl+D 可收藏本站

Ubuntu22配置WireGuard客户端

好玩有趣 陆子方 3小时前 6次浏览 0个评论 扫描二维码
文章目录[隐藏]

安装

sudo apt install wireguard -y

配置文件

配置文件放到 /etc/wireguard/ 下,比如 /etc/wireguard/wg0.conf

sudo nano /etc/wireguard/wg0.conf


[Interface]
PrivateKey = xx
Address = 10.0.0.12/24

[Peer]
PublicKey = xx
Endpoint = web.pp.com:10001
AllowedIPs = 10.0.0.0/24, 172.16.31.64/26, 172.16.20.224/27
PersistentKeepalive = 30

#配置里写了 AllowedIPs = 0.0.0.0/0,那么所有流量都会走 wg0。如果只写了内网网段(比如 10.0.0.0/24),那么只有访问那个网段时才会走 WireGuard。

启停

启动连接
sudo wg-quick up wg0

断开连接
sudo wg-quick down wg0

开机自动启动
sudo systemctl enable wg-quick@wg0

查看更多

sudo wg show

interface: wg0
  public key: xx
  private key: (hidden)
  listening port: 36361

peer: xx
  endpoint: xxx:10001
  allowed ips: 10.0.0.0/24, 172.16.31.64/26, 172.16.20.224/27
  latest handshake: 33 seconds ago
  transfer: 2.81 MiB received, 194.58 KiB sent
  persistent keepalive: every 30 seconds


子方有料原创丨转载请注明原文链接
期待您的评论或捐赠,这是最好的鼓励和支持!
喜欢 (0)
[赞赏使我快乐]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到