×的技巧

×的技巧,第1张

OPEN***的经典使用技巧实战

OPEN×××的经典使用技巧实战

概述:

Open×××允许参与建立×××的单点使用共享密钥,电子证书,用户名/密码来进行身份验证,它大量使用了OpenSSL加密码库中的SSLv3/TLSv1协议函式库. 目前Open×××能在Solaris, Linux, OpenBSD, FreeBSD, NetBSD, Mac OS X与Windows 2000/XP/Vista上运行,并包含了许多安全性的功能, 它并不是一个基于Web的×××软件, 也不与IPsec及其它×××软件包兼容.Open×××所有的通信都能基于一个单一的IP端口, 默认且推荐使用UDP协议通讯, 同时TCP也被支持,Open×××连接能通过大多数的代理服务器,并且能够在NAT的环境中很好地工作, 服务端具有向客户端”推送”某些网络配置信息的功能,这些信息包括:IP地址, 路由设置等.Open×××提供了两种虚拟网络接口:通用Tun/Tap驱动,通过它们,可以建立三层IP隧道,或者虚拟二层以太网,后者可以传送任何类型的二层以太网络数据,

Open×××的官方端口为1194, Open×××2.0以后版本每个进程可以同时管理数个并发的隧道.Open×××使用通用网络协议(TCP UDP)的特点使它成为IPsec 等协议的理想替代,尤其是在ISPInternet service provider)过滤某些特定××× 协议的情况下。在选择协议时候,需要注意2个加密隧道之间的网络状况,如有高延迟或者丢包较多的情况下,请选择TCP协议作为底层协议,UDP协议由于

存在无连接和重传机制,导致要隧道上层的协议进行重传,效率非常低下。

Open××× 作用:

隧道就是要两台主机通信的时候就像在一个局域网内通信一样,但是为了安全可以用ssl 加密。

虚拟专用网×××:加密隧道

可以用ssl 或者ipsec 加密

1ssl 加密==> 软件open×××,支持各种 *** 作系统,简单易用工作中常用

2psec 加密==> 软件freebsd 以后将成为内核默认支持加密的概念

3PTP/L2TP ==> 主要用于windows 点对点协义// 二层隧道协议

一、实验目标

1、实战:让open*** 客户端能访问服务端局域网的其他机器并登录FTP 服务

2、实战:在windows 系统上的open*** 客户端,实现拨号上××× 服务端,实现×××

3、实战:利用open*** 解决服务器80 端口被运营商封掉问题

二、实验环境

系统版本

服务端/客户端

主机名

网卡

模式

IP地址

网关

Rhel 6.5

服务端

xuegod63

eth0:1

桥接

192.168.3.63

192.168.3.64

Rhel 6.5

服务端

xuegod63

eth0

桥接

192.168.1.63

192.168.1.1

Rhel 6.5

客户端

xuegod64

eth0

桥接

192.168.3.64

192.168.3.63

Rhel 6.5

服务端内网

xuegod62

eth0

桥接

192.168.1.62

192.168.1.1

 

三、实验步骤

1、配置服务端/客户端基础环境

1)配置服务端网络环境

[root@xuegod63 ~]#cp

[root@xuegod63 ~]# service network restart

[root@xuegod63 ~]# ifconfig

2)开启路由转发功能:

[root@xuegod63 Desktop]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

[root@xuegod63 Desktop]# sysctl -p

3)配置客户端网络环境

 

[root@xuegod64 ~]#service network restart

[root@xuegod64 ~]#ping 192.168.3.63

2、搭建×××服务端服务器

1)安装依赖环境包

[root@xuegod63 ~]# yum install -y openssl openssl-devel gcc

[root@xuegod64 ~]# yum install -y openssl openssl-devel gcc

2)配置xuegod63 为open*** 服务器:

1安装lzo 包: lzo 软件包用于压缩隧道通信数据以加快传输速度

[root@xuegod63 ~]# tar zxvf lzo-2.03.tar.gz

[root@xuegod63 ~]# cd lzo-2.03

[root@xuegod63 lzo-2.03]#./configure --prefix=/usr/ && make -j 4 && make install

2安装open*** 包:

[root@xuegod64 ~]# tar zxvf open***-2.2.2.tar.gz

[root@xuegod63 ~]# cd open***-2.2.2

[root@xuegod63 open***-2.2.2]# ./configure --with-lzo-lib=/usr/ && make && make install

3建立CA 认证中心

[root@xuegod63 ~]# cd /root/open***-2.2.2/easy-rsa/2.0/

[root@xuegod63 2.0]# vim vars #配置CA 认证中心相关的变量

改:

64 export KEY_COUNTRY="US"

65 export KEY_PROVINCE="CA"

66 export KEY_CITY="SanFrancisco"

67 export KEY_ORG="Fort-Funston" # Organization Name, 组织或公司名

68 export KEY_EMAIL="[email protected]"

为:

export KEY_COUNTRY="CN"

export KEY_PROVINCE="beijing"

export KEY_CITY="beijing"

export KEY_ORG="xuegod"

[root@xuegod63 2.0]# source vars # 加载变量

[root@xuegod63 2.0]# ./clean-all

[root@xuegod63 2.0]# ls keys/

index.txt serial

[root@xuegod63 2.0]# cat keys/serial #CA 认证签名的次数

01

[root@xuegod63 2.0]# cat keys/index.txt # 记录给哪个客户签过名。

 

4生成认证配置文件

[root@xuegod63 2.0]# cp openssl-1.0.0.cnf openssl.cnf #生成CA 认证配置文件

5)配置CA 认证中心:

[root@xuegod63 2.0]# ./build-ca # 使用build-ca ,不用使用openssl 来生成CA 相关文件

Generating a 1024 bit RSA private key

writing new private key to 'ca.key'

Country Name (2 letter code) [CN]: #回车

State or Province Name (full name) [beijing]: #回车

Locality Name (eg, city) [beijing]: #回车

Organization Name (eg, company) [xuegod]: #回车

Organizational Unit Name (eg, section) [changeme]:IT

Common Name (eg, your name or your server's hostname) [changeme]:xuegod63.cn

Name [changeme]:yu

Email Address [[email protected]]:yu@163.com

[root@xuegod63 2.0]# ls keys/ #已经配置好CA,后期需要给*** server 和*** client 分别颁发证书

ca.crt #CA 根证书    ca.key #CA的私钥key

6)为*** server (服务端)颁发证书:

[root@xuegod63 2.0]# ./build-key-server server # 这个server 是××× 服务器的commonName,或主机名

Country Name (2 letter code) [CN]:#回车

State or Province Name (full name) [beijing]:#回车

Locality Name (eg, city) [beijing]:#回车

Organization Name (eg, company) [xuegod]:#回车

Organizational Unit Name (eg, section) [changeme]:IT

Common Name (eg, your name or your server's hostname) [server]: #回车

Name [changeme]: #回车

Email Address [[email protected]]: #回车

A challenge password []: #回车

An optional company name []: #回车

Certificate is to be certified until Dec 24 14:25:37 2024 GMT (3650 days)

Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y #生成证书请求文件

Write out database with 1 new entries

Data Base Updated

查看*** server 生成的相关文件:

[root@xuegod63 2.0]# ls keys/server.*

keys/server.crt keys/server.csr keys/server.key

server.key 服务器的私钥

server.csr 服务器的证书请求文件

server.crt 服务器的证书

查看序列号和已经使用CA 颁发过证书的文件:

[root@xuegod63 2.0]# cat keys/serial

02

[root@xuegod63 2.0]# cat keys/index.txt

V    250511111216Z    01    unknown

/C=CN/ST=beijing/L=beijing/O=xuegod/OU=IT/CN=server/name=changeme/emailA

[email protected]

7*** client(客户端) 颁发证书:

[root@xuegod63 2.0]# ./build-key yonghu1

Country Name (2 letter code) [CN]:#回车

State or Province Name (full name) [beijing]:#回车

Locality Name (eg, city) [beijing]:#回车

Organization Name (eg, company) [xuegod]:#回车

Organizational Unit Name (eg, section) [changeme]:IT

Common Name (eg, your name or your server's hostname) [yong1hu]:

Name [changeme]:#回车

Email Address [[email protected]]:#回车

A challenge password []:#回车

An optional company name []:#回车

Using configuration from /root/open***-2.2.2/easy-rsa/2.0/openssl.cnf

Signature ok

Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y

查看证书的密钥:

[root@xuegod63 2.0]# ls keys/yonghu.*

keys/yonghu1.crt keys/yonghu1.csr keys/yonghu1.key

查看序列号和已经使用CA 颁发过证书的文件:

[root@xuegod63 2.0]# cat keys/serial

03

[root@xuegod63 2.0]# cat keys/index.txt

V 250511111216Z 01 unknown

/C=CN/ST=beijing/L=beijing/O=xuegod/OU=IT/CN=server/name=changeme/emailA

[email protected]

V 250511111620Z 02 unknown

/C=CN/ST=beijing/L=beijing/O=xuegod/OU=IT/CN=yonghu/name=changeme/email

[email protected]

注:CA 认证确认身份,确认身份以后,客户端和服务端需要协商出来一对对称密钥,来加密数据。

建立Diffie Hellman parameters。作用, 通信时,来协商对称密钥。

8)生成密钥对

[root@xuegod63 2.0]# ./build-dh #生成对称密钥

Generating DH parameters, 1024 bit long safe prime, generator 2

This is going to take a long time

注:产生1024 位长的DH 参数,这将花费很长的时间。

[root@xuegod63 2.0]# ls keys/dh1024.pem

keys/dh1024.pem

[root@xuegod63 2.0]# cat keys/dh1024.pem

-----BEGIN DH PARAMETERS-----

MIGHAoGBALcATDd5lbrztIM3RgcZMuRasgBB/mj6iAjshQVwUnapwPtbR7b45J1h

9QnqFxZTnqe+oseMSi63+Jjf6wOPdNxPRcurRvvI2mvC5lgN2l8VddGFeTiQSHXQ

LThk7mEje7dT4+HEQYoQRzWxDC2RIuEiJQkYoMdMys6JU5i/tmdzAgEC

-----END DH PARAMETERS-----

3、配置××× 服务端:

1生成配置文件:修改配置文件,搭建open***

[root@xuegod63 2.0]# cp /root/open***-2.2.2/sample-config-files/server.conf

/etc/server.conf

[root@xuegod63 2.0]# vim /etc/server.conf

修改的第一处

改:36 proto udp

为:36 proto tcp #即服务启动用TCP 1194 端口。

修改的第二处

指定open××× 服务器对应的证书等相关文件,将ca 那4 行内容改成如下所示的形式(记得写绝对路径):

改:

78 ca ca.crt

79 cert server.crt

80 key server.key # This file should be kept secret

87 dh dh1024.pem

为:

ca /root/open***-2.2.2/easy-rsa/2.0/keys/ca.crt

cert /root/open***-2.2.2/easy-rsa/2.0/keys/server.crt

key /root/open***-2.2.2/easy-rsa/2.0/keys/server.key

dh /root/open***-2.2.2/easy-rsa/2.0/keys/dh1024.pem

注:

ca /root/open***-2.2.2/easy-rsa/2.0/keys/ca.crt #ca 后面接的是CA 中心的根证书,它使用

的是buid-ca 生成的,用于验证客户端证书是否合法的。

cert /root/open***-2.2.2/easy-rsa/2.0/keys/server.crt # open*** 服务器的证书

key /root/open***-2.2.2/easy-rsa/2.0/keys/server.key # open*** 服务器的密钥

dh /root/open***-2.2.2/easy-rsa/2.0/keys/dh1024.pem ##在传输中,交换密钥时用到的迪菲赫

尔曼参数

修改的第三处

server 那行改为如下内容,这里做实验就直接使用原有的10.8.0.0 :

97 server 10.8.0.0 255.255.255.0 #每一个客户端连接到××× 服务器时,动态分配到的内网地址。(其

10.8.0.1 是保留××× 服务器自己用的。)

修改的第四处:*** client 登录后所有网络出口全部从server 端出

改:187 ;push "redirect-gateway def1 bypass-dhcp"

为:push "redirect-gateway def1"

修改的第五处:*** client 登录以后所有客户端能够互相访问

改:204 ;client-to-client

为:client-to-client

修改的第六处:*** client 登录后能正常上网,实现×××功能

改: 196 ;push "dhcp-option DNS 208.67.221.220"

     197 ;push "dhcp-option DNS 208.67.220.220"

为: push "dhcp-option DNS 8.8.8.8"

     push "dhcp-option DNS 8.8.4.4"

修改的第七处

#定义日志级别。级别越高,日志记录越多

改:295 verb 3

为:295 verb 4

修改的第八处

添加一条路由:在138 行,插入以下内容:

138 push "route 192.168.1.0 255.255.255.0"

 

2)启动OPEN××× SERVER 端:

[root@xuegod63 2.0]# which open***

/usr/local/sbin/open***

[root@xuegod63 2.0]#/usr/local/sbin/open*** --config /etc/server.conf

#看到以下信息,××× 启动成功

。。。

Thu May 14 19:51:57 2015 IFCONFIG POOL: base=10.8.0.4 size=62

Thu May 14 19:51:57 2015 IFCONFIG POOL LIST

Thu May 14 19:51:57 2015 MULTI: TCP INIT maxclients=1024 maxevents=1028

Thu May 14 19:51:57 2015 Initialization Sequence Completed

注:如果看到最后显示: Initialization Sequence Completed 表示启动成功

[root@xuegod63 Desktop]# netstat -antup | grep 1194

tcp 0 0 0.0.0.0:1194 0.0.0.0:* LISTEN

3376/open***

查看tun 网卡上的IP 地址:

[root@xuegod63 ~]# ifconfig

tun0 Link encap:UNSPEC HWaddr

00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255

4、搭建×××客户端服务器

1)复制软件包:

[root@xuegod63 ~]# scp lzo-2.03.tar.gz open***-2.2.2.tar.gz 192.168.3.64:/root/

2)安装lzo 库

[root@xuegod64 ~]# tar -zxvf lzo-2.03.tar.gz

[root@xuegod64 ~]# cd lzo-2.03

[root@xuegod64 lzo-2.03]# ./configure --prefix=/usr/ && make && make install

3)安装open ***

[root@xuegod64 ~]# tar zxvf open***-2.2.2.tar.gz

[root@xuegod64 ~]# cd open***-2.2.2

[root@xuegod64 open***-2.2.2]# ./configure --with-lzo-lib=/usr/ && make && make install

4)把之前签名的用户证书和密钥传给xuegod64 客户端:

[root@xuegod64 ~]# mkdir /etc/open*** #创建一个存放证书的目录

[root@xuegod63 keys]# cd /root/open***-2.2.2/easy-rsa/2.0/keys

[root@xuegod63 keys]# scp ca.crt yonghu1.crt yonghu1.key 192.168.3.64:/etc/open***/

[email protected]'s password:

ca.crt 100% 1294 1.3KB/s 00:00

yonghu.crt 100% 3866 3.8KB/s 00:00

yonghu.key 100% 916 0.9KB/s 00:00

5、配置××× 客户端:

[root@xuegod64 ~]# cp /root/open***-2.2.2/sample-config-files/client.conf

/etc/open***/

[root@xuegod64 ~]# vim /etc/open***/client.conf #修改以一下内容

改:37 proto udp

为:37 proto tcp

改:42 remote my-server-1 1194

为:42 remote 192.168.3.63 1194

改:

88 ca ca.crt

89 cert client.crt

90 key client.key

为:

ca /etc/open***/ca.crt

cert /etc/open***/yonghu1.crt

key /etc/open***/yonghu1.key

重要参数:

6)启动客户端:

[root@xuegod64 ~]# /usr/local/sbin/open***  --config /etc/open***/client.conf

。。。

Thu May 14 20:22:39 2015 TUN/TAP device tun0 opened

Thu May 14 20:22:39 2015 TUN/TAP TX queue length set to 100

Thu May 14 20:22:39 2015 /sbin/ifconfig tun0 10.8.0.6 pointopoint 10.8.0.5 mtu 1500

Thu May 14 20:22:39 2015 /sbin/route add -net 10.8.0.1 netmask 255.255.255.255 gw

10.8.0.5

Thu May 14 20:22:39 2015 Initialization Sequence Completed

6、测试

1)查看:

[root@xuegod64 ~]# ifconfig tun0

tun0 Link encap:UNSPEC HWaddr

00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

inet addr:10.8.0.6 P-t-P:10.8.0.5 Mask:255.255.255.255

UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:100

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

2)测试:通信

[root@xuegod64 ~]# ping 10.8.0.1

PING 10.8.0.1 (10.8.0.1) 56(84) bytes of data.

64 bytes from 10.8.0.1: icmp_seq=1 ttl=64 time=35.1 ms

[root@xuegod64 ~]#ping 192.168.1.63

PING 192.168.1.63 (192.168.1.63) 56(84) bytes of data.

64 bytes from 192.168.1.63: icmp_seq=1 ttl=64 time=35.1 ms

 

实战1open*** 客户端能访问服务端局域网的其他机器并登录FTP 服务

1、安装vsftpd 服务端并启动服务:

[root@xuegod62 ~]# rpm -ivh /mnt/Packages/vsftpd-2.2.2-11.el6_4.1.x86_64.rpm

[root@xuegod62 ~]# service vsftpd start

2、测试xuegod64 ping xuegod62服务器

[root@xuegod64 ~]# ping 192.168.1.62#发现ping 不通

PING 192.168.1.62 (192.168.1.62) 56(84) bytes of data.

--- 192.168.1.62 ping statistics ---

48 packets transmitted, 0 received, 100% packet loss, time 47549ms

1解决方法:配置xuegod63 ××× 服务端iptables 防火墙规则,让客户端能通过服务端上网

注:此方法在tun 路由模式中,也可以实现客户端登录后访问服务端内网的其他机器

[root@xuegod63 ~]# iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -j SNAT

--to-source 192.168.1.63

或者:

[root@xuegod63 ~]# iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERAD

再次测试xuegod64 与xuegod62 之间是否能ping 通

[root@xuegod64 ~]# ping 192.168.1.62

PING 192.168.1.62 (192.168.1.62) 56(84) bytes of data.

64 bytes from 192.168.1.62: icmp_seq=1 ttl=63 time=0.552 ms

64 bytes from 192.168.1.62: icmp_seq=2 ttl=63 time=1.44 ms

64 bytes from 192.168.1.62: icmp_seq=3 ttl=63 time=0.592 ms

3、xuegod64 的OPEN××× 客户端上测试连接xuegod62 的vsftp 服务

1)安装lftp客户端

[root@xuegod64 ~]# rpm -ivh /mnt/Packages/lftp-4.0.9-1.el6.x86_64.rpm

2)测试lftp 直接访问xuegod62 的vsftp 服务

[root@xuegod64 ~]# lftp 192.168.1.62

lftp 192.168.1.62:~> ls

drwxr-xr-x 2 0 0 4096 Feb 12 2013 pub

3)测试xuegod64 客户端上能否通过xuegod63 服务端上网

[root@xuegod64 ~]# ping g.cn

PING g.cn (203.208.52.144) 56(84) bytes of data.

64 bytes from 203.208.52.144: icmp_seq=1 ttl=55 time=20.7 ms

64 bytes from 203.208.52.144: icmp_seq=2 ttl=55 time=20.8 ms

。。。。。。。。

[root@xuegod64 ~]# ping baidu.com

PING baidu.com (220.181.57.217) 56(84) bytes of data.

64 bytes from 220.181.57.217: icmp_seq=1 ttl=54 time=22.2 ms

64 bytes from 220.181.57.217: icmp_seq=2 ttl=54 time=22.3 ms

。。。。。。。。。。

注:到此说明xuegod64 客户端能够通过xuegod63 服务端进行上网

 

实战2配置让xuegod66 上的windows 系统上用open*** 客户端连接xuegod63 服务端.xuegod63 的CA 认证中心重新颁布一个客户端的证书文件和密钥给xuegod66

1)重新生成证书

[root@xuegod63 2.0]# source vars

NOTE: If you run ./clean-all, I will be doing a rm -rf on

/root/open***-2.2.2/easy-rsa/2.0/keys

注:如不先执行此命令,直接执行./build-key yonghu2 后面会报错:

报错如下

[root@xuegod63 2.0]# ./build-key yonghu2

Please edit the vars script to reflect your configuration,

then source it with "source ./vars".

Next, to start with a fresh PKI configuration and to delete any

previous certificates and keys, run "./clean-all".

Finally, you can run this tool (pkitool) to build certificates/keys.

2)颁发证书给客户端

[root@xuegod63 2.0]# ./build-key yonghu2

Country Name (2 letter code) [CN]:#回车

State or Province Name (full name) [beijing]:#回车

Locality Name (eg, city) [beijing]:#回车

Organization Name (eg, company) [xuegod]:#回车

Organizational Unit Name (eg, section) [changeme]:IT

Common Name (eg, your name or your server's hostname) [yonghu2]:#回车

Name [changeme]:#回车

Email Address [[email protected]]:#回车

A challenge password []:#回车

An optional company name []:#回车

Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y

Write out database with 1 new entries

Data Base Updated

查看生成的文件:

[root@xuegod63 2.0]# ls keys/yonghu2.*

keys/yonghu2.crt keys/yonghu2.csr keys/yonghu2.key

3)上传客户端安装文件open***-2.1_rc15-install.exe

1windows 系统上安装open***-2.1_rc15-install.exe,直接全部下一步直至安装完成

 

 

2xueogod66 上生成客户端配置文件

xuegod63 服务端生成好的yonghu2 证书以及密钥与CA 根证书上传至到xuegod66 的open***客户端安装目录的config 目录下(即C:\Program Files\Open×××\config 目录下)

包括5 个文件:ca.crt ca.key yonghu2.crt yonghu2.csr yonghu2.key

 

3xuegod66 上复制open*** 客户端安装目录下的sample-config 目录下client.o*** 文件到config目录中

 

 

4修改xuegod66 的客户端配置文件用记事本打开client.o*** 文件

改:37 proto udp

为:37 proto tcp

改:42 remote my-server-1 1194

为:42 remote 192.168.3.63 1194

改:88 ca ca.crt

    89 cert client.crt

    90 key client.key

为:ca ca.crt

    cert yonghu2.crt

    key yonghu2.key

4启动open*** GUI 客户端双击***之后会出现一个新的×××,然后直接点击桌面上的***服务

 

 

查看xuegod66 所获取到的地址

 

测试通信:

 

 

 

实战:如何利用open*** 解决服务器80 端口被运营商封掉问题

实验概述:

假设:国内web 服务器service2 的web 端口是990 国外服务器service1 开启了80 端口.

通过架设虚拟局域网将国内web 服务器990 端口映射转发到国外服务器80 端口上达到访问国内

web 服务器上的网站且不需要输入端口访问.利用open*** 将service1 和service2 组建成一个虚拟局域网.虚拟局域网ip 需要固定.所以open*** 必须分配给service1 虚拟ip 是固定的。将service2 上的web 服务器监听分配给它的虚拟ip.同时service1 必须开启80 端口,并且开启路由

转发功能。当客户端访service1 的80 端口时。service1 就通过路由转发功能将请求包通过虚拟虚拟局域网80端口发送给service2 的web 端口990 上.service2 获取到请求后将web 数据在通过内网ip 的990 端口路由转发给service1 的80 端口上.然后提交给客户端.这样用户访问的就是国内服务器上的网站.解决了服务器无公网ip 和运营商未开启80 端口如何将网站强制通过80 端口发布出去.也同时解决了无固定公网ip的问题Service1 和service2 的请求速度取决于两者间的网络环境.建议service1 和service2 使用的是骨干节点网络.且必须是光纤。

 

1、实验环境:

xuegod63 作为香港服务器,架设open*** 服务端,其IP 地址为:192.168.1.63

xuegod64 作为本地能上网的一台内部WEB 服务器,架设open*** 客户端,IP 地址:192.168.1.64

 

3、修改配置文件

注:将之前的步骤重新做一遍,只需要修改以下部分,之前修改的内容还原。

1)生成配置文件:修改配置文件,搭建open***

[root@xuegod63 2.0]# cp /root/open***-2.2.2/sample-config-files/server.conf

修改的第四处:*** client 登录后所有网络出口全部从server 端出

改:187 ;push "redirect-gateway def1 bypass-dhcp"

为:push "redirect-gateway def1"

2)启动服务端:

[root@xuegod63 2.0]#/usr/local/sbin/open*** --config /etc/server.conf

3)安装httpd服务并且修改端口

[root@xuegod64 ~]#yum install httpd-* -y

[root@xuegod64 ~]#vim /etc/httpd/conf/httpd.conf

修改:Listen 80

为:Listen 990

[root@xuegod64 ~]#service httpd restart

4)启动客户端:

[root@xuegod64 ~]# /usr/local/sbin/open***  --config /etc/open***/client.conf

5)通过IPTABLES 防火墙来实现转发xuegod64 上的web 服务990 端口至xuegod63 的80 端口上配置iptables 的NAT 转发规则:

[root@xuegod63 keys]# iptables -t nat -A PREROUTING -d 192.168.1.63 -p tcp --dport 80 -j

DNAT --to-destination 192.168.1.64:990 #去192.168.1.64 的一条NAT 链路

[root@xuegod63 keys]# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 192.168.1.63

#返回的时候的一条路,ip 传输要有去有回才能连通

[root@xuegod63 keys]#service iptables save #保存所设置的iptables 规则

6)测试通过xuegod63 上的192.168.1.63 上的80 端口能否打开xuegod64 上990 端口的web 页面:

 


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/777635.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存