位置: 编程技术 - 正文

在Linux系统的VPS上安装配置OpenVPN的详细教程(linux连接vps)

编辑:rootadmin

推荐整理分享在Linux系统的VPS上安装配置OpenVPN的详细教程(linux连接vps),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:vpslinux使用教程,linux vps,linux vps和windows vps,在linux系统的应急过程中,可以用,在linux系统的脚本文件一般以什么开头,在linux系统的脚本文件一般以什么开头,在linux系统的脚本文件一般以什么开头,在linux系统的目录结构中可以有几个根目录,内容如对您有帮助,希望把文章链接给更多的朋友!

OpenVPN在安全性上比PPTP,L2TP和IPsec都高,因为它通过三个证书的安全验证,实现了整个通信链路的完整加密。

安装步骤:

一、首先检查VPS上的tun设备是否可用,如果不可用需要联系客服打开,否则OpenVPN无法启用。通过root用户登陆,执行复制代码代码如下:#cat /dev/net/tuncat: /dev/net/tun: File descriptor in bad state如果现实结果如上所示,则表示tun设备可用,其它则表示设备异常,无法安装OpenVPN。

二、下载安装所需软件包:

复制代码代码如下:wget install -y openssl openssl-devel automake pkgconfig iptables

四、安装OpenVPN服务端1.安装pkcs-helper RPM包复制代码代码如下:rpm -ivh pkcs-helper-1.-2.el5.1.i.rpmrpm -ivh pkcs-helper-devel-1.-2.el5.1.i.rpm2.安装 LZO复制代码代码如下:tar zxvf lzo-2..tar.gzcd lzo-2././configure –prefix=/opt/lzomakemake checkmake installcd ../3.安装 OpenVPN复制代码代码如下:tar zxvf openvpn-2.1.4.tar.gzcd openvpn-2.1.4./configure –prefix=/opt/openvpn –with-lzo-headers=/opt/lzo/include –with-lzo-lib=/opt/lzo/lib –with-ssl-headers=/usr/include/openssl –with-ssl-lib=/usr/libmakemake install然后,下面就开始key证书文件的创建,总共需要创建三个,即ca,server key,client key。

4.生成证书Key复制代码代码如下:cp -r easy-rsa /opt/openvpn/cd /opt/openvpn/easy-rsa/2.0/vim export_new_varexport D=`pwd`export KEY_CONFIG=$D/openssl.cnfexport KEY_DIR=$D/keysexport KEY_SIZE=export KEY_COUNTRY=CN #国家export KEY_PROVINCE=BJ #省份export KEY_CITY=BJ #城市export KEY_ORG=”btschina.com” #组织export KEY_EMAIL=”root@btschina.com” #邮箱source export_new_var./clean-all

./build-ca

Generating a bit RSA private key..++++++………..++++++writing new private key to ‘ca.key’—–You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter ‘.’, the field will be left blank.—–Country Name (2 letter code) [CN]:State or Province Name (full name) [BJ]:Locality Name (eg, city) [BJ]:Organization Name (eg, company) [btschina.com]:Organizational Unit Name (eg, section) []:btschinaCommon Name (eg, your name or your server’s hostname) [btschina.com CA]:btschina.comName []:btschinaEmail Address [root@btschina.com]:

5.建立 server key复制代码代码如下:[root@centos 2.0]# ./build-key-server serverGenerating a bit RSA private key……………………….++++++……….++++++writing new private key to ‘server.key’—–You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter ‘.’, the field will be left blank.—–Country Name (2 letter code) [CN]:State or Province Name (full name) [BJ]:Locality Name (eg, city) [BJ]:Organization Name (eg, company) [btschina.com]:Organizational Unit Name (eg, section) []:btschinaCommon Name (eg, your name or your server’s hostname) [server]:btschina.comName []:btschinaEmail Address [root@btschina.com]:</p><p>Please enter the following ‘extra’ attributesto be sent with your certificate requestA challenge password []:An optional company name []:btschina.comUsing configuration from /etc/openvpn/easy-rsa/2.0/openssl.cnfCheck that the request matches the signatureSignature okThe Subject’s Distinguished Name is as followscountryName :P RINTABLE:’CN’stateOrProvinceName :P RINTABLE:’BJ’localityName :P RINTABLE:’BJ’organizationName :P RINTABLE:’btschina.com’organizationalUnitName:PRINTABLE:’btschina’commonName :P RINTABLE:’btschina.com’name :P RINTABLE:’btschina’emailAddress :IA5STRING:’root@btschina.com’Certificate is to be certified until Apr :: GMT ( days)Sign the certificate? [y/n]:y

6.生成客户端 key复制代码代码如下:[root@centos 2.0]# ./build-key client1Generating a bit RSA private key……………………………………………………………………..………++++++………………….++++++writing new private key to ‘client1.key’—–You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter ‘.’, the field will be left blank.—–Country Name (2 letter code) [CN]:State or Province Name (full name) [BJ]:Locality Name (eg, city) [BJ]:Organization Name (eg, company) [btschina.com]:Organizational Unit Name (eg, section) []:btschinaCommon Name (eg, your name or your server’s hostname) [client1]:Name []:btschinaEmail Address [root@btschina.com]:

Please enter the following ‘extra’ attributesto be sent with your certificate requestA challenge password []:An optional company name []:btschina.comUsing configuration from /etc/openvpn/easy-rsa/2.0/openssl.cnfCheck that the request matches the signatureSignature okThe Subject’s Distinguished Name is as followscountryName :P RINTABLE:’CN’stateOrProvinceName :P RINTABLE:’BJ’localityName :P RINTABLE:’BJ’organizationName :P RINTABLE:’btschina.com’organizationalUnitName:PRINTABLE:’btschina’commonName :P RINTABLE:’client1′name :P RINTABLE:’btschina’emailAddress :IA5STRING:’root@btschina.com’Certificate is to be certified until Apr :: GMT ( days)Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]yWrite out database with 1 new entriesData Base Updated

1 out of 1 certificate requests certified, commit? [y/n]yWrite out database with 1 new entriesData Base Updated

如果想生成多个client key的话,重复以上步骤,修改client1为client2,client3……即可。

至此,所有的key都已经生成完毕,如果你想删除这些key,重新生成的话,执行以下命令。复制代码代码如下:source var./clean-all

7.生成 Diffie Hellman 参数复制代码代码如下:./build-dh8.将 keys 下的所有文件打包下载到本地复制代码代码如下:tar -cf keys.tar keys9.创建服务端配置文件复制代码代码如下:vi /opt/openvpn/etc/server.conf内容如下:port proto udp

dev tun

ca /opt/openvpn/easy-rsa/2.0/keys/ca.crtcert /opt/openvpn/easy-rsa/2.0/keys/server.crtkey /opt/openvpn/easy-rsa/2.0/keys/server.keydh /opt/openvpn/easy-rsa/2.0/keys/dh.pem

在Linux系统的VPS上安装配置OpenVPN的详细教程(linux连接vps)

server ...0 ...0

client-to-clientkeepalive

comp-lzo

persist-keypersist-tunstatus /opt/openvpn/easy-rsa/2.0/keys/openvpn-status.logverb 4

push “dhcp-option DNS ...1″push “dhcp-option DNS 8.8.8.8″push “dhcp-option DNS 8.8.4.4″

.创建客户端配置文件复制代码代码如下:vi /opt/openvpn/etc/client.conf内容如下client

dev tunproto udp

remote ... #请换成自己ippersist-keypersist-tunca /opt/openvpn/easy-rsa/2.0/keys/ca.crtcert /opt/openvpn/easy-rsa/2.0/keys/client1.crtkey /opt/openvpn/easy-rsa/2.0/keys/client1.keyns-cert-type servercomp-lzoverb 3

redirect-gateway def1route-method exeroute-delay 2

.设置 OpenVPN 服务器 reboot后自动启动 openvpn复制代码代码如下:vi /etc/rc.local加入:复制代码代码如下:/opt/openvpn/sbin/openvpn –config /opt/openvpn/etc/server.conf > /dev/null 2>&1 &运行OpenVPN服务端复制代码代码如下:/opt/openvpn/sbin/openvpn –config /opt/openvpn/etc/server.conf > /dev/null 2>&1 &检查服务端是否启动执行复制代码代码如下:netstat -lnp如果看到有 0.0.0.0: 则证明服务端已经成功启动。

五、防火墙规则设置1.开放OpenVPN服务器端口复制代码代码如下:iptables -A INPUT -p udp -m state –state NEW -m udp –dport -j ACCEPT2.启用NAT映射,实现共享上网复制代码代码如下:iptables -t nat -A POSTROUTING -s ...0/...0 -o eth0 -j MASQUERADE3.开启数据转发复制代码代码如下:sysctl -w net.ipv4.ip_forward=1

六、OpenVPN GUI for Windows 客户端安装1.下载并安装 .NET Framwork 3.5 SP1由于OpenVPN客户端需要 .NET Framwork 3.5 SP1 以上的支持,所以很遗憾,我们不得不先安装它。下载地址: FilesOpenVPN TechnologiesOpenVPN Clientetcprofile创建配置文件client.ovpn,内容如下:client

dev tunproto udp

remote ... #请换成自己ip

persist-keypersist-tunca ca.crtcert client1.crtkey client1.keyns-cert-type servercomp-lzoverb 3

redirect-gateway def1route-method exeroute-delay .将所需的证书等文件放入客户端目录将之前压缩的keys.tar压缩文件解压,并将目录下的所有文件移动到目录:C:Program FilesOpenVPN TechnologiesOpenVPN Clientetcprofile

5.启动OpenVPN客户端启动OpenVPN客户端软件,点击添加连接配置,选择本地文件导入,然后导入刚刚创建的client.ovpn文件。如下图所示:

然后界面上会出现一个Client1选项,点击即可登录

登录成功

至此,整个OpenVPN的安装过程就已经完成了,如果你也是国外的VPS主机的话,那就开始体验翻过GFW的快乐吧。

七、卸载OpenVPN如果你觉得OpenVPN用起来太过于麻烦或其它原因想卸载OpenVPN,那么,请执行以下操作。复制代码代码如下:killall openvpnrpm -e pkcs-helper-1.-2.el5.1.i.rpmrpm -e pkcs-helper-devel-1.-2.el5.1.i.rpmrm -rf /opt/lzorm -rf /opt/openvpn

XEN虚拟机在Linux上的安装和使用教程 1、安装xen复制代码代码如下:yuminstallxen*kernel-xen*virt-managervnc*xen-libpython-virtinstkernel-xen:可以跑Xen的Linux核心xen:主要的xen套件,包括配置文件、启动脚本

详解Linux下iptables中的DNAT与SNAT设置 DNAT(DestinationNetworkAddressTranslation,目的地址转换)通常被叫做目的映谢。而SNAT(SourceNetworkAddressTranslation,源地址转换)通常被叫做源映谢。这是我们在设

VMware安装RedHat Linux系统时出现该光盘无法被挂载错误怎么办? 在使用VmwareWorkstation安装RedHatLinux操作系统时,由于RedHatLinux的安装程序镜像文件有3个,在安装过程中RedHatLinux会在适当的时候提醒我们插入第2张或第3张

标签: linux连接vps

本文链接地址:https://www.jiuchutong.com/biancheng/353385.html 转载请保留说明!

上一篇:连接Linux的服务器时使用SSH密钥认证及解决自动断连问题(linux服务器怎么连接wifi)

下一篇:XEN虚拟机在Linux上的安装和使用教程(linux系统 虚拟机)

  • 印花税滞纳金如何计算日期
  • 纳税义务发生时间记忆口诀
  • 退休金合并其他收入缴纳个税
  • 纳税信用等级是专管员评的吗
  • 租赁费税率3%
  • 增值税何时需要交税
  • 刷卡收手续费吗
  • 户外公司招牌
  • 处置投资性房地产的损益怎么算
  • 个税手续费返还计入哪个科目
  • 填写银行结算凭证的有关印鉴,应集中由谁保管
  • 一般纳税人增值税申报操作流程
  • 货币资金核算的调查报告
  • 小规模纳税人怎么查询
  • 交易性金融资产借贷方向
  • 12月了还没找到工作怎么办
  • 准予扣除的工会经费怎么算
  • 怎么分清楚待认识的人
  • 如何购买车辆保险
  • 计提企业所得税会计分录怎么做
  • 出口佣金可以在企业所得税前扣除吗
  • 用友t3怎么删除损益结转凭证
  • 经办人需要承担风险盘锦交通运输破坏营商环境
  • 收入低于10万免征附加税
  • 工资扣员工的罚款入什么科目
  • 解决脱发的8个方法
  • 利润分配会计处理时间
  • PHP:oci_set_client_info()的用法_Oracle函数
  • windows为什么从7开始
  • win7系统文件在哪
  • php中自定义常量的函数是
  • 建安企业开具增值税专用发票要求
  • 低代码框架开发
  • ssh怎么带密码
  • 大二期末要考试吗
  • 总包缴税
  • 企业实缴各类税金的总额
  • 利润表的格式分为哪几种
  • sqlserver2008安装步骤图文
  • 出差会计处理
  • 公司股东分红要交税吗?
  • 印花税计入会计什么科目
  • 为外单位人员报备流程
  • 购买的电子承兑公司怎么平账做收据
  • 企业每月营业额达多少需要交税
  • 进项税转出年底怎么结转
  • 境外分回的股息在本国抵免限额怎么算
  • 收银电脑怎么录商品
  • 代垫个税费怎么做账
  • 购买的银行理财产品能提前赎回吗
  • 现金折扣定价案例
  • 留存收益和未分配利润一样吗
  • 实发工资高于工资表
  • 利润表季度表怎么填
  • 建账的基本要求
  • 数据库设计三大范式
  • sql常用的语句大全
  • 所有符合条件x+5的绝对值加x- 2的绝对值等于七的数x
  • mysql 300万条数据
  • zhp.exe是什么进程
  • win7命令提示符
  • mac死机按什么都没用
  • centos6关闭图形界面
  • win7音量图标不能启用
  • os x10.10.3beta5官网下载 yosemite10.10.3beta5下载地址
  • win10系统附件游戏被删除
  • windows10专业版界面预览
  • nodejs eventloop
  • shell脚本 -ne 0
  • 用python语言编写
  • 基于JAVASCRIPT实现的可视化工具是
  • 获取路径下的文件名
  • python中循环
  • unity移动
  • listview属性设置
  • Python Sqlite3以字典形式返回查询结果的实现方法
  • 蓝牙模块手机程序
  • 浅析2种JavaScript继承方式
  • 福建电子税务局社保缴费操作
  • 出口退税函调回函时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设