华强北电脑城 龙岗电子世界 龙华电脑城  凯尔电脑

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2694|回复: 0

How to Install Wireguard on Ubuntu 20.04

[复制链接]
发表于 2015-4-2 13:39:43 | 显示全部楼层 |阅读模式

https://songer.pro/how-to-install-wireguard-on-ubuntu-20-04/

. P% }% I3 F/ h6 M  v

https://linuxize.com/post/how-to-set-up-wireguard-vpn-on-centos-8/   这是一个学习LINUX的好网站

% b: p. v3 E7 A7 h9 k/ k


# F  c+ g7 U' s' E

centos7下预置的yum源应用安装及更新比较慢,有时还掉链子,更换到国内的源比较省心,这里以阿里源为例。
进入到源文件目录
cd /etc/yum.repos.d
备份旧的配置文件
mv CentOS-Base.repo CentOS-Base.repo.bak
下载阿里源的文件
清理缓存
yum clean all
重新生成缓存
yum makecache


. Z6 P1 ?4 ]! w  {2 s' u! t

Update and Upgrade Ubuntusudo apt-get update && sudo apt-get upgrade -yInstall Wireguardsudo apt-get install wireguard
Open the system variables file for edit.
sudo nano /etc/sysctl.conf
Then uncomment the following line by removing the # at the beginning of the line.
net.ipv4.ip_forward=1
Apply
sudo sysctl -p
Install and Configure UFW# Install UFWsudo apt install ufw# Firewall Rulessudo ufw allow sshsudo ufw allow 51820/udp# Enable Firewallsudo ufw enable#Check UFW Statussudo ufw status
Generating private and public keys and Configure# Change Directorycd /etc/wireguard# Set Permissionsumask 077#  Generate a new key pair with the command belowwg genkey | tee privatekey | wg pubkey > publickeyGenerate server config# Create new config filesudo nano /etc/wireguard/wg0.conf[Interface]PrivateKey = <contents-of-server-privatekey>Address = 10.0.0.1/24PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEPostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADEListenPort = 51820[Peer]PublicKey = <contents-of-client-publickey>AllowedIPs = 10.0.0.2/32sudo cat /etc/wireguard/publickeysudo cat /etc/wireguard/privatekey
Start Wireguard
wg-quick up wg0
Check Wireguard Config
wg show
Enable Automatic Start
systemctl enable wg-quick@wg0
Update Server
sudo apt-get update && sudo apt-get upgrade -y
Client configuration; f0 _' _- E  f/ `2 j
Create new Config file on Client Device
sudo nano /etc/wireguard/wg0.conf
Remember to set the client private key and server public key to their corresponding places and also include your WireGuard server’s public IP address.
[Interface]Address = 10.0.0.2/32PrivateKey = <contents-of-client-privatekey>DNS = 1.1.1.1[Peer]PublicKey = <contents-of-server-publickey>Endpoint = <server-public-ip>:51820AllowedIPs = 0.0.0.0/0, ::/0Note that setting AllowedIPs to 0.0.0.0/0, ::/0 will forward all traffic over the WireGuard VPN connection.
Start the connection with the command below.
sudo wg-quick up wg0
To Disconnect
sudo wg-quick down wg0sudo systemctl stop wg-quick@wg0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|华强北 电脑城 龙岗电子世界 龙华电脑城 pc4g.com ( 粤ICP备16039863号 )

GMT+8, 2024-11-9 18:32 , Processed in 0.242679 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表