配置虚拟隧道接口建立IPSec隧道示例
组网需求
如图5-53所示,RouterA为企业分支网关,RouterB为企业总部网关,分支与总部通过公网建立通信。分支子网为10.1.1.0/24,总部子网为10.1.2.0/24。
企业希望对分支子网与总部子网之间相互访问的流量进行安全保护。分支与总部通过公网建立通信,可以在分支网关与总部网关之间建立一个IPSec隧道来实施安全保护。由于分支子网较为庞大,有大量需要IPSec保护的数据流,可基于虚拟隧道接口方式建立IPSec隧道,对Tunnel接口下的流量进行保护,不需使用ACL定义待保护的流量特征。
配置思路
采用如下思路配置虚拟隧道接口方式建立IPSec隧道:
配置接口的IP地址和到对端的静态路由,保证两端路由可达。
配置IPSec安全提议,定义IPSec的保护方法。
配置IKE对等体,定义对等体间IKE协商时的属性。
配置安全框架,并引用安全提议和IKE对等体,确定对何种数据流采取何种保护方法。
在Tunnel接口上应用安全框架,使接口具有IPSec的保护功能。
配置Tunnel接口的转发路由,将需要IPSec保护的数据流引到Tunnel接口。
操作步骤
- 分别在RouterA和RouterB上配置接口的IP地址和到对端的静态路由
# 在RouterA上配置接口的IP地址。
<Huawei> system-view [Huawei] sysname RouterA [RouterA] interface gigabitethernet 1/0/0 [RouterA-GigabitEthernet1/0/0] ip address 1.1.1.1 255.255.255.0 [RouterA-GigabitEthernet1/0/0] quit [RouterA] interface gigabitethernet 2/0/0 [RouterA-GigabitEthernet2/0/0] ip address 10.1.1.1 255.255.255.0 [RouterA-GigabitEthernet2/0/0] quit
# 在RouterA上配置到对端的静态路由,此处假设到对端的下一跳地址为1.1.1.12。
[RouterA] ip route-static 2.1.1.0 255.255.255.0 1.1.1.12
# 在RouterB上配置接口的IP地址。
<Huawei> system-view [Huawei] sysname RouterB [RouterB] interface gigabitethernet 1/0/0 [RouterB-GigabitEthernet1/0/0] ip address 2.1.1.1 255.255.255.0 [RouterB-GigabitEthernet1/0/0] quit [RouterB] interface gigabitethernet 2/0/0 [RouterB-GigabitEthernet2/0/0] ip address 10.1.2.1 255.255.255.0 [RouterB-GigabitEthernet2/0/0] quit
# 在RouterB上配置到对端的静态路由,此处假设到对端下一跳地址为2.1.1.2。
[RouterB] ip route-static 1.1.1.0 255.255.255.0 2.1.1.2
- 分别在RouterA和RouterB上创建IPSec安全提议
# 在RouterA上配置IPSec安全提议。
[RouterA] ipsec proposal tran1 [RouterA-ipsec-proposal-tran1] esp authentication-algorithm sha2-256 [RouterA-ipsec-proposal-tran1] esp encryption-algorithm aes-128 [RouterA-ipsec-proposal-tran1] quit
# 在RouterB上配置IPSec安全提议。
[RouterB] ipsec proposal tran1 [RouterB-ipsec-proposal-tran1] esp authentication-algorithm sha2-256 [RouterB-ipsec-proposal-tran1] esp encryption-algorithm aes-128 [RouterB-ipsec-proposal-tran1] quit
此时分别在RouterA和RouterB上执行display ipsec proposal会显示所配置的信息。
- 分别在RouterA和RouterB上配置IKE对等体# 在RouterA上配置IKE安全提议。
[RouterA] ike proposal 5 [RouterA-ike-proposal-5] authentication-algorithm sha2-256 [RouterA-ike-proposal-5] encryption-algorithm aes-128 [RouterA-ike-proposal-5] dh group14 [RouterA-ike-proposal-5] quit
# 在RouterA上配置IKE对等体。
[RouterA] ike peer spub [RouterA-ike-peer-spub] version 1 [RouterA-ike-peer-spub] undo version 2 [RouterA-ike-peer-spub] ike-proposal 5 [RouterA-ike-peer-spub] pre-shared-key cipher Example@123 [RouterA-ike-peer-spub] quit
# 在RouterB上配置IKE安全提议。
[RouterB] ike proposal 5 [RouterB-ike-proposal-5] authentication-algorithm sha2-256 [RouterB-ike-proposal-5] encryption-algorithm aes-128 [RouterB-ike-proposal-5] dh group14 [RouterB-ike-proposal-5] quit
# 在RouterB上配置IKE对等体。
[RouterB] ike peer spua [RouterB-ike-peer-spua] version 1 [RouterB-ike-peer-spua] undo version 2 [RouterB-ike-peer-spua] ike-proposal 5 [RouterB-ike-peer-spua] pre-shared-key cipher Example@123 [RouterB-ike-peer-spua] quit
- 分别在RouterA和RouterB上创建安全框架
# 在RouterA上配置安全框架。
[RouterA] ipsec profile profile1 [RouterA-ipsec-profile-profile1] proposal tran1 [RouterA-ipsec-profile-profile1] ike-peer spub [RouterA-ipsec-profile-profile1] quit
# 在RouterB上配置安全框架。
[RouterB] ipsec profile profile1 [RouterB-ipsec-profile-profile1] proposal tran1 [RouterB-ipsec-profile-profile1] ike-peer spua [RouterB-ipsec-profile-profile1] quit
- 分别在RouterA和RouterB的接口上应用各自的安全框架
# 在RouterA的接口上引用安全框架。
[RouterA] interface tunnel 0/0/0 [RouterA-Tunnel0/0/0] ip address 192.168.1.1 255.255.255.0 [RouterA-Tunnel0/0/0] tunnel-protocol ipsec [RouterA-Tunnel0/0/0] source 1.1.1.1 [RouterA-Tunnel0/0/0] destination 2.1.1.1 [RouterA-Tunnel0/0/0] ipsec profile profile1 [RouterA-Tunnel0/0/0] quit
# 在RouterB的接口上引用安全框架。
[RouterB] interface tunnel 0/0/0 [RouterB-Tunnel0/0/0] ip address 192.168.1.2 255.255.255.0 [RouterB-Tunnel0/0/0] tunnel-protocol ipsec [RouterB-Tunnel0/0/0] source 2.1.1.1 [RouterB-Tunnel0/0/0] destination 1.1.1.1 [RouterB-Tunnel0/0/0] ipsec profile profile1 [RouterB-Tunnel0/0/0] quit
# 此时在RouterA和RouterB上执行display ipsec profile会显示所配置的信息。
- 配置Tunnel接口的转发路由,将需要IPSec保护的数据流引到Tunnel接口。
# 在RouterA上配置Tunnel接口的转发路由。
[RouterA] ip route-static 10.1.2.0 255.255.255.0 tunnel 0/0/0
# 在RouterB上配置Tunnel接口的转发路由。
[RouterB] ip route-static 10.1.1.0 255.255.255.0 tunnel 0/0/0
- 检查配置结果
# 配置成功后,分别在RouterA和RouterB上执行display ike sa会显示所配置的信息,以RouterA为例。
[RouterA] display ike sa IKE SA information : Conn-ID Peer VPN Flag(s) Phase RemoteType RemoteID -------------------------------------------------------------------------------- 16 2.1.1.1:500 RD|ST v1:2 IP 2.1.1.1 14 2.1.1.1:500 RD|ST v1:1 IP 2.1.1.1 Number of IKE SA : 2 -------------------------------------------------------------------------------- RD--READY ST--STAYALIVE RL--REPLACED FD--FADING TO--TIMEOUT HRT--HEARTBEAT LKG--LAST KNOWN GOOD SEQ NO. BCK--BACKED UP M--ACTIVE S--STANDBY A--ALONE NEG--NEGOTIATING
配置文件
RouterA的配置文件
# sysname RouterA # ipsec proposal tran1 esp authentication-algorithm sha2-256 esp encryption-algorithm aes-128 # ike proposal 5 encryption-algorithm aes-128 dh group14 authentication-algorithm sha2-256 authentication-method pre-share integrity-algorithm hmac-sha2-256 prf hmac-sha2-256 # ike peer spub version 1 pre-shared-key cipher %^%#JvZxR2g8c;a9~FPN~n'$7`DEV&=G(=Et02P/%\*!%^%# ike-proposal 5 # ipsec profile profile1 ike-peer spub proposal tran1 # interface Tunnel0/0/0 ip address 192.168.1.1 255.255.255.0 tunnel-protocol ipsec source 1.1.1.1 destination 2.1.1.1 ipsec profile profile1 # interface GigabitEthernet1/0/0 ip address 1.1.1.1 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 10.1.1.1 255.255.255.0 # ip route-static 2.1.1.0 255.255.255.0 1.1.1.12 ip route-static 10.1.2.0 255.255.255.0 tunnel0/0/0 # return
RouterB的配置文件
# sysname RouterB # ipsec proposal tran1 esp authentication-algorithm sha2-256 esp encryption-algorithm aes-128 # ike proposal 5 encryption-algorithm aes-128 dh group14 authentication-algorithm sha2-256 authentication-method pre-share integrity-algorithm hmac-sha2-256 prf hmac-sha2-256 # ike peer spua version 1 pre-shared-key cipher %^%#K{JG:rWVHPMnf;5\|,GW(Luq'qi8BT4nOj%5W5=)%^%# ike-proposal 5 # ipsec profile profile1 ike-peer spua proposal tran1 # interface Tunnel0/0/0 ip address 192.168.1.2 255.255.255.0 tunnel-protocol ipsec source 2.1.1.1 destination 1.1.1.1 ipsec profile profile1 # interface GigabitEthernet1/0/0 ip address 2.1.1.1 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 10.1.2.1 255.255.255.0 # ip route-static 1.1.1.0 255.255.255.0 2.1.1.2 ip route-static 10.1.1.0 255.255.255.0 tunnel0/0/0 # return