1.CentOS8.0服务端安装
yum update -y
yum install epel-release https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
yum install kmod-wireguard
yum install wireguard-tools
reboot
要开启 Linux内核的数据包转发功能可以使用如下的命令。
# sysctl -w net.ipv4.ip_forward=1
这样设置之后,当前系统就能实现包转发,但下次启动计算机时将失效。为了使在下次启动计算机时仍然有效,需要将下面的行写入配置文件/etc/sysctl.conf。
# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
# sysctl -p
用户还可以使用如下的命令查看当前系统是否支持包转发。
# sysctl net.ipv4.ip_forward
[root@VM_2_2_centos ~]# vim /etc/sysctl.conf
#配置转发,默认是0
net.ipv4.ip_forward = 1
#关闭重定向,防止恶意用户可以使用IP重定向来修改远程主机中的路由表
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
2、生成配置文件
# 创建并进入WireGuard文件夹
mkdir -p /etc/wireguard && chmod 0777 /etc/wireguard
cd /etc/wireguard
umask 0