一,client-server 路由模式

使用tun,openssl,lzo压缩,启用转发,生成证书,关闭selinux
同步下时间 #1安装
yum -y install openvpn easy-rsa
#2配置文件
cp /usr/share/doc/openvpn-2.4.7/sample/sample-configfiles/server.conf /etc/openvpn
cp -r /usr/share/easy-rsa/ /etc/openvpn/
cp /usr/share/doc/easy-rsa-3.0.3/vars.example /etc/openvpn/easy-rsa/3.0.3/vars cd /etc/openvpn/easy-rsa/3.0.3/ 目录结构
├── easyrsa
├── openssl-1.0.cnf
├── vars
└── x509-types
├── ca
├── client
├── COMMON
├── san
└── server #3创建PKI和CA签发机构
在/etc/openvpn/easy-rsa/3.0.3/目录下
./easyrsa init-pki #初始化PKI,生成空目录 privata reqs
#4创建CA机构
./easyrsa build-ca nopass #有提示直接回车
ll /etc/openvpn/easy-rsa/3.0.3/pki/private/ca.key
#5创建服务端证书(私钥)
./easyrsa gen-req server nopass #生成服务端密钥及证书请求文件
ll /etc/openvpn/easy-rsa/3.0.3/pki/private/server.key
ll /etc/openvpn/easy-rsa/3.0.3/pki/reqs/server.req
#6签发服务端证书
./easyrsa sign server server
ls /etc/openvpn/easy-rsa/3.0.3/pki/issued/server.crt
#7创建Diffie-Hellman,作为“对称加密”的密钥而被双方在后续数据传输中使用。
./easyrsa gen-dh
ll /etc/openvpn/easy-rsa/3.0.3/pki/dh.pem
#8客户端证书
cp -r /usr/share/easy-rsa/ /etc/openvpn/client/easyrsa
cp /usr/share/doc/easy-rsa-3.0.3/vars.example /etc/openvpn/client/easy-rsa/vars cd /etc/openvpn/client/easy-rsa/3.0.3
./easyrsa init-pki #生成pki目录
客户端证书生成
./easyrsa gen-req zhangshijie nopass #可配置密码+密钥
req: /etc/openvpn/client/easy-rsa/3.0.3/pki/reqs/zhangshijie.req
key: /etc/openvpn/client/easy-rsa/3.0.3/pki/private/zhangshijie.key
签发客户端证书,进入主目录
cd /etc/openvpn/easy-rsa/3.0.3/
导入客户端req文件
./easyrsa import-req /etc/openvpn/client/easyrsa/3.0.3/pki/reqs/zhangshijie.req zhangshijie ./easyrsa sign client zhangshijie
生成 /etc/openvpn/easy-rsa/3.0.3/pki/issued/zhangshijie.crt #转移证书目录,服务器端证书密钥
mkdir /etc/openvpn/certs
cd /etc/openvpn/certs/ cp /etc/openvpn/easy-rsa/3.0.3/pki/dh.pem .
cp /etc/openvpn/easy-rsa/3.0.3/pki/ca.crt .
cp /etc/openvpn/easy-rsa/3.0.3/pki/issued/server.crt .
cp /etc/openvpn/easy-rsa/3.0.3/pki/private/server.key . ├── ca.crt
├── dh.pem
├── server.crt
└── server.key 客户端公钥与私钥
mkdir /etc/openvpn/client/zhangshijie/
cp /etc/openvpn/easy-rsa/3.0.3/pki/ca.crt /etc/openvpn/client/zhangshijie/
cp /etc/openvpn/easyrsa/3.0.3/pki/issued/zhangshijie.crt /etc/openvpn/client/zhangshijie/
cp /etc/openvpn/client/easyrsa/3.0.3/pki/private/zhangshijie.key /etc/openvpn/client/zhangshijie/ #server端配置文件
grep -v "#" /etc/openvpn/server.conf | grep -v "^$"
local 172.20.134.25
#本机监听IP
port 1194
proto tcp
dev tun
ca /etc/openvpn/certs/ca.crt
cert /etc/openvpn/certs/server.crt
dh /etc/openvpn/certs/dh.pem
server 192.168.36.0 255.255.255.0
#额外的网段
push "route 10.20.0.0 255.255.0.0"
#在客户端push路由
keepalive 10 120
cipher AES-256-CBC
max-clients 100
user nobody
group nobody
persist-key
persist-tun
status /var/log/openvpn/openvpn-status.log
log /var/log/openvpn/openvpn.log
log-append /var/log/openvpn/openvpn.log
verb 3
mute 20 # 启动 systemctl start openvpn@server
ss -tnl 看端口监听
systemctl stop firewalld
systemctl disable firewalld
yum install iptables-services iptables -y
systemctl enable iptables.service
systemctl start iptables.service
#清空已有规则
~]# iptables -F
~]# iptables -X
~]# iptables -Z
~]# iptables -t nat -F
~]# iptables -t nat -X
~]# iptables -t nat -Z
路由转发
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p
iptables 规则 iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -j #IP段为server 192.168.36.0 255.255.255.0 配置的ip段
iptables -A INPUT -p TCP --dport 1194 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
service iptables save
iptables -vnL
日志目录
mkdir /var/log/openvpn
chown nobody.nobody /var/log/openvpn #客户端配置文件
cd /etc/openvpn/client/zhangshijie
grep -Ev "^(#|$|;)" /usr/share/doc/openvpn-2.4.7/sample/sample-config-files/client.conf
client
dev tun
proto udp
remote my-server-1-ip 1194
#填写server-ip
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client-name.crt
key client-name.key
remote-cert-tls server
tls-auth ta.key 1
cipher AES-256-CBC
verb 3 tree /etc/openvpn/client/zhangshijie/
/etc/openvpn/client/zhangshijie/
├── ca.crt
├── client.ovpn
├── zhangshijie.crt
└── zhangshijie.key 客户端软件安装 ,使用管理员权限,安装完毕后设备管理器————查看网卡是否新添加tap适配器且驱动正常,注意版本号
将用户的公私钥配置文件复制到客户端的config目录里,启动程序测试 验证: cmd route -n
ping 内网服务器 常见错误:
#错误1:
CreateFile failed on TAP device
All TAP-Win32 adapters on this system are currently in use.
解决:
设备管理器---》属性---查看TAP device网卡驱动是否正常
卸载软件,重启机器,下载相应版本软件
https://build.openvpn.net/downloads/releases/latest/openvpn-install-latest-winxp-x86_64.exe
#错误2:
Route addition fallback to route.exe
ERROR: Windows route add command failed [adaptive]: returned error code 1
解决:
这是在Vista/Win7/Win2003Win2008等系统中没有用管理员权限安装及启动OpenVPN GUI造成的,
OpenVPN进程没有相应权限修改系统路由表。
解决方法是重新用管理员权限安装OpenVPN,并在启动OpenVPN GUI时右键选择使用管理员权限打开 某些会提示使用vista 以上版本兼容模式打开 #错误3:
There are no TAP-Win32 adapters on this system. You should be able to create a TAP-Win32 adapter by going to
Start -> All Programs -> OpenVPN -> Add a new TAP-Win32 virtual ethernet adapter.
如果是Vista/Win7/Win10,用管理员权限执行 ####
####
觉得应该在内网添加到vpn-server的路由记录,于是试了下,添加之后可以在客户端访问,重启后没有该路由还是可以,想了想内网应该不用添加路由,数据是从内网网卡出去的,出网地址也是内网。

  

open--v--pn server 桥接模式

open--v---pn server路由模式 +口令认证 +mysql

各种模式

待续。。。。。。。

centos7下open--v!(p/n)部署的更多相关文章

  1. centos7下kubernetes(3。部署kubernetes)

    环境:三个centos7 K8s2是Master;K8s1是node1:K8s3是node2 官方文档:https://kubernetes.io/docs/setup/independent/ins ...

  2. 又一篇Centos7下的asp.net core部署教程

    历程2个多月的学习,我终于从PHP转.Net开发了. 从壹开始前后端分离[ .NETCore2.1 +Vue 2 +AOP+DI]框架 感谢老张的博客,我对asp.net core入门主要就是靠他的博 ...

  3. centos7下kafka集群安装部署

    应用摘要: Apache kafka是由Apache软件基金会开发的一个开源流处理平台,由Scala和Java编写.Kafka是一种高吞吐量的 分布式发布订阅消息系统,是消息中间件的一种,用于构建实时 ...

  4. centos7下zookeeper集群安装部署

    应用场景:ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件. 它是一个为分布式应用提供一致性服务的软 ...

  5. Centos7下的zabbix安装与部署

    目录: 1.Zabbix介绍 2.LAMP/LNMP介绍 3.Zabbix安装与部署 1.Zabbix介绍 zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. ...

  6. 在centos7下获取git代码(部署代码)

    一.准备好账号 现在我们写的前端页面都放在公司自己搭建的gitlab上,使用的是 SSH KEY 访问的,所以我们先注册了一个账号 "1374669657@qq.com" . 二. ...

  7. centos7下kubernetes(5。部署kubernetes dashboard)

    基于WEB的dashboard,用户可以用kubernetes dashboard部署容器话的应用,监控应用的状态,执行故障排查任务以及管理kubernetes各种资源. 在kubernetes da ...

  8. centos7下采用Nginx+uwsgi来部署django

    之前写过采用Apache和mod_wsgi部署django,因为项目需要,并且想比较一下Nginx和Apache的性能,尝试采用Nginx+uwsgi的模式来部署django. 1.安装uwsgi以及 ...

  9. Centos7下git服务器及gogs部署

    1.安装git # yum install -y git 2.创建git用户及组 # groupadd git # adduser git -g git # mkdir /home/git # mkd ...

  10. Centos7下yum安装zabbix-server的部署(一)

    一.环境准备 OS:CentOS 7.2 64bit Zabbix版本:3.0.12 MySQL版本:5.6 hostname ip 主机用途zabbix-server 10.0.0.44 服务端 z ...

随机推荐

  1. pip install dal 失败问题

    这个问题是我在看一本<Django企业开发实战>运行其中一个项目时遇到的  作为一个自学的python 这种问题挺头疼的 这不是代码逻辑的问题 没法像Debug 一样去找问题 我们能依据的 ...

  2. Spring Boot 中使用 WebSocket 实现一对多聊天及一对一聊天

    为什么需要WebSocket? 我们已经有了http协议,为什么还需要另外一个协议?有什么好处? 比如我想得到价格变化,只能是客户端想服务端发起请求,服务器返回结果,HTTP协议做不到服务器主动向客户 ...

  3. P1141 01迷宫(连通块模板)

    题目描述 有一个仅由数字0与1组成的n×n格迷宫.若你位于一格0上,那么你可以移动到相邻4格中的某一格1上,同样若你位于一格1上,那么你可以移动到相邻4格中的某一格0上. 你的任务是:对于给定的迷宫, ...

  4. Autumn is deep, alas! I stand on the grass in the shadow of the evergreen trees.

    essence. n. 本质 flush.n. 脸红 v. 刷洗 initiate.v.开始 intrinsic.固执的 mainfest.a.显然的 intuition.n.直觉上的 refrain ...

  5. Sqoop-MySQL导入hive时id为文本解决

    错误如下 // :: ERROR tool.ImportTool: Import failed: java.io.IOException: Generating splits for a textua ...

  6. nodejs 和 js

    JavaScript组成:ECMAScript(定义这门语言的基础,比如语法.数据类型.结构以及一些内置对象等).DOM(基于ECMASCRIPT,扩展出来的用于操作页面元素的方法).BOM(基于EC ...

  7. 索引之----mysql单列索引失效的情况

    使用的索引名称: 1.隐式转换导致索引失效. 由于表字段定义为vachar类型,但在查询时把该字段作为number类型 以及where条件传给mysql. 2.对索引列进行任何操作(计算(+.-.*. ...

  8. 洛谷 P1879 玉米田Corn Fields 题解

    题面 一道思维难度不大的状态压缩,也并不卡常,但细节处理要格外注意: f[i][j]表示前i行最后一行状态是j的方案数 #include <bits/stdc++.h> #define p ...

  9. mysql之general log 日志

    开启 general log 将所有到达MySQL Server的SQL语句记录下来. 一般不会开启开功能,因为log的量会非常庞大.但个别情况下可能会临时的开一会儿general log以供排障使用 ...

  10. POJ 3249 Test for Job (拓扑排序+DP)

    POJ 3249 Test for Job (拓扑排序+DP) <题目链接> 题目大意: 给定一个有向图(图不一定连通),每个点都有点权(可能为负),让你求出从源点走向汇点的路径上的最大点 ...