在華為裝置上實施GRE隧道和IPSECVPN

科技小能手發表於2017-11-13

IPSEC VPN是幹私活利器哦,歡迎大家學習和掌握

私有的BGP的AS號碼:64512~65535,網際網路的基礎就是BGP

VPN的簡單分類:

一大類IPSEC VPN,這是一個框架,包含很多解決方案

LAN to LAN VPN(站點到站點的VPN)僅僅是IPSEC VPN中的一小類而已,它基於internet實現

另外一類是MPLS VPN(多協議標籤交換),又分成L3VPN(peer2peer,即裝置之間建立路由協議鄰居);IPSEC的框架:1)AH(認證頭部) 2)ESP(安全頭部負載封裝,協議號50) 3)IKE(網際網路祕鑰交換協議)–面試常見題目

會形成兩種SA(安全關聯):ISAKMP SA和IPSEC SA

傳輸模式和隧道模式

實施拓撲:
在華為裝置上實施GRE隧道和IPSEC VPN

1.實施GRE隧道(協議號47),它的特點是支援路由協議。如果實現加密的叫做GRE over IPSEC

R1:

interface Tunnel0/0/0

tunnel-protocol gre

source 202.100.1.1

destination 202.100.1.2

ip address 10.1.12.1 24

R2:

interface Tunnel0/0/0

tunnel-protocol gre

source 202.100.1.2

destination 202.100.1.1

ip address 10.1.12.2 255.255.255.0

[Huawei-Tunnel0/0/0]ping 10.1.12.2

PING 10.1.12.2: 56 data bytes, press CTRL_C to break

Reply from 10.1.12.2: bytes=56 Sequence=1 ttl=255 time=70 ms

Reply from 10.1.12.2: bytes=56 Sequence=2 ttl=255 time=30 ms

在GRE隧道上實施路由協議:

[R2-GigabitEthernet0/0/1]dis cu conf rip

[V200R003C00]

#

rip 1

version 2

network 10.0.0.0 //實施在GRE隧道上的動態路由協議



[R1-rip-1]dis th

[V200R003C00]

#

rip 1

version 2

network 10.0.0.0

通過GRE隧道得到的路由

[R1-rip-1]dis ip rou pro rip

Route Flags: R – relay, D – download to fib

Public routing table : RIP

Destinations : 1 Routes : 1

RIP routing table status : <Active>

Destinations : 1 Routes : 1

Destination/Mask Proto Pre Cost Flags NextHop Interface

   10.1.2.0/24  RIP     100  1           D   10.1.12.2       Tunnel0/0/0

RIP routing table status : <Inactive>

Destinations : 0 Routes : 0

終端的通訊:

PC>ping 10.1.1.1

Ping 10.1.1.1: 32 data bytes, Press Ctrl_C to break

Request timeout!

From 10.1.1.1: bytes=32 seq=2 ttl=126 time=15 ms

From 10.1.1.1: bytes=32 seq=3 ttl=126 time=15 ms

From 10.1.1.1: bytes=32 seq=4 ttl=126 time=15 ms

From 10.1.1.1: bytes=32 seq=5 ttl=126 time=15 ms

— 10.1.1.1 ping statistics —

5 packet(s) transmitted

4 packet(s) received

20.00% packet loss

round-trip min/avg/max = 0/15/15 ms

2.L2L的IPSEC VPN

實施步驟:1)實施路由的可達性

HEDEX

加解密裝置至少需要3條路由:A.到達對端加解密點的路由;B.到達本端通訊點的路由;C.到達對端通訊點的路由(這點容易忽略,但是轉發裝置如果沒有到達目的地的路由就丟棄資料包)

R1的路由實施:

[R1]ip route-static 10.1.2.0 24 g0/0/0 202.100.1.2

另外兩個要求預設使用直連路由完成

[R2]ip route-static 0.0.0.0 0.0.0.0 g0/0/0 202.100.1.1

2)實施第一階段的Proposal策略

R1&R2:

ipsec proposal QYT

esp authentication-algorithm sha1

[R2]display ipsec proposal

Number of proposals: 1

IPSec proposal name: QYT 

Encapsulation mode: Tunnel 

Transform : esp-new

ESP protocol : Authentication SHA1-HMAC-96 

Encryption DES

[R2]

3)實施SPD(ACL來匹配哪些資料通過IPSEC 處理),感興趣

R1:

acl name VPN 3999 

rule 10 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255 

R2:

acl name VPN 3999 

rule 10 permit ip source 10.1.2.0 0.0.0.255 destination 10.1.1.0 0.0.0.255 

4)整合IPSEC 策略

R1:

ipsec policy NONGDA 10 manual

security acl 3999

proposal QYT

tunnel local 202.100.1.1

tunnel remote 202.100.1.2

sa spi inbound esp 6543

sa string-key inbound esp simple nongda

sa spi outbound esp 3456

sa string-key outbound esp simple nongda

R2:

ipsec policy NONGDA 10 manual

security acl 3999

proposal QYT

tunnel local 202.100.1.2

tunnel remote 202.100.1.1

sa spi inbound esp 3456

sa string-key inbound esp simple nongda

sa spi outbound esp 6543

sa string-key outbound esp simple **

應用策略

兩個閘道器裝置應用:

interface GigabitEthernet0/0/0

ip address 202.100.1.2 255.255.255.252 

ipsec policy NONGDA

[R2]dis ipsec sa //驗證安全關聯

===============================

Interface: GigabitEthernet0/0/0

Path MTU: 1500


IPSec policy name: “NONGDA”

Sequence number : 10

Acl Group : 3999

Acl rule : 0

Mode : Manual

Encapsulation mode: Tunnel
Tunnel local      : 202.100.1.2
Tunnel remote     : 202.100.1.1
Qos pre-classify  : Disable

[Outbound ESP SAs] 
  SPI: 6543 (0x198f)
  Proposal: ESP-ENCRYPT-DES-64 ESP-AUTH-SHA1
  No duration limit for this SA

[Inbound ESP SAs] 
  SPI: 3456 (0xd80)                   
  Proposal: ESP-ENCRYPT-DES-64 ESP-AUTH-SHA1
  No duration limit for this SA

[R2]dis ipsec statistics esp //驗證通過SEC加解密的報文

Inpacket count : 9

Inpacket auth count : 0

Inpacket decap count : 0

Outpacket count : 7

NAT bypass(用acl拒絕掉VPN流量,再配置其他流量去訪問網際網路),即在NAT環境下實施IPSEC VPN

本文轉自EnderJoe 51CTO部落格,原文連結:http://blog.51cto.com/enderjoe/2057897


相關文章