![](https://img-blog.csdnimg.cn/direct/f9b99f045148451198603ba726b7ab86.png)
- [root@web1 ~]# yum -y install rpm-build
- [root@web1 ~]# rpmbuild -ba nginx.spec #会报错,没有文件或目录
- [root@web1 ~]# ls /root/rpmbuild #自动生成的目录结构
- BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
- 将源码软件复制到SOURCES目录 [root@web1 ~]# cp nginx-1.22.1.tar.gz /root/rpmbuild/SOURCES/
rpmbuild创建RPM软件包
-
- [root@web1 ~]# rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
- [root@web1 ~]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.22.1-1.x86_64.rpm
- [root@web1 ~]# yum install /root/rpmbuild/RPMS/x86_64/nginx-1.22.1-1.x86_64.rpm
- [root@web1 ~]# rpm -qa |grep nginx
- [root@web1 ~]# ls /usr/local/nginx/
![](https://img-blog.csdnimg.cn/direct/2e2c8ef8561c4a06b2c9aa4cf736a611.png)
VPN服务器 Linux客户端连接WireGuard
![](https://img-blog.csdnimg.cn/direct/7e6bf50bd81747a2aaf72026fed58b76.png)
制作密钥文件
- [root@proxy ~]#cd /usr/local/nginx/html/vpn/linux
- [root@proxy linux]# wg genkey | tee private.key | wg pubkey > public.key #生成私钥存入private.key,再利用私钥生成公钥存入public.key
- [root@proxy linux]# cp public.key ../ser.txt #拷贝一份方便客户端通过浏览器查看
- [root@proxy linux]# cat public.key UygBBCi6gEX5aJ0hMpKjBXDxltsV4+yI4NQTqK1ih1k=
- [root@proxy linux]# cat private.key
- GB2NbtPoAEvNufEggKM41GNEUBlxfJfVYn4i9yJ4WlU=
编写配置文件
![](https://img-blog.csdnimg.cn/direct/4e96f0e5e9684ca281db4ca88da78c3b.png)
- [root@proxy linux]# cd /etc/wireguard
- [root@proxy wireguard]# vim wg.conf
- [Interface] #服务端配置
- PrivateKey = GB2NbtPoAEvNufEggKM41GNEUBlxfJfVYn4i9yJ4WlU= #服务器的私钥
- Address = 10.10.10.1/8 #VPN隧道里面的IP和网段
- ListenPort = 54321 #WireGuard服务监听的端口
- [Peer] #对端(客户端)配置
- PublicKey = #客户端的公钥,稍后获取
- AllowedIPs = 10.10.10.2/32 #允许哪些客户端访问VPN服务器 ,32代表ip的二进制32位必须和10.10.10.2一样,也就是ip必须为10.10.10.2的客户才能访问
启动服务,注意,该步骤必须在上述配置文件获取客户端的公钥才可进行
- [root@proxy wireguard]# wg-quick up wg #启动VPN服务,wg是之前配置文件的名称
- [root@proxy wireguard]# ss -ntulp | grep 54321 #检查端口
- [root@proxy wireguard]# systemctl stop firewalld
- [root@proxy wireguard]# ifconfig #查看
步骤二:配置客户端
首先将$教学资料目录/vpn/linux目录拷贝到虚拟机/root下
在客户端安装VPN软件
![](https://img-blog.csdnimg.cn/direct/7fac7bfcb5a7484fa96793abbc7924f1.png)
![](https://img-blog.csdnimg.cn/direct/c27f76d74c374ea7a670068184a33d71.png)
Windows客户端连接WireGuard
![](https://img-blog.csdnimg.cn/direct/7443ed169ee945d58faad9bd9cc765e4.png)
![](https://img-blog.csdnimg.cn/direct/333c010860384bd184271c352e90d9f9.png)
![](https://img-blog.csdnimg.cn/direct/ecabd7f925de4448a781562ecbf97d09.png)
![](https://img-blog.csdnimg.cn/direct/9a2b20282ed942c9b58045b186fedef1.png)
![](https://img-blog.csdnimg.cn/direct/cb948dfff11a4b9aba65f0bd9e1a555c.png)
frp连接Linux系统实现内网穿透
![](https://img-blog.csdnimg.cn/direct/81be51cf1bae4a0597155ee9d64e4317.png)
![](https://img-blog.csdnimg.cn/direct/d4e21afabf6b4683b45c61a63762c86e.png)
![](https://img-blog.csdnimg.cn/direct/96d21f39057e471588e3d0b7125b011d.png)
![](https://img-blog.csdnimg.cn/direct/a6c778e3e5eb4aa1ba97d936dde741af.png)
- 熟悉systemctl常用命令
![](https://img-blog.csdnimg.cn/direct/8c8820e257cd4340a00fb139c605423d.png)
![](https://img-blog.csdnimg.cn/direct/d9edd3d1ab4d4726a8ed70faa6f0636f.png)
![](https://img-blog.csdnimg.cn/direct/39956aedb8194ca294c0ee8da3ed7437.png)