位置: 编程技术 - 正文

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

  • 邮政电信业务差距大吗
  • 增值税专用发票有效期是多长时间
  • 百旺金赋的服务费必须交吗
  • 如何根据销售额降序排序
  • 物业公司收取电损费合法吗
  • 个体户购买发票需要什么资料
  • 土地投资入股是否需要发票作为企业所得税税前扣除凭证
  • 公司章程上的出资时间2050年
  • 银行卡收单机构外包业务管理指引
  • 财务人员最重要的三点
  • 税务编码如何快速查询
  • 哪些进项税不能转出
  • 供暖税收分类编码是多少
  • 商业健康保险个人所得税扣除
  • 职工向公司借款计入什么科目
  • 一般纳税人预缴税款几个点
  • 总公司签合同发票可以给子公司吗
  • 限制性股票股利会计处理
  • 预付账款后期如何冲销
  • 小型微利企业的条件
  • 补缴去年的社保怎么做账
  • 超市里销售
  • 预提保障金和交税的区别
  • 过期商品报损账务处理?
  • 外贸出口企业的租金能退税吗
  • 生产车间领用材料45000元,投入生产
  • windows11下载后怎么安装
  • 公司罚款怎么写
  • 投资公司的股东
  • 免征的增值税需要纳税调整吗
  • win11新功能
  • 个人股权分红如何缴税
  • php实现ping功能
  • 稀有品种茅膏菜
  • 股权变更怎么缴纳个人所得税
  • 大雾山国家公园总部加特林堡
  • form表单使用
  • html无刷新跳转
  • 国有划拨土地给集体企业怎么办
  • 今日冬至有什么讲究吗
  • 安卓跑ubuntu
  • 房贷计算器搜房网
  • php正则替换函数怎么写
  • vue3动态路由权限
  • 税务清单和发票清单是一样吗
  • 应付职工薪酬账户期末余额可能是
  • 金蝶k3固定资产如何入账
  • 融资租赁视同销售吗
  • 房产税的征收范围和标准有哪些
  • 水利基金可以不计提吗
  • 应收账款属于什么会计要素
  • 专票不小心印上划痕
  • 专用发票跨月退税怎么办
  • 债务抵销的条件
  • 应付票据转应付账款分录
  • 建筑行业的收入做什么科目
  • 工程款发票怎么做分录
  • 会计记账借贷记什么账户
  • 苹果手机价格
  • ubuntu 16.04.6安装教程
  • 运行linux
  • Fedora Core 8中yum设置
  • win7应用程序无法正常启动
  • win+p怎么用
  • musirc4.71.exe - musirc4是什么进程文件 有什么作用
  • unity alembic
  • dos批处理教程
  • 注释标签的内容会显示在浏览器窗口中
  • unity jsonutility
  • js实现登录界面
  • android 调用相机拍照
  • python中的open
  • 表单验证jquery
  • javascript导航栏
  • python里list
  • python import ssl
  • 不能抵扣消费税口诀
  • 买下中国需要多少钱?
  • 深圳沙井社保局在哪个位置
  • 税控盘打不开
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设