(二)在ubuntu20.04安装VPN服务

2 篇文章 0 订阅
2 篇文章 0 订阅

2.在PC端安装openVPN客户端。

1.下载OpenVPN 

openvpn-install-2.3.0-I005-x86_64.exe

http://swupdate.openvpn.org/community/releases/openvpn-install-2.3.0-I005-x86_64.exe

安装步骤安装:

 

安装完毕后,右键属性,选择兼容性,修改如下

点击运行会出现

但此时因为配有配置client配置文件无法连接设备。

1.配置OpenVPN 客户端

C:\Program Files\OpenVPN\config目录下copy ubuntu生产ca.crt ,yangxd.crt,yangxd.key

client.ovpn也是由ubuntu  

/usr/share/doc/openvpn/examples/sample-config-files/client.conf 更名而来的

client.ovpn的内容如下:

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun #vpn网卡

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto tcp #TCP协议

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote xxx.nangaoyun.com 17017 #域名/公网IP地址+映射端口,这个跟frp相关,这个需要提前设置frp相关配置
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nogroup

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca ca.crt   #CA证书
cert yangxd.crt  #证书
key yangxd.key #私有密钥

# Verify server certificate by checking that the
# certicate has the correct key usage set.
# This is an important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the keyUsage set to
#   digitalSignature, keyEncipherment
# and the extendedKeyUsage to
#   serverAuth
# EasyRSA can do this for you.
#remote-cert-tls server

# If a tls-auth key is used on the server
# then every client must also have the key.
#tls-auth ta.key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
# Note that 2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the ncp-cipher option in the manpage
#cipher AES-256-CBC

# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20

至此openVPN客户端就配置号了。

双击电脑连接设备vpn就可以了。但实际上可能还是不通的,因为没有公网IP地址

注:上边能够完成因为在做此至此配置了frp。

所以

三.搭建frp服务器实现ubuntu的内网IP地址和端口映射

 用来解决外网上访问remote地址如何映射到ubuntu上。

下载 https://github.com/fatedier/frp/releases frp软件

1.在公网IP地址上安装frp ,例如ubuntu等等,可以执行tar -zxvf frp.xxx.tar.gz,然后配置frps.ini PORT为指定PORT

[common]

server_addr = 127.0.0.1

server_port = 7000

在ubuntu上同样安装frpc,然后配置frpc.ini如下

[common]
server_addr = 公网域名或者IP地址
server_port = 7000
token = nangao@2021


[ssh_17007]
local_ip = 127.0.0.1
local_port = 1194  #vpn的端口
remote_port =17017

这样我们就可以在vpn的客户端使用公网IP地址+17017端口进行vpn登录了。

支持完成所有搭建,如大致原理图下:


 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值