IPsecVPN配置教程
- 網絡技術
- 關注:1.85W次
在項目中遇到一個關於IPsecVPN的問題,這種場景並不是很常見。翻了一下,找到之前做過的測試數據,小編分享一下。也考考大家,看看有沒有人能想到更好的解決方案(當然是有替代方案的,可以自行測試一下)。
以下圖為例,R1及OR是站點1的設備,OR是站點1的出口路由器;R2是站點2的出口路由器。及分別用於模擬站點1和站點2的內網。R2的FE0/0直接連接Internet公網,使用的IP地址為,其默認網關為。而站點1則比較特殊,出於節省公網IP地址的目的',R1與出口路由器OR之間的互連鏈路採用私有IP地址段()。OR一個接口與R1對接,另一側的接口則連接着Internet。
現在站點1也額外申請到一個公網IP地址,。要求在站點1與站點2之間建立IPsecVPN隧道,而且需在R1與R2上完成(可能OR路由器不支持IPSecVPN)。最終的需求是與要能夠安全地互訪。這裏演示的方法是在R1上配置Loopback0接口,把公網地址放在這個接口上,然後R1(使用該公網地址)與R2建立IPsec隧道。這麼做的一個好處是,OR沒有NAT的壓力。當然即使是這個原因,我們演示的場景依然是挺奇葩的,不是麼。另一個方案是,OR部署Static NAT,將公網地址映射到,然後依然是在R1與R2上部署IPsec VPN,這種場景到是很常見,可自行測試。
【IPsecVPN】關於IPsecVPN的一個非常規場景
R1的配置如下:
#完成接口IP地址的配置:
interface Loopback0
ip address #將公司申請到的公網地址配置在Loopback0接口
interface Loopback1 #這個Loopback接口模擬本站點內網
ip address
interface FastEthernet0/0
ip address
#完成IPSec相關配置:
access-list 100 permit ip
crypto isakmp policy 1
authentication pre-share
group 2
exit
crypto isakmp key ccietea address
crypto ipsec transform-set myset esp-3des esp-sha-hmac
exit
crypto map mymap 1 ipsec-isakmp
match address 100
set peer
set transform-set myset
exit
#完成路由的配置:
ip route
ip route Loopback0
#將Crypto map應用在Loopback0接口:
interface Loopback0
crypto map mymap
注:在上述配置中,ip route Loopback0這條靜態路由用於將到達對端內網的流量引到Loopback0接口,從而“觸碰”到部署在Loopback0接口的Crypto map,進而匹配VPN調用的ACL100,觸發IKE協商並最終建立IPSecVPN隧道。
R2的配置如下:
#完成接口IP地址的配置:
interface Loopback1 #這個Loopback接口模擬本站點內網
ip address
interface FastEthernet0/0
ip address
#完成IPSec相關配置:
access-list 100 permit ip
crypto isakmp policy 1
authentication pre-share
group 2
exit
crypto isakmp key ccietea address
crypto ipsec transform-set myset esp-3des esp-sha-hmac
exit
crypto map mymap 1 ipsec-isakmp
match address 100
set peer
set transform-set myset
exit
#完成路由的配置:
ip route
#將Crypto map應用在FE0/0接口:
interface FastEthernet0/0
crypto map mymap
注意,OR路由器的配置除了基本的接口IP地址配置、默認路由指向Internet之外,還需配置靜態路由到達,使得Internet訪問這個公網IP地址的流量能夠抵達R1:
OR(config)#ip route x.x.x.x #默認路由指向Internet
OR(config)#ip route
完成上述配置後,在R1上執行如下操作:
R1#ping source
這個操作將觸發雙方IPSecVPN隧道的協商。完成協商後,在R1上查看IPSec SA:
R1#show crypto ipsec sa
interface: Loopback0
Crypto map tag: mymap, local addr
protected vrf: (none)
local ident (addr/mask/prot/port): ()
remote ident (addr/mask/prot/port): ()
current_peer port 500
PERMIT, flags={origin_is_acl,ipsec_sa_request_sent}
#pkts encaps: 9, #pkts encrypt: 9, #pkts digest: 9
#pkts decaps: 9, #pkts decrypt: 9, #pkts verify: 9
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 1, #recv errors 0
local crypto endpt.: , remote crypto endpt.:
path mtu 1514, ip mtu 1514, ip mtu idb Loopback0
current outbound spi: 0x2C3824ED(741876973)
inbound esp sas:
spi: 0x159FD96C(362797420)
transform: esp-3des esp-sha-hmac ,
in use settings ={Tunnel, }
conn id: 2001, flow_id: SW:1, crypto map: mymap
sa timing: remaining key lifetime (k/sec): (4489149/3586)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE
inbound ah sas:
inbound pcp sas:
outbound esp sas:
spi: 0x2C3824ED(741876973)
transform: esp-3des esp-sha-hmac ,
in use settings ={Tunnel, }
conn id: 2002, flow_id: SW:2, crypto map: mymap
sa timing: remaining key lifetime (k/sec): (4489149/3584)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE
outbound ah sas:
outbound pcp sas:
- 文章版權屬於文章作者所有,轉載請註明 https://xuezhezhai.com/zh-hk/jsj/wl/1verne.html