系统管理指南:IP 服务

使用 IPsec 保护 VPN 的示例(使用处于隧道模式的隧道)

图 20–1 IPsec 隧道示意图

图中显示了一个连接着两个 LAN 的 VPN。每个 LAN 具有四个子网。

以下示例假设这些 LAN 的所有子网都配置了隧道:


## Tunnel configuration ##
# Tunnel name is ip.tun0
# Intranet point for the source is 10.1.2.1
# Intranet point for the destination is 10.2.3.1
# Tunnel source is 192.168.1.10
# Tunnel destination is 192.168.2.10

示例 20–6 创建一个所有子网都可以使用的隧道

在此示例中,来自图 20–1 中的中心 LAN 的本地 LAN 的所有通信都可以通过隧道从路由器 1 传送到路由器 2,然后再传送到国外 LAN 的所有本地 LAN。通信使用 AES 进行加密。


## IPsec policy ##
{tunnel ip.tun0 negotiate tunnel} 
 ipsec {encr_algs aes encr_auth_algs sha1 sa shared}


示例 20–7 创建一个仅连接两个子网的隧道

在此示例中,仅为中心 LAN 的子网 10.1.2.0/24 和国外 LAN 的子网 10.2.3.0/24 之间的通信建立了隧道并对通信进行了加密。在中心 LAN 没有其他 IPsec 策略的情况下,如果中心 LAN 尝试通过此隧道路由其他 LAN 的任何通信,则通信会在路由器 1 处被丢弃。


## IPsec policy ##
{tunnel ip.tun0 negotiate tunnel laddr 10.1.2.0/24 raddr 10.2.3.0/24} 
 ipsec {encr_algs aes encr_auth_algs md5 sha1 shared}


示例 20–8 仅在两个子网之间为电子邮件通信创建隧道

在此示例中,仅为电子邮件通信创建隧道。通信从中心 LAN 的子网 10.1.2.0/24 传送到国外 LAN 的子网 10.2.3.0/24 上的电子邮件服务器。电子邮件使用 Blowfish 进行加密。这些策略可应用于远程电子邮件端口和本地电子邮件端口。rport 策略可保护从中心 LAN 发送到国外 LAN 远程电子邮件端口的电子邮件。lport 策略可以保护中心 LAN 在本地端口 25 接收到的来自国外 LAN 的电子邮件。


## IPsec policy for email from Central to Overseas ##
{tunnel ip.tun0 negotiate tunnel ulp tcp rport 25 
 laddr 10.1.2.0/24 raddr 10.2.3.0/24} 
 ipsec {encr_algs blowfish encr_auth_algs sha1 sa shared}

## IPsec policy for email from Overseas to Central ##
{tunnel ip.tun0 negotiate tunnel ulp tcp lport 25 
 laddr 10.1.2.0/24 raddr 10.2.3.0/24} 
 ipsec {encr_algs blowfish encr_auth_algs sha1 sa shared}


示例 20–9 为所有子网的 FTP 通信创建隧道

在此示例中,IPsec 策略使用 AES 保护图 20–1 中用于从中心 LAN 的所有子网向国外 LAN 的所有子网传输数据的 FTP 端口。此配置适用于 FTP 的主动模式。


## IPsec policy for outbound FTP from Central to Overseas ##
{tunnel ip.tun0 negotiate tunnel ulp tcp rport 21} 
  ipsec {encr_algs aes encr_auth_algs sha1 sa shared}
{tunnel ip.tun0 negotiate tunnel ulp tcp lport 20} 
  ipsec {encr_algs aes encr_auth_algs sha1 sa shared}

## IPsec policy for inbound FTP from Central to Overseas ##
{tunnel ip.tun0 negotiate tunnel ulp tcp lport 21} 
  ipsec {encr_algs aes encr_auth_algs sha1 sa shared}
{tunnel ip.tun0 negotiate tunnel ulp tcp rport 20} 
  ipsec {encr_algs aes encr_auth_algs sha1 sa shared}