# 為R1設定IP及路由表
en
conf t
ho R1
int f0/0
no shut
ip add 172.16.1.254255.255.255.0
exit
int f0/1
no shut
ip add 100.1.1.1255.255.255.0
exit
ip route 0.0.0.00.0.0.0100.1.1.2# 為R2設定IP及路由表
en
conf t
ho R2
int f0/0
no shut
ip add 172.17.1.254255.255.255.0
exit
int f0/1
no shut
ip add 101.1.1.1255.255.255.0
exit
ip route 0.0.0.00.0.0.0101.1.1.2# 為R3設定IP及路由表
en
conf t
ho R3
int f0/0
no shut
ip add 172.18.1.254255.255.255.0
exit
int f0/1
no shut
ip add 102.1.1.1255.255.255.0
exit
ip route 0.0.0.00.0.0.0102.1.1.2# 為R4設定IP及路由表
en
conf t
ho R4
int f0/0
no shut
ip add 172.19.1.254255.255.255.0
exit
int f0/1
no shut
ip add 103.1.1.1255.255.255.0
exit
ip route 0.0.0.00.0.0.0103.1.1.2# 為R5設定IP及路由表
en
conf t
ho R4
int f0/0
no shut
ip add 100.1.1.2255.255.255.0
exit
int f0/1
no shut
ip add 101.1.1.2255.255.255.0
exit
int f1/0
no shut
ip add 102.1.1.2255.255.255.0
exit
int f1/1
no shut
ip add 103.1.1.2255.255.255.0
exit
2.2 實驗一:IPsecVPN設定
'''為R1設定IPsecVPN'''# 階段一
en
conf t
crypto isakmp policy 1
encryption aes
group 2hash sha
authentication pre-share
lifetime 3600
exit
crypto isakmp key QQ address 102.1.1.1# 階段二
acc 100 permit ip 172.16.1.00.0.0.255172.18.1.00.0.0.255
crypto ipsec transform-set QQtran esp-aes esp-sha-hmac
# 建立map對映
crypto map QQmap 1 ipsec-isakmp
set peer 102.1.1.1
match address 100set transform-set QQtran
exit
# 應用map對映int f0/1
crypto map QQmap
exit
'''為R3設定IPsecVPN'''# 階段一
en
conf t
crypto isakmp policy 1
encryption aes
group 2hash sha
authentication pre-share
lifetime 3600
exit
crypto isakmp key QQ address 100.1.1.1# 階段二,其中傳輸模式名在隧道兩端需要一致
acc 100 permit ip 172.18.1.00.0.0.255172.16.1.00.0.0.255
crypto ipsec transform-set QQtran esp-aes esp-sha-hmac
# 建立map對映
crypto map QQmap 1 ipsec-isakmp
set peer 100.1.1.1
match address 100set transform-set QQtran
exit
# 應用map對映int f0/1
crypto map QQmap
exit
# 檢視已設定的安全策略狀態
show crypto isakmp sa
2.3 實驗二:NAT豁免技術
每次設定ACL表時,需要先show ip access檢視一下已經設定過的表號,檢視所需資訊或避免表號衝突。
命令:
'''為R1設定PAT'''
en
conf t
int f0/0
ip nat inside
exit
int f0/1
ip nat outside
exit
acc 101 deny ip 172.16.1.00.0.0.255172.18.1.00.0.0.255
acc 101 permit ip anyany
ip nat inside source list101int f0/1 overload
'''為R3設定PAT'''
en
conf t
int f0/0
ip nat inside
exit
int f0/1
ip nat outside
exit
acc 101 deny ip 172.18.1.00.0.0.255172.16.1.00.0.0.255
acc 101 permit ip anyany
ip nat inside source list101int f0/1 overload
'''為R4設定靜態PAT'''
en
conf t
int f0/0
ip nat inside
exit
int f0/1
ip nat outside
exit
# 設定靜態PAT,將整個內網轉換為外網
ip nat inside source static 172.19.1.1103.1.1.1
# 檢視已設定的安全策略集內容
show crypto isakmp policy
# 檢視階段一的狀態
show crypto isakmp sa
# 檢視階段二應用狀態
show crypto ipsec sa
# 檢視階段二傳輸模式狀態
show crypto ipsec transform-set# 有可能是平臺bug,嘗試儲存並重新啟動
write
reload