IPsec+预共享密钥的IKE野蛮模式

该配置教程详细介绍了如何在两台路由器RTA和RTB上设置IPsec+预共享密钥的IKE野蛮模式,包括配置接口IP地址、默认路由、DHCPServer、IKE提案、身份信息、密钥链、IKEprofile、安全ACL、IPsec安全提议和策略,以及最后的隧道工作状况检验。整个过程确保了两端设备间的安全通信通道建立。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目标

  • 配置 IPsec+预共享密钥的IKE 野蛮模式

步骤一、配置各接口IP地址

步骤二、配置默认路由

[RTB]ip route-static 0.0.0.0 0 2.2.2.2

步骤三:配置公网连接

在 SWA 上配置 DHCP Server。设置 RTA 从 SWA 动态获得 IP 地址和默认路由。

[SWA]dhcp enable

[SWA]dhcp server ip-pool 1

[SWA-dhcp-pool-1]network 1.1.1.0 mask 255.255.255.0

[SWA-dhcp-pool-1]gateway-list 1.1.1.2

[SWA-dhcp-pool-1]quit

[RTA]interface GigabitEthernet0/0

[RTA-GigabitEthernet0/1] ip address dhcp-alloc

步骤四:配置 IKE proposal

[RTA]ike proposal 1

//配置IKE安全提议

[RTA-ike-proposal-1]authentication-method pre-share

//配置IKE安全提议的认证方式

[RTA-ike-proposal-1]authentication-algorithm md5

//配置IKE的认证算法建议

[RTA-ike-proposal-1]encryption-algorithm 3des-cbc

//配置IKE安全提议的加密算法

[RTA-ike-proposal-1]quit

[RTB]ike proposal 1

//配置IKE安全提议

[RTB-ike-proposal-1]authentication-method pre-share

//配置IKE安全提议的认证方式

[RTB-ike-proposal-1]authentication-algorithm md5

//配置IKE的认证算法建议

[RTB-ike-proposal-1]encryption-algorithm 3des-cbc

//配置IKE安全提议的加密算法

[RTB-ike-proposal-1]quit

步骤五:配置 IKE 身份信息

[RTA]ike identity fqdn rta

//使用FQDN作为标识

[RTB]ike identity fqdn rtb

//使用FQDN作为标识

步骤六:配置 IKE keychain

[RTA]ike keychain keychain1

[RTA-ike-keychain-keychain1]pre-shared-key address 2.2.2.1 255.255.255.0 keysimple h3c

//配置与对等体使用的预共享密钥

[RTA-ike-keychain-keychain1]quit

[RTB]ike keychain keychain1

[RTB-ike-keychain-keychain1]pre-shared-key hostname rta 255.255.255.0 key simple h3c

//通过主机名指定对等体

[RTB-ike-keychain-keychain1]quit

步骤七:配置 IKE profile

配置 IKE profile,并设置 IKE 第一阶段协商模式为野蛮模式:

[RTA]ike profile profile1

//创建安全提议,并进入提议试图

[RTA-ike-profile-profile1]exchange-mode aggressive

//修改协商模式为野蛮模式

[RTA-ike-profile-profile1]match remote identity fqdn rtb

//配置对等体的策略匹配信息

[RTA-ike-profile-profile1]keychain keychain1

//指定要使用的密钥链

[RTA-ike-profile-profile1]proposal 1

//配置IKE安全策略的IKE安全提议

[RTA-ike-profile-profile1]quit

[RTB]ike profile profile1

[RTB-ike-profile-profile1]exchange-mode aggressive

//修改协商模式为野蛮模式

[RTB-ike-profile-profile1]match remote identity fqdn rta

//匹配对端标识信息

[RTB-ike-profile-profile1]keychain keychain1

//指定要使用的密钥链

[RTB-ike-profile-profile1]proposal 1

//配置IKE安全策略的IKE安全提议

[RTB-ike-profile-profile1]quit

步骤八:配置安全 ACL

安全 ACL 应匹配 192.168.1.0/24 网段与 192.168.2.0/24 网段之间的数据流。

[RTA]acl advanced 3000

[RTA-acl-ipv4-adv-3000] rule 0 permit ip source 192.168.1.0 0.0.0.255 destination

192.168.2.0 0.0.0.255

[RTA-acl-ipv4-adv-3001]quit

[RTB]acl advanced 3000

[RTB-acl-ipv4-adv-3000] rule 0 permit ip source 192.168.2.0 0.0.0.255 destination

192.168.1.0 0.0.0.255

[RTB-acl-ipv4-adv-3000]quit

步骤九:配置 IPsec 安全提议

[RTA]ipsec transform-set tran1

[RTA-ipsec-proposal-prop1]esp authentication-algorithm sha1

//指定ESP认证算法为sha1

[RTA-ipsec-proposal-prop1]esp encryption-algorithm aes-cbc-128

//指定ESP加密算法

[RTA-ipsec-transform-set-tran1]quit

[RTB]ipsec transform-set tran1

[RTB-ipsec-transform-set-tran1]esp authentication-algorithm sha1

//指定ESP认证算法为sha1

[RTB-ipsec-transform-set-tran1]esp encryption-algorithm aes-cbc-128

//指定ESP加密算法

[RTB-ipsec-transform-set-tran1]quit

步骤十:配置并应用 IPsec 安全策略

配置 IPsec 安全策略,并将其应用于通往对方的物理接口上:

[RTA]ipsec policy policy1 1 isakmp

//指定IPsec隧道对端IP地址

[RTA-ipsec-policy-isakmp-policy1-1]remote-address 2.2.2.1

//指定IPsec隧道对端IP地址

[RTA-ipsec-policy-isakmp-policy1-1]security acl 3000

//配置流量保护参数

[RTA-ipsec-policy-isakmp-policy1-1]transform-set tran1

//指定IPsec转换集

[RTA-ipsec-policy-isakmp-policy1-1]ike-profile profile1

//配置IKE (Internet Key Exchange)安全策略

[RTA-ipsec-policy-isakmp-policy1-1]quit

[RTA]interface GigabitEthernet 0/0

[RTA-GigabitEthernet0/0]ipsec apply policy policy1

//在接口上应用安全策略

[RTA-GigabitEthernet0/0]quit

RTB 作为响应方,无法获取对端的 IP 地址,需要配置成模板形式。

[RTB]ipsec policy-template templete1 1

[RTB-ipsec-policy-template-templete1-1]security acl 3000

[RTB-ipsec-policy-template-templete1-1]transform-set tran1

[RTB-ipsec-policy-template-templete1-1]ike-profile proflie1

[RTB]ipsec policy policy1 1 isakmp template templete1

[RTB]interface GigabitEthernet 0/0

[RTB-GigabitEthernet0/0]ipsec apply policy policy1

[RTB-GigabitEthernet0/0]quit

步骤十一:检验配置

在 RTA 和 RTB 上用 display 命令检查配置参数:

[RTA]display ike proposal

 Priority Authentication Authentication Encryption  Diffie-Hellman Duration

              method       algorithm    algorithm       group      (seconds)

----------------------------------------------------------------------------

 1        PRE-SHARED-KEY     MD5        3DES-CBC    Group 1        86400

 default  PRE-SHARED-KEY     SHA1       DES-CBC     Group 1        86400

[RTA]display ipsec policy

-------------------------------------------

IPsec Policy: policy1

Interface: GigabitEthernet0/0

-------------------------------------------

  -----------------------------

  Sequence number: 1

  Mode: ISAKMP

  -----------------------------

  Traffic Flow Confidentiality: Disabled

  Security data flow: 3000

  Selector mode: standard

  Local address:

  Remote address: 2.2.2.1

  Remote address switchback mode: Disabled

  Transform set:  tran1

  IKE profile: profile1

  IKEv2 profile:

  smart-link policy:

  SA trigger mode: Traffic-based

  SA duration(time based): 3600 seconds

  SA duration(traffic based): 1843200 kilobytes

  SA soft-duration buffer(time based): --

  SA soft-duration buffer(traffic based): --

  SA idle time: --

  SA df-bit:

[RTB]display ipsec policy-template

-------------------------------------------

IPsec Policy Template: templete1

-------------------------------------------

  -----------------------------

  Sequence number: 1

  -----------------------------

  Traffic Flow Confidentiality: Disabled

  Security data flow : 3000

  Selector mode: standard

  Local address:

  IKE profile: profile1

  IKEv2 profile:

  Remote address:

  Transform set: tran1

  IPsec SA local duration(time based): 3600 seconds

  IPsec SA local duration(traffic based): 1843200 kilobytes

  SA idle time: --

  SA df-bit:

在 RTA 与 RTB 上查看 IPsec/IKE 相关信息:

[RTA]display ike sa verbose

   -----------------------------------------------

   Connection ID: 4

   Outside VPN:

   Inside VPN:

   Profile: profile1

   Transmitting entity: Initiator

   Initiator cookie: b3bcaddf7a4212a5

   Responder cookie: b3c52817b752a0fb

   -----------------------------------------------

   Local IP/port: 1.1.1.1/500

   Local ID type: FQDN

   Local ID: rta

   Remote IP/port: 2.2.2.1/500

   Remote ID type: FQDN

   Remote ID: rtb

   Authentication-method: PRE-SHARED-KEY

   Authentication-algorithm: MD5

   Encryption-algorithm: 3DES-CBC

   Life duration(sec): 86400

   Remaining key duration(sec): 83201

   Exchange-mode: Aggressive

   Diffie-Hellman group: Group 1

   NAT traversal: Not detected

   Extend authentication: Disabled

   Assigned IP address:

   Vendor ID index:0xffffffff

   Vendor ID sequence number:0x0

看到 IKE 的协商模式是野蛮模式(Aggressive)

[RTB]display ike sa verbose

   -----------------------------------------------

   Connection ID: 4

   Outside VPN:

   Inside VPN:

   Profile: profile1

   Transmitting entity: Responder

   Initiator cookie: b3bcaddf7a4212a5

   Responder cookie: b3c52817b752a0fb

   -----------------------------------------------

   Local IP/port: 2.2.2.1/500

   Local ID type: FQDN

   Local ID: rtb

   Remote IP/port: 1.1.1.1/500

   Remote ID type: FQDN

   Remote ID: rta

   Authentication-method: PRE-SHARED-KEY

   Authentication-algorithm: MD5

   Encryption-algorithm: 3DES-CBC

   Life duration(sec): 86400

   Remaining key duration(sec): 83178

   Exchange-mode: Aggressive

   Diffie-Hellman group: Group 1

   NAT traversal: Not detected

   Extend authentication: Disabled

   Assigned IP address:

   Vendor ID index:0xffffffff

   Vendor ID sequence number:0x0

步骤十二:检验隧道工作状况

从 PCA 检测与 PCB 的连通性:

<H3C>ping 192.168.2.2

Ping 192.168.2.2 (192.168.2.2): 56 data bytes, press CTRL_C to break

Request time out

56 bytes from 192.168.2.2: icmp_seq=1 ttl=253 time=3.000 ms

56 bytes from 192.168.2.2: icmp_seq=2 ttl=253 time=1.000 ms

56 bytes from 192.168.2.2: icmp_seq=3 ttl=253 time=2.000 ms

56 bytes from 192.168.2.2: icmp_seq=4 ttl=253 time=1.000 ms

--- Ping statistics for 192.168.2.2 ---

5 packet(s) transmitted, 4 packet(s) received, 20.0% packet loss

round-trip min/avg/max/std-dev = 1.000/1.750/3.000/0.829 ms

<H3C>%Oct 19 14:35:39:639 2022 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.2.2: 5 packet(s) transmitted, 4 packet(s) received, 20.0% packet loss, round-trip min/avg/max/std-dev = 1.000/1.750/3.000/0.829 ms.

可见除第一个 ICMP Echo Request 包被报告超时之外,其他的都成功收到 Echo Reply 包。

这是因为第一个包触发了 IKE 协商,在 IPsec SA 成功建立之前,这个包无法得到 IPsec 服务,

只能被丢弃。而 IPsec SA 很快就成功建立了,后续的包也就可以顺利到达目的

### Cisco 防火墙 IPSec 配置野蛮模式设置指南 在配置 Cisco ASA 防火墙的 IPSec 时,如果需要支持两端 IP 地址不固定的情况(例如 ADSL 拨号上网),可以使用 IKE 野蛮模式。以下是一个详细的配置指南[^2]。 #### 配置 IKE 野蛮模式 1. **启用 IKE 野蛮模式** 在 ASA 上配置 IKE 策略以支持野蛮模式。通过指定预共享密钥和允许非固定 IP 地址连接,可以实现动态对等体的支持。 ```bash crypto isakmp policy 10 encr aes authentication pre-share group 2 ``` 2. **配置预共享密钥** 设置预共享密钥以用于身份验证。确保两端设备使用相同的密钥。 ```bash crypto isakmp key mypre-shared-key address 0.0.0.0 ``` 3. **启用 NAT 穿越(NAT-T)** 如果网络中有 NAT 设备,必须启用 NAT 穿越以确保 IPSec 流量能够正常通过。 ```bash crypto isakmp nat-traversal 20 ``` 4. **配置 IPSec 变换集** 定义 IPSec 使用的加密算法和哈希算法。 ```bash crypto ipsec transform-set MY_TRANSFORM_SET esp-aes 256 esp-sha-hmac mode tunnel ``` 5. **创建访问控制列表(ACL)** 定义需要保护的流量。例如,允许从 DMZ 到内部网络的流量。 ```bash access-list dma_to_in permit tcp host 192.168.2.10 host 192.168.1.10 eq 1723 ``` 6. **配置 IPSec 隧道** 将 ACL 与 IPSec 变换集关联起来。 ```bash crypto map MY_CRYPTO_MAP 10 ipsec-isakmp set peer 0.0.0.0 set transform-set MY_TRANSFORM_SET match address dma_to_in ``` 7. **应用 crypto map 到接口** 将 crypto map 应用到 outside 接口以激活 IPSec 隧道。 ```bash interface GigabitEthernet0/1 crypto map MY_CRYPTO_MAP ``` #### 注意事项 - 确保两端设备的预共享密钥一致[^2]。 - 如果使用动态 IP 地址,请将 `set peer` 的值设置为 `0.0.0.0`,表示接受任何 IP 地址作为对等体。 - 在某些情况下,可能需要调整 MTU 值以避免分片问题。 #### 验证配置 完成配置后,可以通过以下命令验证 IPSec 隧道的状态: ```bash show crypto isakmp sa show crypto ipsec sa ``` 上述命令可以帮助确认 IKEIPSec 安全关联是否成功建立。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

李李网工日记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值