網(wǎng)絡(luò)拓?fù)淙缟蠄D所示,為方便記憶從左到右順時針方向的網(wǎng)段的分別為192.168.1.0, 2.0, 3.0。
配置目標(biāo):兩臺思科防火墻之間建立IPsec VPN(野蠻模式),使得左邊192.168.1.0網(wǎng)段能夠訪問右邊192.168.3.0網(wǎng)段。左邊ASA1作為連接發(fā)起端,右邊ASA2作為連接接收端。在這里兩邊都是固定IP地址,在真實(shí)環(huán)境中發(fā)起端一般為非固定IP地址,如撥號上網(wǎng)的網(wǎng)絡(luò),光貓通過撥號動態(tài)獲取IP地址,ASA1防火墻可以放在光貓的LAN口一端。接收一端必須有固定IP地址。
基本信息:該環(huán)境使用GNS3模擬軟件,防火墻軟件版本為9.9(2)。配置完成后ipsec連接不會自動觸發(fā),需要數(shù)據(jù)請求通過隧道才會觸發(fā),而且只能在發(fā)起端(ASA1端)觸發(fā),比如在192.168.1.2上ping 192.168.3.2,就會觸發(fā)ipsec連接。
ASA1(發(fā)起連接端)防火墻配置:
基本配置:
配置主機(jī)名:
hostname ASA1
配置接口和IP地址:
int e0/0
nameif inside
ip address 192.168.1.1 255.255.255.0
no shut
int e0/1
nameif outside
ip address 192.168.2.1 255.255.255.0
no shut
配置從192.168.1.0到192.168.3.0的數(shù)據(jù)包不做地址轉(zhuǎn)換,該網(wǎng)絡(luò)拓?fù)浔容^簡單,可以不配置,但是真實(shí)環(huán)境比較復(fù)雜,一般都需要配置,故這里也配置上。由于這篇文章主要講ipsec的配置,故這里不做地址轉(zhuǎn)換命令的介紹。
?object network ASA1-inside
?subnet 192.168.1.0 255.255.255.0
object network ASA2-inside
?subnet 192.168.3.0 255.255.255.0
nat (inside,outside) source static ASA1-inside ASA1-inside destination static ASA2-inside ASA2-inside
下面配置控制連接的參數(shù),配置后,收到連接或發(fā)出連接請求時會根據(jù)策略號由低到高的匹配對端的策略
設(shè)置1號策略,策略號可以隨便填,敲入后進(jìn)入二層命令行
crypto ikev1 policy 1
?設(shè)置預(yù)共享密碼(不是密鑰),密碼需要與對端一致,具體密碼在通道命令里設(shè)置
?authentication pre-share
?設(shè)置控制連接加密方法為3des,需要與對端一致
?encryption 3des
?設(shè)置控制連接數(shù)據(jù)包完整性校驗(yàn)方法為sha,需要與對端一致
?hash sha
?設(shè)置密鑰生成的長度,需要與對端一致,一般號碼越高,越長
?group 2
?設(shè)置密鑰更新周期,建議與對端一致
?lifetime 28800
下面配置數(shù)據(jù)連接的參數(shù):
使用隧道(esp)方式,建議使用esp.? 加密方式為3des,數(shù)據(jù)完整性校驗(yàn)方式為sha
crypto ipsec ikev1 transform-set trans1 esp-3des esp-sha-hmac
配置NAT-T特性,這個特性使得防火墻outside接口的IP地址,如果在網(wǎng)絡(luò)中有被轉(zhuǎn)換為其他地址,則雙方也能通訊,建議配置。如果outside接口的IP地址被網(wǎng)絡(luò)中的設(shè)備NAT后沒有配置這個選項,則IPSEC不能建立。這個命令后面會加一個數(shù)字表示多少秒,該數(shù)字表示周期性發(fā)送類似于心跳包的數(shù)據(jù)包,保持網(wǎng)絡(luò)中網(wǎng)絡(luò)設(shè)備的NAT會話不會被刪除。
crypto isakmp nat-traversal 30
配置對端設(shè)備的身份識別方式(可以理解為賬號名,一般登陸一個系統(tǒng)需要賬戶名和密碼,密碼就是預(yù)共享密碼在后面配置)
簡要介紹一下這個命令:
?crypto isakmp identity {address | hostname |? key-id 字符串 | auto}
可以看出有3種類型的識別方式, address,hostname, key-id。auto是address和hostname的綜合,這里不介紹。識別方式要和對端一致。hostname的識別方式叫FQDN識別方式,hostname只是思科命令不是IPsec的術(shù)語。如果選擇hostname則用戶名(身份識別字符串)為設(shè)備的hostname,可以用show hostname命令查看具體字符串。ASA1建立控制連接時發(fā)送的數(shù)據(jù)包會含很多信息,其中兩個信息就是:一.字符串ASA2? 二.FQDN方式。
對端ASA2配置好之后,在建立控制連接的過程中也會把自身的身份發(fā)送到ASA1,其中兩個信息就是:一.字符串ASA2?? 二. FQDN方式
在本場景中,使用識別方式為hostname方式,則FQDN身份識別方式的識別字符串為ASA1。查看之前基本配置里的配置命令(hostname ?ASA1)。
crypto isakmp identity hostname
配置IPSEC通道
野蠻方式的通道名為對端的身份識別字符串,對端的識別方式為FQDN方式,識別字符串為ASA2。
tunnel-group ASA2 type ipsec-l2l
配置這條命令后設(shè)備會有提示,表示該配置為數(shù)字證書或者對端為野蠻模式才會這樣配,如下圖所示,可以忽略這個提示。
配置預(yù)共享密碼和斷線檢測
tunnel-group ASA2 ipsec-attributes
進(jìn)入第二層命令模式
配置連接密碼為123456,需與對端一致
?ikev1 pre-shared-key ?123456
配置IPSEC密碼和斷線檢測,配置20秒超時后重傳,重傳3次判斷為斷線
?isakmp keepalive threshold 20 retry 3
配置哪些數(shù)據(jù)包需要轉(zhuǎn)發(fā)到IPSEC通道,該配置需要設(shè)置一個ACL,然后后面配置綁定這個ACL
access-list goIntoTunnel extended permit ip 192.168.1.0 255.255.255.0 192.168.3.0 255.255.255.0
注意上面這個ACL的網(wǎng)段必須與對端相對應(yīng),不然連接建立不起來。
比如上面這個ACL可以總結(jié)為:(本端192.168.1.0/24, 對端192.168.3.0/24)。則對端需要配置為:(本端192.168.3.0/24,對端192.168.1.0/24)。如果對端配置為:(本端192.168.3.0/27, 對端192.168.1.0/24)則不能匹配,不能建立連接。
配置cryto map。? cryto map是一個列表,該列表記錄哪些數(shù)據(jù)包需要建立IPsec, 將前面配置的一些分散的信息綁定到一起形成一個ipsec連接的完整信息,這個列表有序號,序號可以隨意填,匹配IPSEC參數(shù)的時候按照序號從低到高的順序進(jìn)行匹配。
設(shè)置10號入口,匹配ACL名為goIntoTunnel(該ACL已在之前設(shè)置好),需要與對端為192.168.2.1的地址建立IPSEC連接,數(shù)據(jù)連接參數(shù)為trans1(該參數(shù)已在之前設(shè)置),發(fā)起控制連接時使用野蠻模式發(fā)起連接。
crypto map mymap 10 match address goIntoTunnel
crypto map mymap 10 set peer 192.168.2.2
crypto map mymap 10 set ikev1 phase1-mode aggressive
crypto map mymap 10 set ikev1 transform-set trans1
將crypto map 綁定到outside并設(shè)置ISAKMP(Internet Security Association and Key Management Protocol)為enable。ISAKMP就是建立IPsec連接時需要使用的框架,包含一系列的規(guī)則。
crypto map mymap interface outside
crypto ikev1 enable outside
設(shè)置允許IPSEC的數(shù)據(jù)包進(jìn)入防火墻
sysopt connection permit-vpn
設(shè)置192.168.3.0的數(shù)據(jù)包通過outside接口進(jìn)行發(fā)送
route outside 192.168.3.0 255.255.255.0 192.168.2.2
ASA1配置完畢。
配置ASA2:
基本配置:
配置主機(jī)名:
hostname ASA2
配置接口和IP地址:
int e0/0
nameif inside
ip address 192.168.3.1 255.255.255.0
no shut
int e0/1
nameif outside
ip address 192.168.2.2 255.255.255.0
no shut
配置從192.168.3.0到192.168.1.0的數(shù)據(jù)包不做地址轉(zhuǎn)換,上面已介紹過。
object network ASA1-inside
?subnet 192.168.1.0 255.255.255.0
object network ASA2-inside
?subnet 192.168.3.0 255.255.255.0
nat (inside,outside) source static ASA2-inside ASA2-inside destination static ASA1-inside ASA1-inside
下面配置控制連接的參數(shù),上面已介紹過。
crypto ikev1 policy 1
?authentication pre-share
?encryption 3des
?hash sha
?group 2
?lifetime 28800
下面配置數(shù)據(jù)連接的參數(shù),上面已介紹過:
crypto ipsec ikev1 transform-set trans1 esp-3des esp-sha-hmac
配置NAT-T特性,上面已介紹過。
crypto isakmp nat-traversal 30
配置對端設(shè)備的身份識別方式,上面已介紹過:
crypto isakmp identity hostname
配置IPSEC通道,上面已介紹過,和上面不同的是這里設(shè)置通道名為ASA1。
tunnel-group ASA1 type ipsec-l2l
配置預(yù)共享密碼和斷線檢測,上面已介紹過:
tunnel-group ASA1 ipsec-attributes
?ikev1 pre-shared-key ?123456
?isakmp keepalive threshold 20 retry 3
配置哪些數(shù)據(jù)包需要轉(zhuǎn)發(fā)到IPSEC通道,上面已介紹過。
access-list goIntoTunnel extended permit ip 192.168.3.0 255.255.255.0 192.168.1.0 255.255.255.0
配置動態(tài)crypto maps:
由于野蠻模式的控制連接只需要設(shè)備認(rèn)證方式和預(yù)共享密碼匹配就能連接,對于接收端來說發(fā)起端的IP地址不知道(相當(dāng)于信息不全),需要設(shè)置到動態(tài)crypto maps(Dynamic Crypto Maps)里。靜態(tài)crypto maps就是ASA1里面配置的crypto maps那樣。動態(tài)crypto maps只設(shè)置在野蠻模式的接收端,和靜態(tài)crypto maps一樣,也是把一些分散的信息集中起來形成一個完整的ipsec連接信息,里面的匹配規(guī)則也和靜態(tài)crypto maps一樣從低到高匹配,配置方式也和靜態(tài)crypto maps一樣。設(shè)置好之后,最終也要綁定到靜態(tài)crypto maps上。然后把靜態(tài)crypto maps綁定到接口上。
配置一個名為dyn1的動態(tài)crypto maps,配置30號入口(號碼隨便填寫),匹配ACL名為goIntoTunnel(該ACL已在之前設(shè)置好),數(shù)據(jù)連接參數(shù)為trans1(該參數(shù)已在之前設(shè)置)。
crypto dynamic-map dyn1 30 match address goIntoTunnel
crypto dynamic-map dyn1 30 set ikev1 transform-set trans1
將該動態(tài)crypto maps綁定到靜態(tài)crypto maps上
crypto map mymap 50 ipsec-isakmp dynamic dyn1
將靜態(tài)crypto map 綁定到outside并設(shè)置為enable,? 上面已介紹過。
crypto map mymap interface outside
crypto ikev1 enable outside
設(shè)置允許IPSEC的數(shù)據(jù)包進(jìn)入防火墻
sysopt connection permit-vpn
設(shè)置192.168.1.0的數(shù)據(jù)包通過outside接口進(jìn)行發(fā)送
route outside 192.168.1.0 255.255.255.0 192.168.2.1
ASA2配置完畢。
兩個防火墻設(shè)置完畢后,只能從發(fā)起端的PC發(fā)送數(shù)據(jù)包請求通過隧道,才會觸發(fā)ipsec連接(因?yàn)榻邮斩说呐渲美餂]有發(fā)起端的IP地址信息)??梢詮腜C1(192.168.1.2)ping PC3(192.168.3.2)觸發(fā)設(shè)備建立IPsec連接??梢允褂胹how crypto isakmp sa查看控制連接是否建立,使用show crypto ipsec sa查看數(shù)據(jù)連接是否建立。如下圖所示:
兩個防火墻的所有配置如下:
ASA1配置:
ASA1(config)# show run
: Saved
:
: Serial Number: 9AG0P7LU00M
: Hardware:?? ASAv, 2048 MB RAM, CPU Pentium II 3591 MHz
:
ASA Version 9.9(2)
!
hostname ASA1
enable password $sha512$5000$YZTh8YIpAhQedXT5xcZWPA==$JdPEXF2OhJ0ZMD4BelIvdQ== pbkdf2
names
!
interface GigabitEthernet0/0
?nameif inside
?security-level 100
?ip address 192.168.1.1 255.255.255.0
!
interface GigabitEthernet0/1
?nameif outside
?security-level 0
?ip address 192.168.2.1 255.255.255.0
!
interface GigabitEthernet0/2
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/3
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/4
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/5
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/6
?shutdown
?no nameif
?no security-level
?no ip address
!
interface Management0/0
?shutdown
?no nameif
?no security-level
?no ip address
!
ftp mode passive
object network ASA1-inside
?subnet 192.168.1.0 255.255.255.0
object network ASA2-inside
?subnet 192.168.3.0 255.255.255.0
access-list goIntoTunnel extended permit ip 192.168.1.0 255.255.255.0 192.168.3.0 255.255.255.0
pager lines 23
mtu outside 1500
mtu inside 1500
no failover
icmp unreachable rate-limit 1 burst-size 1
no asdm history enable
arp timeout 14400
no arp permit-nonconnected
arp rate-limit 8192
nat (inside,outside) source static ASA1-inside ASA1-inside destination static ASA2-inside ASA2-inside
route outside 192.168.3.0 255.255.255.0 192.168.2.2 1
timeout xlate 3:00:00
timeout pat-xlate 0:00:30
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 sctp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
timeout conn-holddown 0:00:15
timeout igp stale-route 0:01:10
user-identity default-domain LOCAL
aaa authentication login-history
no snmp-server location
no snmp-server contact
crypto ipsec ikev1 transform-set trans1 esp-3des esp-sha-hmac
crypto ipsec security-association pmtu-aging infinite
crypto map mymap 10 match address goIntoTunnel
crypto map mymap 10 set peer 192.168.2.2
crypto map mymap 10 set ikev1 phase1-mode aggressive
crypto map mymap 10 set ikev1 transform-set trans1
crypto map mymap interface outside
crypto ca trustpoint _SmartCallHome_ServerCA
?no validation-usage
?crl configure
crypto ca trustpool policy
?auto-import
crypto isakmp identity hostname
crypto isakmp nat-traversal 30
crypto ikev1 enable outside
crypto ikev1 policy 1
?authentication pre-share
?encryption 3des
?hash sha
?group 2
?lifetime 28800
telnet timeout 5
ssh stricthostkeycheck
ssh timeout 5
ssh version 2
ssh key-exchange group dh-group1-sha1
console timeout 0
console serial
threat-detection basic-threat
threat-detection statistics access-list
no threat-detection statistics tcp-intercept
dynamic-access-policy-record DfltAccessPolicy
tunnel-group ASA2 type ipsec-l2l
tunnel-group ASA2 ipsec-attributes
?ikev1 pre-shared-key *****
?isakmp keepalive threshold 20 retry 3
!
class-map inspection_default
?match default-inspection-traffic
!
!
policy-map type inspect dns migrated_dns_map_1
?parameters
? message-length maximum client auto
? message-length maximum 512
? no tcp-inspection
policy-map global_policy
?class inspection_default
? inspect dns migrated_dns_map_1
? inspect ftp
? inspect h323 h225
? inspect h323 ras
? inspect ip-options
? inspect netbios
? inspect rsh
? inspect rtsp
? inspect skinny
? inspect esmtp
? inspect sqlnet
? inspect sunrpc
? inspect tftp
? inspect sip
? inspect xdmcp
policy-map type inspect dns migrated_dns_map_2
?parameters
? message-length maximum client auto
? message-length maximum 512
? no tcp-inspection
!
service-policy global_policy global
prompt hostname context
no call-home reporting anonymous
call-home
?profile CiscoTAC-1
? no active
? destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
? destination address email callhome@cisco.com
? destination transport-method http
? subscribe-to-alert-group diagnostic
? subscribe-to-alert-group environment
? subscribe-to-alert-group inventory periodic monthly
? subscribe-to-alert-group configuration periodic monthly
? subscribe-to-alert-group telemetry periodic daily
Cryptochecksum:c030dd47ce46973d8811b1556136f85a
: end文章來源:http://www.zghlxwxcb.cn/news/detail-836083.html
ASA1(config)#
ASA2配置:
ASA2(config)# show run
: Saved
:
: Serial Number: 9AA4EG8LNAD
: Hardware:?? ASAv, 2048 MB RAM, CPU Pentium II 3591 MHz
:
ASA Version 9.9(2)
!
hostname ASA2
enable password $sha512$5000$BgWr3rLdxm3i+QSJKnW9QQ==$J7iDqV+4n52S34mxjxrF2A== pbkdf2
names
!
interface GigabitEthernet0/0
?nameif inside
?security-level 100
?ip address 192.168.3.1 255.255.255.0
!
interface GigabitEthernet0/1
?nameif outside
?security-level 0
?ip address 192.168.2.2 255.255.255.0
!
interface GigabitEthernet0/2
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/3
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/4
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/5
?shutdown
?no nameif
?no security-level
?no ip address
!
interface GigabitEthernet0/6
?shutdown
?no nameif
?no security-level
?no ip address
!
interface Management0/0
?shutdown
?no nameif
?no security-level
?no ip address
!
ftp mode passive
object network ASA1-inside
?subnet 192.168.1.0 255.255.255.0
object network ASA2-inside
?subnet 192.168.3.0 255.255.255.0
access-list goIntoTunnel extended permit ip 192.168.3.0 255.255.255.0 192.168.1.0 255.255.255.0
pager lines 23
mtu outside 1500
mtu inside 1500
no failover
icmp unreachable rate-limit 1 burst-size 1
no asdm history enable
arp timeout 14400
no arp permit-nonconnected
arp rate-limit 8192
nat (inside,outside) source static ASA2-inside ASA2-inside destination static ASA1-inside ASA1-inside
route outside 192.168.1.0 255.255.255.0 192.168.2.1 1
timeout xlate 3:00:00
timeout pat-xlate 0:00:30
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 sctp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
timeout conn-holddown 0:00:15
timeout igp stale-route 0:01:10
user-identity default-domain LOCAL
aaa authentication login-history
no snmp-server location
no snmp-server contact
crypto ipsec ikev1 transform-set trans1 esp-3des esp-sha-hmac
crypto ipsec security-association pmtu-aging infinite
crypto dynamic-map dyn1 30 match address goIntoTunnel
crypto dynamic-map dyn1 30 set ikev1 transform-set trans1
crypto map mymap 50 ipsec-isakmp dynamic dyn1
crypto map mymap interface outside
crypto ca trustpoint _SmartCallHome_ServerCA
?no validation-usage
?crl configure
crypto ca trustpool policy
?auto-import
crypto isakmp identity hostname
crypto isakmp nat-traversal 30
crypto ikev1 policy 1
?authentication pre-share
?encryption 3des
?hash sha
?group 2
?lifetime 28800
telnet timeout 5
ssh stricthostkeycheck
ssh timeout 5
ssh version 2
ssh key-exchange group dh-group1-sha1
console timeout 0
console serial
threat-detection basic-threat
threat-detection statistics access-list
no threat-detection statistics tcp-intercept
dynamic-access-policy-record DfltAccessPolicy
tunnel-group ASA1 type ipsec-l2l
tunnel-group ASA1 ipsec-attributes
?ikev1 pre-shared-key *****
?isakmp keepalive threshold 20 retry 3
!
class-map inspection_default
?match default-inspection-traffic
!
!
policy-map type inspect dns migrated_dns_map_1
?parameters
? message-length maximum client auto
? message-length maximum 512
? no tcp-inspection
policy-map global_policy
?class inspection_default
? inspect dns migrated_dns_map_1
? inspect ftp
? inspect h323 h225
? inspect h323 ras
? inspect ip-options
? inspect netbios
? inspect rsh
? inspect rtsp
? inspect skinny
? inspect esmtp
? inspect sqlnet
? inspect sunrpc
? inspect tftp
? inspect sip
? inspect xdmcp
policy-map type inspect dns migrated_dns_map_2
?parameters
? message-length maximum client auto
? message-length maximum 512
? no tcp-inspection
!
service-policy global_policy global
prompt hostname context
no call-home reporting anonymous
call-home
?profile CiscoTAC-1
? no active
? destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
? destination address email callhome@cisco.com
? destination transport-method http
? subscribe-to-alert-group diagnostic
? subscribe-to-alert-group environment
? subscribe-to-alert-group inventory periodic monthly
? subscribe-to-alert-group configuration periodic monthly
? subscribe-to-alert-group telemetry periodic daily
Cryptochecksum:b64ac3c3d10f45ee6d61cb3617a4dd7b
: end
ASA2(config)#文章來源地址http://www.zghlxwxcb.cn/news/detail-836083.html
到了這里,關(guān)于思科防火墻IPsec配置-野蠻模式方式(基于9.9版本)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!