设置完成后,复制ipsec.donf和ipsec.secrets文件到其他需要使用此安全模式的机器中。剩下的工作就是修改防火墙规则,使其只将数据包转发,而不将其伪装(masquerade)。在服务器1.2.3.4上增加以下规则:
-A forward -p all -j ACCEPT -s 10.0.0.0/24 -d 192.168.0.0/24
-A forward -p all -j ACCEPT -s 192.168.0.0/24 -d 10.0.0.0/24
记住,要确保这些规则在伪装(masquerade)规则之前,如以下所示:
#
# FORWARD RULES
#
ipchains -P forward DENY
#
-A forward -p all -j ACCEPT -s 10.0.0.0/24 -d 192.168.0.0/24
-A forward -p all -j ACCEPT -s 192.168.0.0/24 -d 10.0.0.0/24
-A forward -p all -j MASQ -s 10.0.0.0/24 -d 0.0.0.0/0
在服务器5.6.7.8上重复类似工作:
-A forward -p all -j ACCEPT -s 192.168.0.0/24 -d 10.0.0.0/24
-A forward -p all -j ACCEPT -s 10.0.0.0/24 -d 192.168.0.0/24
记住,要确保这些规则在伪装(masquerade)规则之前,如以下所示:
#
# FORWARD RULES
#
-P forward DENY
#
-A forward -p all -j ACCEPT -s 192.168.0.0/24 -d 10.0.0.0/24
-A forward -p all -j ACCEPT -s 10.0.0.0/24 -d 192.168.0.0/24
-A forward -p all -j MASQ -s 192.168.0.0/24 -d 0.0.0.0/0
现在我们可以利用这个手工构造的ipsec通道,建立网络A与网络B之间的通信。
ipsec manual ——up my-tunnel
从客户机10.0.0.2上ping 192.168.0.2,如果ping得通则说明设置正确。否则请检查网络,确保1.2.3.4与5.6.7.8之间可以通信,允许TCP-IP转发,和两个网络间的防火墙没有规则禁止数据包通过或伪装数据包。当成功完成了手工(固定)密钥连接后,便应当开始配置自动密钥 (automative keying)。
自动密钥连接 (Automatic connection keying)
对于一个商业应用来说,使用手工(固定)密钥是不安全和不可靠的。在自动密钥连接模式下产生一个256位共享密钥,将其复制到连接通道的各个节点上后,那些企图截取数据包的网络攻击者将很难攻破这种安全连接。在自动密钥连接模式下,一个密钥的有效期是8个小时,这种配置有效地阻止了那些企图用暴力法猜出密钥的攻击者。下面我们在前一个例子的基础上建立自动密钥连接配置:
ipsec.conf文件中编辑通道配置,如下例:
conn my-tunnel
type=tunnel
left=1.2.3.4
leftnexthop=1.2.3.1
leftsubnet=10.0.0.0/24
right=5.6.7.8
rightnexthop=5.6.7.1
rightsubnet=192.168.0.0/24
keyexchange=ike
keylife=8h
keyingtries=0
然后启动pluto守护进程。在通道的另一端连接pluto守护进程以建立一个连接。需要提醒的是,因为pluto守护进程运行在端口500/UDP,你需要在防火墙开一个"洞"使数据包能够顺利通过:
-A input -p udp -j ACCEPT -s 0.0.0.0/0 -i eth0 -d 0.0.0.0/0 500
使用"%search"关键字比列出要建立的通道清单更方便。方法如下:在每一个通道配置中增加一行:
auto=start
编辑ipsec.secrets文件:
plutoload=%search
plutostart=%search
如果一切正常,/var/log/messages中将有类似如下记录:
Oct 16 02:10:41 server ipsec_setup: Starting FreeS/WAN IPSEC……
Oct 16 02:10:41 server ipsec_setup: /usr/local/lib/ipsec/spi: message size is 28.
Oct 16 02:10:41 server ipsec_setup: KLIPS debug `none''
Oct 16 02:10:41 server ipsec_setup: KLIPS ipsec0 on eth0 1.2.3.4/255.255.255.0 broadcast
而在/var/log/secure文件中将有类似如下记录:
Oct 16 02:10:42 server Pluto[25157]: Starting Pluto (FreeS/WAN Version snap1999Jun14b)
Oct 16 02:10:44 server Pluto[25157]: added connection description "my-tunnel"
Oct 16 02:10:44 server Pluto[25157]: listening for IKE messages
Oct 16 02:10:44 server Pluto[25157]: adding interface ipsec0/eth0 1.2.3.4Jun 26 02:10:44 server
用命令ipsec look查看信息:
Destination GateWay Genmask Flags Mss Window irtt Iface
0.0.0.0 192.168.0.0 0.0.0.0 US 40 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 40 0 0 ipsec0
11.2.3.0 0.0.0.0 255.255.255.0 U 40 0 0 lo
在/proc/net/route查看路由表时:
Destination Gateway Genmask Flags Metric Ref Use Iface
1.2.3.4 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
11.2.3.0 0.0.0.0 255.255.255.0 U 0 0 0 lo
1.2.3.0 0.0.0.0 255.255.255.0 U 0 0 0 ipsec0
192.168.0.0 1.2.3.1 255.255.255.0 UG 0 0 0 ipsec0
更多请看Cisco与华为技术网(Vlan9.com)局域网安全管理、Sniffer安全技术专题、SSH安全技术专题,或进入论坛讨论。- (11112篇文章)局域网安全管理
- (297篇文章)Sniffer安全技术专题
- (9584篇文章)SSH安全技术
- (14715篇文章)路由安全配置
- 04-23感受真实的虚拟机—Virtual Server王者归来
- 04-23认识各大网络银行及实战使用
- 04-23微软即将发布新一代iSCSI initiator
- 04-23入门基础-VC网络编程入门
- 03-13小窍门:简单个性化我的电脑
- 03-13如何让电脑硬盘运行更快
- 03-13诺基亚将猛攻研发 称未来手机终将取代电脑
- 03-13给别人电脑永远设置个别人删不掉的管理员用户
- 03-13帝国时代3-普鲁士快攻电脑小心得 aoe
- 03-13“守财奴”如何升级电脑?
