{"id":7540,"date":"2022-04-24T18:55:52","date_gmt":"2022-04-24T10:55:52","guid":{"rendered":"https:\/\/blog.pfchina.org\/?p=7540"},"modified":"2024-08-20T11:43:34","modified_gmt":"2024-08-20T03:43:34","slug":"opnsense%e4%b8%8eubuntu-wireguard%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%bb%ba%e7%ab%8b%e7%82%b9%e5%af%b9%e7%82%b9%e8%bf%9e%e6%8e%a5%ef%bc%8c%e5%ae%9e%e7%8e%b0vpn%e7%ad%96%e7%95%a5%e8%b7%af%e7%94%b1","status":"publish","type":"post","link":"https:\/\/blog.pfchina.org\/?p=7540","title":{"rendered":"pfSense\u4f7f\u7528WireGuard\u5efa\u7acb\u70b9\u5bf9\u70b9\u8fde\u63a5\uff0c\u5b9e\u73b0\u7b56\u7565\u8def\u7531"},"content":{"rendered":"<p style=\"text-align: justify;\">WireGuard\u662f\u4e00\u79cd\u6700\u65b0\u7684\u5f00\u6e90VPN\u7a0b\u5e8f\u548c\u534f\u8bae\uff0c\u5b83\u6bd4\u4f20\u7edf\u7684VPN\u66f4\u7b80\u5355\uff0c\u4f20\u8f93\u901f\u5ea6\u4e5f\u66f4\u5feb\u3002\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728Ubuntu 20.04 LTS Linux \u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u548c\u8bbe\u7f6e WireGuard VPN\u670d\u52a1\u5668\uff0c\u5e76\u4e0epfSense\u5efa\u7acb\u70b9\u5bf9\u70b9\u8fde\u63a5\uff0c\u5b9e\u73b0VPN\u7b56\u7565(\u5206\u6d41)\u8def\u7531\u3002<\/p>\n<p style=\"text-align: justify;\">\u672c\u793a\u4f8b\u670d\u52a1\u5668\u8fd0\u884cUbuntu 20.04 LTS\u3002VPN\u96a7\u9053\u5b50\u7f51\uff1a10.10.0.0\/24\uff0c\u670d\u52a1\u5668WG\u63a5\u53e3\u5730\u574010.10.0.1\uff0cpfSense\u9632\u706b\u5899WG\u63a5\u53e3\u5730\u574010.10.0.2\u3002<\/p>\n<h1 style=\"text-align: justify;\">\u670d\u52a1\u5668\u914d\u7f6e<\/h1>\n<p style=\"text-align: justify;\">\u5728Ubuntu 20.04 LTS\u7cfb\u7edf\u4e0a\u5b89\u88c5WireGuard\u5206\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<h2 style=\"text-align: justify;\">\u5b89\u88c5WireGuard<\/h2>\n<p style=\"text-align: justify;\">\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\u7cfb\u7edf\uff1a<\/p>\n<pre class=\"code\">apt upgrade<\/pre>\n<p style=\"text-align: justify;\">\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5WireGuard:<\/p>\n<pre class=\"code\">apt install wireguard<\/pre>\n<p>\u914d\u7f6eWireGuard\uff0c\u8fdb\u5165wireguard\u76ee\u5f55\uff1a<\/p>\n<pre class=\"code\">cd \/etc\/wireguard\/<\/pre>\n<p>\u751f\u6210\u516c\u94a5\u548c\u79c1\u94a5\uff1a<\/p>\n<pre class=\"code\">umask 077; wg genkey | tee privatekey | wg pubkey &gt; publickey<\/pre>\n<p style=\"text-align: justify;\">\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u751f\u6210\u7684\u79c1\u94a5\u5e76\u8bb0\u5f55\u5230\u8bb0\u4e8b\u672c\uff1a<\/p>\n<pre class=\"code\">cat privatekey<\/pre>\n<pre>IPb6tTT+M6V428O1RPV4p5AwwiLdG2Ul1I3AJiy2FVE=<\/pre>\n<p style=\"text-align: justify;\">\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u751f\u6210\u7684\u516c\u94a5\uff0c\u5e76\u8bb0\u5f55\u5230\u8bb0\u4e8b\u672c\uff1a<\/p>\n<pre class=\"code\">cat publickey<\/pre>\n<pre>HaFVrLOzDyWZrutPYi0jsc2ZKrSa4e\/UWkPJZGi00wk=<\/pre>\n<p style=\"text-align: justify;\">\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5vim\u6587\u672c\u7f16\u8f91\u7a0b\u5e8f<\/p>\n<pre class=\"code\">apt install vim<\/pre>\n<p style=\"text-align: justify;\">\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u7f16\u8f91WireGuard\u7684\u914d\u7f6e\u6587\u4ef6wg0.conf\uff1a<span style=\"background-color: #f5f5f5; font-family: Consolas, Monaco, monospace;\">vim \/etc\/wireguard\/wg0.conf<\/span><\/p>\n<div class=\"wp-geshi-highlight-wrap5\" style=\"text-align: justify;\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<p>\u5185\u5bb9\u5982\u4e0b:<\/p>\n<pre class=\"code\">[Interface] Address = 10.0.0.1\/24 \r\nPostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE\r\nPostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE\r\nListenPort = 51820 \r\nPrivateKey = IPb6tTT+M6V428O1RPV4p5AwwiLdG2Ul1I3AJiy2FVE= \r\n\r\n[Peer] \r\nPublicKey = vqWe0YTUvZIXGkQp8XfZX3kx8ljihLiObc5d7A3NfC0= \r\nAllowedIPs = 10.10.0.1\/32<\/pre>\n<p>\u5176\u4e2dPeer\u7684PublicKey(\u516c\u94a5)\u5728pfSense\u96a7\u9053\u4e0a\u590d\u5236\u3002\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684eth0\u4e3a\u670d\u52a1\u5668\u516c\u7f51\u7f51\u5361\u540d\u79f0\uff0c\u53ef\u4ee5\u7528&#8221;ip a&#8221;\u6216&#8221;ifconfig&#8221;\u547d\u4ee4\u67e5\u770b\u3002<\/p>\n<h2 class=\"wp-geshi-highlight-wrap\">\u8bbe\u7f6e\u670d\u52a1\u5668\u9632\u706b\u5899\u76d1\u542c\u7aef\u53e3<\/h2>\n<p>\u8fd9\u91cc\u5047\u8bbe\u5df2\u7ecf\u914d\u7f6e\u4e86UFW(\u5982\u4f55\u914d\u7f6e\u53ef\u4ee5\u53c2\u8003\u8fd9\u7bc7<a href=\"https:\/\/www.cyberciti.biz\/faq\/how-to-configure-firewall-with-ufw-on-ubuntu-20-04-lts\/\">\u6587\u7ae0<\/a>\u3002\u4f7f\u7528ufw \u547d\u4ee4\u6253\u5f00\u670d\u52a1\u5668\u7684UDP\u7aef\u53e351820\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<pre class=\"code\">ufw allow 51820\/udp<\/pre>\n<p style=\"text-align: justify;\">\u9a8c\u8bc1\u8bbe\u7f6e\uff1a<\/p>\n<pre class=\"code\">ufw status<\/pre>\n<h2 style=\"text-align: justify;\">\u542f\u52a8WireGuard \u670d\u52a1<\/h2>\n<p style=\"text-align: justify;\">\u542f\u7528WireGuard\u670d\u52a1\uff1a<\/p>\n<pre class=\"code\">systemctl enable wg-quick@wg0<\/pre>\n<p style=\"text-align: justify;\">\u8fd0\u884cWireGuard\u670d\u52a1\uff1a<\/p>\n<pre class=\"code\">systemctl start wg-quick@wg0<\/pre>\n<p style=\"text-align: justify;\">\u67e5\u770b\u670d\u52a1\u72b6\u6001\uff1a<\/p>\n<pre class=\"code\">systemctl status wg-quick@wg0<\/pre>\n<p style=\"text-align: justify;\">\u4f7f\u7528ip\u547d\u4ee4\u9a8c\u8bc1wg \u7684\u63a5\u53e3\u72b6\u6001\uff1a<\/p>\n<pre class=\"code\">wg\r\nip a show wg0<\/pre>\n<h2 style=\"text-align: justify;\">\u670d\u52a1\u5668\u9632\u706b\u5899NAT\u8bbe\u7f6e<\/h2>\n<p style=\"text-align: justify;\">\u4f7f\u7528iptables\u4e3aWireGuard VPN\u5ba2\u6237\u7aef\u542f\u7528IP\u8f6c\u53d1\uff0c\u5141\u8bb8\u5ba2\u6237\u7aef\u901a\u8fc7\u96a7\u9053\u8fdb\u884cInternet \u8bbf\u95ee\u3002<\/p>\n<p style=\"text-align: justify;\">\u786e\u4fdd\u6240\u6709\u51fa\u7ad9\u7684\u6570\u636e\u5305\u90fd\u901a\u8fc7VPN\u8fdb\u884cNAT\u8f6c\u53d1\uff1a<\/p>\n<pre class=\"code\">iptables -t nat -I POSTROUTING 1 -s 10.0.0.0\/24\u00a0-o eth0\u00a0-j MASQUERADE<\/pre>\n<p style=\"text-align: justify;\">\u5141\u8bb8wg0 \u63a5\u53e3\u4e0a\u7684\u6240\u6709\u6d41\u91cf\uff1a<\/p>\n<pre class=\"code\">iptables -I INPUT 1 -i wg0 -j ACCEPT<\/pre>\n<p style=\"text-align: justify;\">\u5141\u8bb8\u6570\u636e\u5305\u901a\u8fc7WireGuard \u670d\u52a1\u5668\u8fdb\u884c\u8def\u7531:<\/p>\n<pre class=\"code\">iptables -I FORWARD 1 -i eth0\u00a0-o\u00a0wg0\u00a0-j ACCEPT \r\niptables -I FORWARD 1 -i wg0\u00a0-o\u00a0eth0\u00a0-j ACCEPT<\/pre>\n<p style=\"text-align: justify;\">\u6253\u5f00WireGuard \u6240\u4f7f\u7528\u7684UDP\u7aef\u53e351820\uff1a<\/p>\n<pre class=\"code\">iptables -I INPUT 1 -i eth0 -p udp --dport 51820 -j ACCEPT<\/pre>\n<p style=\"text-align: justify;\">\u6253\u5f00IP\u8f6c\u53d1\uff08ipv4\uff09\uff1a<\/p>\n<pre class=\"code\">sysctl -w net.ipv4.ip_forward=1<\/pre>\n<h1 style=\"text-align: justify;\">pfSense\u914d\u7f6e<\/h1>\n<p style=\"text-align: justify;\">\u4f7f\u7528\u7684\u8f6f\u4ef6\u7248\u672c\u4e3apfSense plus 22.01\u3002<\/p>\n<h2 style=\"text-align: justify;\">\u6dfb\u52a0\u96a7\u9053<\/h2>\n<p style=\"text-align: justify;\">\u8f6c\u5230VPN&gt;WireGuard\uff0c\u96a7\u9053\u9009\u9879\u5361\uff0c\u5355\u51fb\u53f3\u4e0b\u4fa7\u6dfb\u52a0\u96a7\u9053\u6309\u94ae\uff0c\u65b0\u5efa\u4e00\u4e2a\u96a7\u9053\u3002\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684\u96a7\u9053\u516c\u94a5\u5fc5\u987b\u4e0e\u670d\u52a1\u5668\u4e0a\u914d\u7f6e\u7684peer\u7684\u96a7\u9053\u516c\u94a5\u76f8\u540c\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-37-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8733\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-37-02.png\" alt=\"\" width=\"1147\" height=\"621\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-37-02.png 1147w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-37-02-300x162.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-37-02-1024x554.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-37-02-768x416.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-37-02-500x271.png 500w\" sizes=\"auto, (max-width: 1147px) 100vw, 1147px\" \/><\/a><\/p>\n<h2 style=\"text-align: justify;\">\u914d\u7f6e\u63a5\u53e3<\/h2>\n<p style=\"text-align: justify;\">\u5728\u63a5\u53e3\u914d\u7f6e\u90e8\u5206\uff0c\u4e3a\u96a7\u9053\u6dfb\u52a0\u4e00\u4e2a\u63a5\u53e3\uff0c\u5730\u5740\u4e3a\u96a7\u9053\u7aef\u70b9\u7684\u5730\u5740\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-41-41.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8734\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-41-41.png\" alt=\"\" width=\"1135\" height=\"1014\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-41-41.png 1135w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-41-41-300x268.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-41-41-1024x915.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-41-41-768x686.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-41-41-336x300.png 336w\" sizes=\"auto, (max-width: 1135px) 100vw, 1135px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u914d\u7f6e\u5b8c\u6210\u540e\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-42-57.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8735\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-42-57.png\" alt=\"\" width=\"1138\" height=\"161\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-42-57.png 1138w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-42-57-300x42.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-42-57-1024x145.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-42-57-768x109.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-42-57-500x71.png 500w\" sizes=\"auto, (max-width: 1138px) 100vw, 1138px\" \/><\/a><\/p>\n<h2 style=\"text-align: justify;\">\u6dfb\u52a0\u8fdc\u7a0b\u7aef\u70b9<\/h2>\n<p style=\"text-align: justify;\">\u5bfc\u822a\u5230VPN&gt;WireGuard\uff0c\u7aef\u70b9\u9009\u9879\u5361\uff0c\u5355\u51fb\u53f3\u4e0b\u4fa7\u7684\u6dfb\u52a0\u7aef\u70b9\u6309\u94ae\uff0c\u6dfb\u52a0\u670d\u52a1\u5668\u8fdc\u7a0b\u7aef\u70b9\u3002\u7aef\u70b9\u5730\u5740\u4e3a\u670d\u52a1\u5668\u7684\u516c\u7f51IP\u5730\u5740\uff0c\u5c06\u524d\u9762\u5728\u670d\u52a1\u5668\u4e0a\u751f\u6210\u7684\u516c\u94a5\u590d\u5236\u5230\u672c\u9875\u7684\u516c\u94a5\u680f\uff0c\u5141\u8bb8IP\u8f93\u5165 0.0.0.0\/0\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-49-32.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8736\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-49-32.png\" alt=\"\" width=\"1147\" height=\"847\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-49-32.png 1147w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-49-32-300x222.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-49-32-1024x756.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-49-32-768x567.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-49-32-406x300.png 406w\" sizes=\"auto, (max-width: 1147px) 100vw, 1147px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u914d\u7f6e\u5b8c\u6210\u540e\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-53-31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8737\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-53-31.png\" alt=\"\" width=\"1128\" height=\"156\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-53-31.png 1128w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-53-31-300x41.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-53-31-1024x142.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-53-31-768x106.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-53-31-500x69.png 500w\" sizes=\"auto, (max-width: 1128px) 100vw, 1128px\" \/><\/a><\/p>\n<h2 style=\"text-align: justify;\">\u542f\u7528\u96a7\u9053<\/h2>\n<p style=\"text-align: justify;\">\u8f6c\u5230VPN&gt;WireGuard\uff0c\u8bbe\u7f6e\u9009\u9879\u5361\uff0c\u9009\u4e2d\u542f\u7528WireGuard\u5e76\u4fdd\u5b58\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-55-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8738\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-55-02.png\" alt=\"\" width=\"1138\" height=\"573\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-55-02.png 1138w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-55-02-300x151.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-55-02-1024x516.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-55-02-768x387.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-15-55-02-500x252.png 500w\" sizes=\"auto, (max-width: 1138px) 100vw, 1138px\" \/><\/a><\/p>\n<h2 style=\"text-align: justify;\">\u6dfb\u52a0\u7f51\u5173<\/h2>\n<p style=\"text-align: justify;\">\u5728pfSense\u4e0a\u6dfb\u52a0\u8fdc\u7a0b\u7f51\u5173\uff0c\u4ee5\u4fbf\u901a\u8fc7WireGuard\u670d\u52a1\u5668\u8fdb\u884c\u7b56\u7565\u8def\u7531\u3002<\/p>\n<p style=\"text-align: justify;\">\u8f6c\u5230\u7cfb\u7edf&gt;\u8def\u7531\u7ba1\u7406\uff0c\u7f51\u5173\u72b6\u6001\u9009\u9879\u5361\uff0c\u5355\u51fb\u53f3\u4fa7\u6dfb\u52a0\u6309\u94ae\uff0c\u6dfb\u52a0\u8fdc\u7a0b\u7f51\u5173\u3002\u63a5\u53e3\u9009\u524d\u9762\u6dfb\u52a0\u7684WG\u63a5\u53e3\uff0c\u7f51\u5173IP\u5730\u5740\u586b\u5165\u8fdc\u7a0b\u670d\u52a1\u5668\u7684WG\u63a5\u53e3\u5730\u5740\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-00-25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8740\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-00-25.png\" alt=\"\" width=\"1133\" height=\"752\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-00-25.png 1133w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-00-25-300x199.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-00-25-1024x680.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-00-25-768x510.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-00-25-452x300.png 452w\" sizes=\"auto, (max-width: 1133px) 100vw, 1133px\" \/><\/a><\/p>\n<h2 style=\"text-align: justify;\">\u914d\u7f6e\u9632\u706b\u5899\u89c4\u5219<\/h2>\n<p style=\"text-align: justify;\">\u5305\u542b\u4e09\u4e2a\u65b9\u9762\uff0c\u4e00\u662f\u5141\u8bb8WG\u63a5\u53e3\u4e0e\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u7684WireGuard\u670d\u52a1\u5668\u901a\u4fe1\uff0c\u4e8c\u662f\u653e\u5f00WAN\u63a5\u53e3\u4e0a\u7684UDP 51820\u7aef\u53e3\uff0c\u4e09\u662f\u8fdb\u884c\u7b56\u7565\u5206\u6d41\u3002<\/p>\n<p style=\"text-align: justify;\">\u8f6c\u5230\u9632\u706b\u5899&gt;\u89c4\u5219\u7b56\u7565\uff0c\u5728\u65b0\u5efa\u7acb\u7684WG\u63a5\u53e3\u4e0a\uff0c\u6dfb\u52a0\u5141\u8bb8\u901a\u884c\u7684\u89c4\u5219\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002\u7b80\u5355\u5904\u7406\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2aany to any\u89c4\u5219\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-07-06.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8741\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-07-06.png\" alt=\"\" width=\"1136\" height=\"242\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-07-06.png 1136w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-07-06-300x64.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-07-06-1024x218.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-07-06-768x164.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-07-06-500x107.png 500w\" sizes=\"auto, (max-width: 1136px) 100vw, 1136px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u5728WAN\u63a5\u53e3\u4e0a\uff0c\u6dfb\u52a0\u4e00\u6761\u89c4\u5219\uff0c\u653e\u884cUDP\u7aef\u53e351820\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-09-35.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8742\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-09-35.png\" alt=\"\" width=\"1140\" height=\"254\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-09-35.png 1140w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-09-35-300x67.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-09-35-1024x228.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-09-35-768x171.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-09-35-500x111.png 500w\" sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u5185\u5916\u5730\u5740\u8bbf\u95ee\u7b56\u7565\u5206\u6d41\uff0c\u5fc5\u987b\u5efa\u7acb\u4e00\u4e2a\u56fd\u5185\u6216\u56fd\u5916IP\u5730\u5740\u7684\u522b\u540d\uff0c\u5efa\u7acb\u4e00\u79cd\u5373\u53ef\u3002\u56fd\u5185IP\u5730\u5740\u6bb5\u53ef\u4ee5\u4ece<a href=\"https:\/\/github.com\/DivineEngine\/Profiles\/tree\/master\">\u8fd9\u91cc<\/a>\u4e0b\u8f7d\u3002<\/p>\n<p style=\"text-align: justify;\">\u8f6c\u5230\u9632\u706b\u5899&gt;\u522b\u540d\u7ba1\u7406\uff0c IP\u9009\u9879\u5361\uff0c\u70b9\u51fb\u53f3\u4e0b\u7684\u5bfc\u5165\u6309\u94ae\uff0c\u5bfc\u5165\u56fd\u5185IP\u6bb5\u5e76\u4fdd\u5b58\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-15-37.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8743\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-15-37.png\" alt=\"\" width=\"1134\" height=\"523\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-15-37.png 1134w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-15-37-300x138.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-15-37-1024x472.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-15-37-768x354.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-15-37-500x231.png 500w\" sizes=\"auto, (max-width: 1134px) 100vw, 1134px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u4fdd\u5b58\u540e\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-16-20.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8744\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-16-20.png\" alt=\"\" width=\"1146\" height=\"165\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-16-20.png 1146w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-16-20-300x43.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-16-20-1024x147.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-16-20-768x111.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-16-20-500x72.png 500w\" sizes=\"auto, (max-width: 1146px) 100vw, 1146px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u8f6c\u5230\u9632\u706b\u5899&gt;\u89c4\u5219\u7b56\u7565\uff0cLAN\u9009\u9879\u5361\uff0c\u4fee\u6539\u9ed8\u8ba4\u89c4\u5219\u5e76\u6dfb\u52a0\u4e00\u6761\u7b56\u7565\u8def\u7531\u89c4\u5219\u3002\u9ed8\u8ba4\u89c4\u5219\u76ee\u6807\u4fee\u6539\u4e3a\u56fd\u5185IP\u6bb5\u522b\u540d\uff0c\u9ed8\u8ba4\u7f51\u5173\u4fee\u6539\u4e3aWAN\u7f51\u5173\uff0c\u8be5\u89c4\u5219\u5fc5\u987b\u653e\u5728\u5217\u8868\u7684\u9996\u4f4d\u3002\u6dfb\u52a0\u53e6\u4e00\u6761\u901a\u8fc7VPS\u7f51\u5173\u51fa\u7ad9\u7684\u7b56\u7565\u8def\u7531\u89c4\u5219\uff0c\u8be5\u89c4\u5219\u5fc5\u987b\u653e\u5728\u9ed8\u8ba4\u89c4\u5219\u7684\u540e\u9762\uff0c\u5426\u5219\u6240\u6709\u7684\u8bbf\u95ee\u90fd\u4f1a\u4eceVPS\u7f51\u5173\u51fa\u7ad9\u3002\u7ecf\u8fc7\u8bbe\u7f6e\u4ee5\u540e\uff0c\u8bbf\u95ee\u56fd\u5185IP\u5730\u5740\u4f1a\u8d70\u56fd\u5185\u7f51\u5173\uff0c\u8bbf\u95ee\u56fd\u5916\u5730\u5740\u8d70VPS\u7f51\u5173\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-18-43.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8745\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-18-43.png\" alt=\"\" width=\"1134\" height=\"347\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-18-43.png 1134w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-18-43-300x92.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-18-43-1024x313.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-18-43-768x235.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-18-43-500x153.png 500w\" sizes=\"auto, (max-width: 1134px) 100vw, 1134px\" \/><\/a><\/p>\n<h1 style=\"text-align: justify;\">\u6d4b\u8bd5<\/h1>\n<p style=\"text-align: justify;\">\u5b8c\u6210\u8bbe\u7f6e\u4ee5\u540e\uff0c\u5148\u68c0\u67e5\u4e24\u7aef\u96a7\u9053\u662f\u5426\u5df2\u901a\uff0c\u518d\u68c0\u67e5\u662f\u5426\u80fd\u6b63\u5e38\u4e0a\u7f51\u3002\u8bbf\u95ee\u56fd\u5916\u7684IP\u67e5\u8be2\u7f51\u7ad9\uff0c\u67e5\u770b\u51fa\u7ad9\u516c\u7f51IP\u662f\u5426\u4e3aVPS\u7684\u516c\u7f51\u5730\u5740\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-28-59.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8746\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-28-59.png\" alt=\"\" width=\"1086\" height=\"183\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-28-59.png 1086w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-28-59-300x51.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-28-59-1024x173.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-28-59-768x129.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-28-59-500x84.png 500w\" sizes=\"auto, (max-width: 1086px) 100vw, 1086px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u8bbf\u95ee\u56fd\u5185\u7684IP\u67e5\u8be2\u7f51\u7ad9\uff0c\u67e5\u770b\u516c\u7f51IP\u662f\u5426\u4e3aWAN\u63a5\u53e3\u5730\u5740\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-54-25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8747\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-54-25.png\" alt=\"\" width=\"884\" height=\"191\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-54-25.png 884w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-54-25-300x65.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-54-25-768x166.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-14-54-25-500x108.png 500w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u7ecf\u8fc7\u6d4b\u8bd5 \uff0c\u8bbf\u95ee\u56fd\u5916\u4e3b\u8981\u7f51\u7ad9\u6b63\u5e38\uff0c\u56fd\u5185\u7f51\u7ad9\u6b63\u5e38\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2022\/04\/2022-04-26-09-50-28.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8773\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2022\/04\/2022-04-26-09-50-28.png\" alt=\"\" width=\"1082\" height=\"601\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2022\/04\/2022-04-26-09-50-28.png 1082w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2022\/04\/2022-04-26-09-50-28-300x167.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2022\/04\/2022-04-26-09-50-28-1024x569.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2022\/04\/2022-04-26-09-50-28-768x427.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2022\/04\/2022-04-26-09-50-28-500x278.png 500w\" sizes=\"auto, (max-width: 1082px) 100vw, 1082px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u67e5\u770b\u9632\u706b\u5899\u5bf9\u5e94\u89c4\u5219\uff0c\u68c0\u67e5\u662f\u5426\u6709\u6d41\u91cf\u4ea7\u751f\u3002<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-28-45.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8749\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-28-45.png\" alt=\"\" width=\"1136\" height=\"83\" srcset=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-28-45.png 1136w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-28-45-300x22.png 300w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-28-45-1024x75.png 1024w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-28-45-768x56.png 768w, https:\/\/blog.pfchina.org\/wp-content\/uploads\/2021\/08\/2022-04-25-16-28-45-500x37.png 500w\" sizes=\"auto, (max-width: 1136px) 100vw, 1136px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">\u53c2\u8003\u6587\u7ae0\uff1a<\/p>\n<ol>\n<li class=\"headline\" style=\"text-align: justify;\"><a href=\"https:\/\/www.cyberciti.biz\/faq\/ubuntu-20-04-set-up-wireguard-vpn-server\/?__cf_chl_captcha_tk__=pmd_9f24cfbb1eaec4511b556c05bb295b0e80c03ed1-1628825566-0-gqNtZGzNAyKjcnBszQii#WireGuard_server_firewall_config\">Ubuntu 20.04 set up WireGuard VPN server<\/a><\/li>\n<li class=\"headline\" style=\"text-align: justify;\"><a href=\"https:\/\/www.cyberciti.biz\/faq\/how-to-set-up-wireguard-firewall-rules-in-linux\/\">How To Set Up WireGuard Firewall Rules in Linux<\/a><\/li>\n<li style=\"text-align: justify;\"><a href=\"https:\/\/blog.pfchina.org\/?p=7327\">pfSense\u3001OPNsense\u4f7f\u7528WireGuard VPN\u5efa\u7acb\u7ad9\u70b9\u5230\u7ad9\u70b9\u8fde\u63a5\u548c\u914d\u7f6e\u7b56\u7565\u8def\u7531\u793a\u4f8b<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>WireGuard\u662f\u4e00\u79cd\u6700\u65b0\u7684\u5f00\u6e90VPN\u7a0b\u5e8f\u548c\u534f\u8bae\uff0c\u5b83\u6bd4\u4f20\u7edf\u7684VPN\u66f4\u7b80\u5355\uff0c\u4f20\u8f93 &hellip; <a href=\"https:\/\/blog.pfchina.org\/?p=7540\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[101],"class_list":["post-7540","post","type-post","status-publish","format-standard","hentry","category-pfsense","tag-wireguard"],"_links":{"self":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts\/7540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7540"}],"version-history":[{"count":4,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts\/7540\/revisions"}],"predecessor-version":[{"id":13254,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts\/7540\/revisions\/13254"}],"wp:attachment":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}