一、 二、 三、 四、
系统安装...........................................................................................................2 网络架构...........................................................................................................2 认证方式...........................................................................................................2 配置文件...........................................................................................................3 1. ipsec.conf文件...........................................................................................3 2. ipsec.secrets文件.......................................................................................5
五、 六、
日常管理...........................................................................................................6 其它注意事项...................................................................................................6
一、 系统安装
可以使用redhat 9.0或fc4安装配置FreeSWAN,一般可直接使用ipcop(1.4.0最稳定)
二、 网络架构
Ipsec可以有如下形式:
1. Gateway-Gateway 连接方式 2. Net-Gate 连接方式 3. Net-Net 连接方式 4. 混合模式连接方式
我们一般是使用net-net这种形式(采用其它形式的一般是为了实验)
三、 认证方式
1. 共享密钥:简单实用 2. 数字证书:安全
附:证书创建过程 1.
把openssl.exe、cygwin1.dll、openssl.cnf放置于同一个目录中
2. md rootCA 3. 4. 5.
echo 01 > rootCA/serial type nul > rootCA/index.txt
创建自我签名的根证书:openssl req -config openssl.cnf -new -x509 -keyout rootCA/ca.key
–out rootCA/ca.pem -days DAYS_VALID –nodes 6. 7. 8.
申请客户端证书:openssl req -config openssl.cnf -new -keyout jiang.key -out jiang.req 使用CA签名证书:openssl ca -config openssl.cnf -out jiang.pem -notext -infiles jiang.req 查看subject:
subject:openssl x509 –in xxxx.pem –noout –subject
9. 注意常用命令:
创造吊销列表: openssl ca –config openssl.cnf -gencrl -out crl.pem 撤消证书: openssl ca –config openssl.cnf -revoke test.pem
更新吊销列表: openssl ca –config openssl.cnf -gencrl -crldays xx -out crl.pem 查看吊销列表: openssl crl -in crl.pem -noout -text
转为x509格式:openssl x509 -in demoCA/cacert.pem -outform der -out rootca.der 导出证书:
openssl pkcs12 -export -in xxx.com.pem -inkey xxx.com.key -certfile emoCA/cacert.pem –out xxx.com.p12
从p12格式中导出CA证书, 则输入下列命令:
openssl pkcs12 -nomacver -cacerts -nokeys -in pkcs12_file -out ca_certificate.pem 从p12格式中导出xxx.com.pem和xxx.com.key 则输入下列命令:
openssl pkcs12 -nomacver -clcerts -nokeys -in pkcs12_file -out xxx.certificate.pem openssl pkcs12 -nomacver -nocerts -in pkcs12_file -out xxx.private_key.pem
四、 配置文件
1. ipsec.conf文件
config setup
interfaces=%defaultroute klipsdebug=none plutodebug=none plutoload=%search plutostart=%search uniqueids=yes
nat_traversal=yes 支持NAT
virtual_private=%v4:10.0.0.0/8,%v4:172.16.0.0/12,%v4:192.168.0.0/16,%v4:!192.168.2.0/255.255.255.0,%v4:!10.2.2.0/255.2
55.255.0,%v4:!192.168.3.0/24,%v4:!192.168.4.0/24,%v4:!172.16.1.0/24,%v4:129.0.0.0/24
conn %default
keyingtries=0
disablearrivalcheck=no
conn xxxx2_3
x_conn_match=xxxx
leftsubnet=192.168.2.0/24 rightsubnet=192.168.3.0/24 also=xxxx auto=start
conn xxxx30_3
x_conn_match=xxxx
leftsubnet=192.168.30.0/24 rightsubnet=192.168.3.0/24 also=xxxx auto=start
conn xxxx31_3
x_conn_match=xxxx
leftsubnet=192.168.31.0/24 rightsubnet=192.168.3.0/24 also=xxxx auto=start
conn xxxx2_13
x_conn_match=xxxx
leftsubnet=192.168.2.0/24 rightsubnet=192.168.13.0/24 also=xxxx auto=start
conn xxxx2_172_16_4
x_conn_match=xxxx
leftsubnet=192.168.2.0/24 rightsubnet=172.16.4.0/24 also=xxxx auto=start
conn xxxx2_172_16_2
x_conn_match=xxxx
leftsubnet=192.168.2.0/24 rightsubnet=172.16.2.0/24 also=xxxx auto=start
conn xxxx2_129
x_conn_match=xxxx
leftsubnet=192.168.2.0/24 rightsubnet=129.0.0.0/24 also=xxxx auto=start
conn xxxx
left=210.75.1.173
leftnexthop=%defaultroute
leftcert=/var/ipcop/certs/hostcert.pem right=205.33.68.09
rightnexthop=%defaultroute
rightcert=/var/ipcop/certs/xxxxcert.pem dpddelay=30 dpdtimeout=120 dpdaction=hold
authby=rsasig #是采用证书认证
conn xxxxoffice
left=202.86.33.23
leftnexthop=%defaultroute
leftsubnet=192.168.2.0/255.255.255.0 right=xxxxoffice.vnet.org rightsubnet=172.16.1.0/24 rightnexthop=%defaultroute dpddelay=30 dpdtimeout=120 dpdaction=hold authby=secret #采用共享密钥 auto=start
2. ipsec.secrets文件
: RSA /var/ipcop/certs/hostkey.pem
202.86.33.23 xxxxoffice.vnet.org : PSK \"790**^*^rfdkjdfjdffdfdfd\" ………………………………………………
……………………………………..(略)
五、 日常管理
查看状态:ipsec whack –status 查看通道情况:ipsec look
重新启动ipsec服务:ipsec setup restart或/xxx/ipsec –restart 启动单个通道:
ipsec auto –add xxxx ipsec auto –route xxxx ipsec auto --rereadall
ipsec auto --asynchronous –up 半闭单个通道:
ipsec auto –down xxxx ipsec auto –delete xxxx
六、 其它注意事项
xxxx
因篇幅问题不能全部显示,请点此查看更多更全内容