说明
所需软件及下载地址
CentOS 最稳定的linux服务器
ppptargzPPP主程序
opensslitargz生产证书的主程序
xltpdtargzFreeRadius服务器主程序
openswantargzIPSec主程序
实现过程及功能特性
我们的试验网络拓扑如下图所示
我们采用VM虚拟机试验VM中的网络设置如下
在VMware提供的Virtual Network Editor中的Host Virtual Network Mapping选项卡中把VMNet设为Not bridged点击右边的>按钮-subnetIP地址填入确定
VPNGateway虚拟机需要再添加一个网卡然后在Linux下按照下表设置各个网卡并在虚拟机设置中选择网卡对应的网络其中VPNGateway的网卡属于VMNet网卡属于VMNet网卡的默认网卡设为
另外XP本机自动位于VMNet不需要进行设置
机器名
网卡(eth)
网卡(eth)
默认网关
所属网络
角色说明
Windows
VMNet
XP Client
VPNGateway
VMNetVMNet
VPNGateway
Juniper
VMNet
私网中HTTP服务器
其中/网段模拟外网windows xp模拟外网拨号的VPN客户机
/网段模拟内网Juniper为内网中一台机器作为企业内部的HTTP服务器
架设服务器
具体过程不再赘述相关配置文件如下
OpenSWan 主要配置文件
/etc/ipsecsecrets 用来保存private RSA keys 和 preshared secrets (PSKs)
/etc/ipsecconf 配置文件(settings options defaults connections)
OpenSWan 主要配置目录
/etc/ipsecd/cacerts 存放X 认证证书(根证书-root certificates)
/etc/ipsecd/certs 存放X 客户端证书(X client Certificates)
/etc/ipsecd/private 存放X 认证私钥(X Certificate private keys)
/etc/ipsecd/crls 存放X 证书撤消列表(X Certificate Revocation Lists)
/etc/ipsecd/ocspcerts 存放X OCSP 证书(Online Certificate Status Protocol certificates)
/etc/ipsecd/passwd XAUTH 密码文件(XAUTH password file)
/etc/ipsecd/policies 存放Opportunistic Encryption 策略组(The Opportunistic Encryption policy groups)
# cat /etc/ppp/chapsecrets # Secrets for authentication using CHAP #
client server secret IP addresses
test * test *
ltptest * ltptest
ltptest * ltptest *
# cat /etc/ipsecsecrets
RSA /etc/ipsecd/private/vpngatewaykey
# %any PSK
# cat /etc/ipsecconf
#version
config setup
interfaces=%defaultroute
nat_traversal=yes
virtual_private=%v/%v/%v/%v!/
conn %default
compress=yes
authby=rsasig
leftrsasigkey=%cert
rightrsasigkey=%cert
#conn roadwarrior
#left=
#leftcert=vpngatewaycert
#leftsubnet=/
#right=%any
#auto=add
conn ltpx
pfs=no auto=add
left=
leftcert=vpngatewaycert
leftprotoport=/
right=%any
rightca=%same
rightprotoport=/%any ############################################################################# #configure preshared secret authentication
#conn ltp
# authby=secret
# pfs=no
# auto=add
# type=transport
# left=
# leftprotoport=/
# right=%any
# rightprotoport=/%any ############################################################################# #include /etc/ipsecd/examples/no_oeconf
# cat /etc/ppp/optionsxltpd
ipcpacceptlocal
ipcpacceptremote
msdns
msdns
mswins
mswins
#noccp
auth
crtscts
idle
mtu
mru
nodefaultroute
debug
lock
proxyarp
connectdelay
logfile /var/log/ltpdlog
proxyarp
# cat /etc/xltpd/xltpdconf
listenaddr =
port =
auth file = /etc/ppp/chapsecrets
debug tunnel = yes
ip range =
local ip =
require chap = yes
refuse pap = yes
require authentication = yes
name = mm;s LTP VPN Server
ppp debug = yes
pppoptfile = /etc/ppp/optionsxltpd
length bit = yes
复制证书(在机器之间复制证书请确保安全性)
#cp cacertpem /etc/ipsecd/cacerts
#cp vpngatewaycert /etc/ipsecd/certs
#cp vpngatewaykey /etc/ipsecd/private
#cp crlpem /etc/ipsecd/crls/
CA工作目录 /root/CA
# openssl req ‐x ‐days ‐newkey rsa ‐keyout cakeypem ‐out cacertpem
# mkdir newcerts
# touch indextxt
# echo > serial
# echo > crlnumber
# mkdir private
# cp cakeypem /private/
# openssl ca ‐gencrl ‐out crlpem
# openssl req ‐newkey rsa ‐keyout vpngatewaykey ‐out vpngatewayreqpem
# openssl ca ‐in /vpngatewayreqpem ‐days ‐out /vpngatewaycert ‐notext
# openssl pkcs ‐export ‐in cacertpem ‐inkey cakeypem ‐out demoCAp
下面产生windows的私钥及证书
# openssl req ‐newkey rsa ‐keyout windowskey ‐out windowsreqpem
# openssl ca ‐in /windowsreqpem ‐days ‐out /windowscert ‐notext
# openssl pkcs ‐export ‐in windowscert ‐inkey windowskey ‐out windowsp
注意在导出P文件时输入读取CA密钥的密码然后再指定导出p文件中的证书需要
的密码并进行二次确认
用户名ltptest密码ltptest进行拨号
可以看到获得的IP 是/etc/ppp/chap‐secrets 文件中指定的那个IP
src=http://imgeducitycn/img_///jpg border=>
src=http://imgeducitycn/img_///jpg border=>
用户名ltptest密码ltptest进行拨号
可以看到获得的IP 是从地址池中获得的
src=http://imgeducitycn/img_///jpg border=>
src=http://imgeducitycn/img_///jpg border=>
一个完整的拨号连接信息如下
xltpd build_fdset closing down tunnel
xltpd get_call allocating new tunnel for host port
xltpd get_call allocating new tunnel for host port
xltpd control_finish Peer requested tunnel twice ignoring second one
xltpd build_fdset closing down tunnel
xltpd Connection established to Local Remote (ref=/)
LNS session is ;default;
xltpd start_pppd I;m running
xltpd /usr/sbin/pppd
xltpd passive
xltpd ‐detach
xltpd
xltpd refuse‐pap
xltpd auth
xltpd require‐chap
xltpd name
xltpd mm;s LTP VPN Server
xltpd debug
xltpd file
xltpd /etc/ppp/optionsxltpd
xltpd /dev/pts/
xltpd Call established with Local Remote Serial
xltpd network_thread select timeout
xltpd network_thread select timeout
xltpd child_handler pppd exited for call with code
xltpd call_close Call to disconnected
xltpd control_finish Connection closed to port () Local
Remote
xltpd build_fdset closing down tunnel
xltpd Trustingly terminating pppd sending TERM signal to pid
xltpd pppd successfully terminated
关于LTP IPSec VPN 服务器的架设暂且学习到这里其中还有很多细节需要学习和熟悉有待进一步的研究