位置: 编程技术 - 正文

在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系统 虚拟机)

  • 进项税额转出的几种情况会计分录
  • 计提印花税会计分录
  • 项目固定资产投资包括
  • 发票验旧以后还有用吗
  • 外地预缴的增值税要在本地计算附加税吗?
  • 进项税抵扣销项税怎么做账
  • 有限责任公司应当具备的条件
  • 欠缴税款会给纳税证明吗
  • 一台设备分期开票数量
  • 法院退诉讼费账务处理
  • 承包方收取分包方费用
  • 增值税普通发票跨月冲红
  • 对方跨行转账成功后我却没收到款还能追回来吗
  • 如何查询进项发票是否作废
  • 免抵退税应退税额
  • 非公司员工可以交社保吗
  • 在天猫店铺后台中的提现怎么做会计分录?
  • 购买材料物资入账需哪些原始凭证?
  • 电子税务局哪里打印发票
  • 长期股权投资稀释
  • 房屋租赁发票需要什么资料
  • 劳务工程款和工人工资的区别
  • windows版本比较
  • windows11启动卡在转圈圈
  • 企业出售自用车账务处理
  • inclooder.exe
  • php中array怎么用
  • 销售商品的会计分录已收到钱
  • findfont: Font family [‘Times New Roman‘] not found. Falling back to DejaVu Sans.
  • 财政专户资金是什么意思
  • springmvc执行流程简单
  • thinkphp批量导入数据
  • 认识数据库思维导图
  • vuex和bus
  • php授权ip访问
  • 土地测绘费计入管理费用明细科目吗
  • 归还长期借款会计分录例题
  • java transactional
  • 内账增值税计入什么科目
  • c标准库pdf下载
  • 用专项资金支付项目滞纳金合规么
  • 抵账的多余款是什么科目
  • mysql线程数配置
  • 公司代扣代缴个人所得税是怎么算的
  • 增值税普通发票查询
  • 工业企业缴纳增值税吗
  • php图片格式转换
  • 残保金申报基数
  • 广告公司收到广告收入会计分录
  • 预计产品质量保证损失计入什么费用
  • 公司给员工租的宿舍如何做分录
  • 收到银行季度结转怎么做
  • 防伪税控技术维护费
  • 投资收益下期间怎么结转
  • 期末留抵税额和上期留抵税额
  • 增值税结转是月结转还是年度
  • 创办小企业如何起步
  • mysql在查询结果中查询
  • windows已保护你的电脑,阻止你的应用
  • 黑苹果驱动说明
  • linux git教程
  • linux系统配置命令
  • 苹果电脑安装中国银行网银助手
  • windows8进入桌面
  • windows8.1默认壁纸
  • centos5.5网络配置
  • Omniserv.exe - Omniserv是什么进程 有什么用
  • win7旗舰版如何进入bios
  • cpio压缩
  • win8.1系统更新
  • JavaScript运算符中谁拥有最高优先级
  • Unity3d-四元数到矩阵的实现
  • 理解js绑定事件是什么
  • 修改update.zip
  • 哈尔滨工业大学录取分数线2023年
  • 个人工资扣税标准计算
  • 护肤品关税税率
  • 科级干部试用期一年转正流程
  • 税务稽查查哪些
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设