新聞中心
,sudo apt update,`,,2. 安裝WireGuard軟件包:,`,sudo apt install wireguard,`,,3. 生成WireGuard配置文件和密鑰:,`,sudo wg genkey | sudo tee /etc/wireguard/privatekey | sudo wg pubkey > /etc/wireguard/publickey,`,,4. 創(chuàng)建WireGuard配置文件:,`,sudo nano /etc/wireguard/wg0.conf,`,,5. 將以下內(nèi)容粘貼到配置文件中,然后保存并關(guān)閉文件:,`,[Interface],PrivateKey = /etc/wireguard/privatekey,Address = 10.0.0.1/24,ListenPort = 51820,,[Peer],PublicKey = /etc/wireguard/publickey,AllowedIPs = 10.0.0.2/32,Endpoint = peer.example.com:51820,PersistentKeepalive = 25,`,,6. 啟動(dòng)WireGuard服務(wù):,`,sudo systemctl enable wg-quick@wg0,sudo systemctl start wg-quick@wg0,`,,7. 確認(rèn)WireGuard服務(wù)已啟動(dòng):,`,sudo systemctl status wg-quick@wg0,“,,現(xiàn)在,WireGuard已在Ubuntu和Debian 8+上安裝并配置完成。Ubuntu和Debian8+ 上一鍵安裝并配置 WireGuard

青陽網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),青陽網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為青陽近千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營銷網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的青陽做網(wǎng)站的公司定做!
1. 安裝 WireGuard
在 Ubuntu 或 Debian 8+ 系統(tǒng)上,可以使用以下命令來安裝 WireGuard:
sudo aptget update sudo aptget install wireguard
2. 生成密鑰對(duì)
WireGuard 使用公鑰和私鑰來進(jìn)行身份驗(yàn)證和加密,你需要為你的 WireGuard 客戶端和服務(wù)器生成密鑰對(duì),可以使用以下命令生成:
wg genkey | tee privatekey | wg pubkey > publickey
這將生成一對(duì)公鑰和私鑰,并將它們分別保存在 privatekey 和 publickey 文件中。
3. 配置 WireGuard 服務(wù)器
在服務(wù)器上,需要?jiǎng)?chuàng)建一個(gè)配置文件來設(shè)置 WireGuard,可以使用以下命令創(chuàng)建一個(gè)新的配置文件:
sudo nano /etc/wireguard/wg0.conf
將以下內(nèi)容粘貼到配置文件中,替換 和 為你在第2步中生成的公鑰和私鑰:
[Interface] PrivateKey =ListenPort = 51820 Address = 10.0.0.1/24 [Peer] PublicKey = AllowedIPs = 10.0.0.2/32
保存并關(guān)閉文件,使用以下命令啟動(dòng) WireGuard 服務(wù)器:
sudo systemctl start wgquick@wg0 sudo systemctl enable wgquick@wg0
4. 配置 WireGuard 客戶端
在客戶端上,也需要?jiǎng)?chuàng)建一個(gè)配置文件來設(shè)置 WireGuard,可以使用以下命令創(chuàng)建一個(gè)新的配置文件:
nano /etc/wireguard/wg0.conf
將以下內(nèi)容粘貼到配置文件中,替換 和 為你在第2步中生成的公鑰和私鑰,以及 為你的 WireGuard 服務(wù)器的 IP 地址:
[Interface] PrivateKey =Address = 10.0.0.2/32 DNS = 8.8.8.8,8.8.4.4 [Peer] PublicKey = AllowedIPs = 0.0.0.0/0,::/0 Endpoint = :51820 PersistentKeepalive = 25
保存并關(guān)閉文件,使用以下命令啟動(dòng) WireGuard 客戶端:
sudo systemctl start wgquick@wg0
現(xiàn)在,你應(yīng)該能夠在 WireGuard 服務(wù)器和客戶端之間建立連接了。
常見問題與解答
Q1: 如何查看 WireGuard 的狀態(tài)?
A1: 可以使用以下命令查看 WireGuard 的狀態(tài):
sudo systemctl status wgquick@wg0
Q2: 如果我想更改 WireGuard 的配置,應(yīng)該怎么做?
A2: 你可以直接編輯 /etc/wireguard/wg0.conf 文件來更改 WireGuard 的配置,完成更改后,需要重新啟動(dòng) WireGuard 服務(wù)以應(yīng)用更改:
sudo systemctl restart wgquick@wg0
網(wǎng)頁題目:Ubuntu和Debian8+上一鍵安裝并配置WireGuard
轉(zhuǎn)載來于:http://m.fisionsoft.com.cn/article/dpihspo.html


咨詢
建站咨詢
