Me pehea te raruraru IPsec VPN o te kainga. Wāhanga 1

Me pehea te raruraru IPsec VPN o te kainga. Wāhanga 1

Te āhuatanga

Rā whakatā. Ka inu kawhe ahau. I whakaritea e te tauira he hononga VPN i waenga i nga waahi e rua ka ngaro. Ka tirohia e au: he pono he kauhanga, engari kaore he waka i roto i te kauhanga. Kare te tauira e whakautu waea.

Ka maka e ahau te ketere ka ruku ki roto i te rapunga raruraru S-Terra Gateway. Ka tohatoha ahau i aku wheako me taku tikanga.

Raw raraunga

Ko nga waahi wehe whenua e rua e hono ana e te kohanga GRE. Me whakamuna te GRE:

Me pehea te raruraru IPsec VPN o te kainga. Wāhanga 1

Kei te taki au i te mahi o te kauhanga GRE. Ki te mahi i tenei, ka rere ahau i te ping mai i te taputapu R1 ki te atanga GRE o te taputapu R2. Koinei te kaupapa hokohoko mo te whakamunatanga. Karekau he whakautu:

root@R1:~# ping 1.1.1.2 -c 4
PING 1.1.1.2 (1.1.1.2) 56(84) bytes of data.

--- 1.1.1.2 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3057ms

Ka titiro au ki nga rakau i runga i te Gate1 me te Gate2. Kei te harikoa te korero a te raarangi kua pai te whakarewatanga o te kauhanga IPsec, kaore he raru:

root@Gate1:~# cat /var/log/cspvpngate.log
Aug  5 16:14:23 localhost  vpnsvc: 00100119 <4:1> IPSec connection 5 established, traffic selector 172.17.0.1->172.16.0.1, proto 47, peer 10.10.10.251, id "10.10.10.251", Filter 
IPsec:Protect:CMAP:1:LIST, IPsecAction IPsecAction:CMAP:1, IKERule IKERule:CMAP:1

I roto i nga tatauranga o te kauhanga IPsec i runga i te Gate1 ka kite ahau he tunnel tena, engari kua tautuhia te porotiti Rсvd ki te kore:

root@Gate1:~# sa_mgr show
ISAKMP sessions: 0 initiated, 0 responded

ISAKMP connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) State Sent Rcvd
1 3 (10.10.10.251,500)-(10.10.10.252,500) active 1070 1014

IPsec connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) Protocol Action Type Sent Rcvd
1 3 (172.16.0.1,*)-(172.17.0.1,*) 47 ESP tunn 480 0

Ka raru ahau i a S-Terra penei: Ka rapu ahau kei hea nga paatete e ngaro ana i te huarahi mai i te R1 ki te R2. I roto i te tukanga (spoiler) ka kitea e ahau he he.

Raparongoā

Hipanga 1. He aha te Gate1 ka whiwhi mai i a R1

Ka whakamahi ahau i te hongi putea kua hangaia - tcpdump. Ka whakarewahia e ahau te hongi i runga i te atanga o roto (Gi0/1 i roto i te tohu Cisco-rite ranei eth1 i roto i te tohu Debian OS):

root@Gate1:~# tcpdump -i eth1

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
14:53:38.879525 IP 172.16.0.1 > 172.17.0.1: GREv0, key=0x1, length 92: IP 1.1.1.1 > 1.1.1.2: ICMP echo request, id 2083, seq 1, length 64
14:53:39.896869 IP 172.16.0.1 > 172.17.0.1: GREv0, key=0x1, length 92: IP 1.1.1.1 > 1.1.1.2: ICMP echo request, id 2083, seq 2, length 64
14:53:40.921121 IP 172.16.0.1 > 172.17.0.1: GREv0, key=0x1, length 92: IP 1.1.1.1 > 1.1.1.2: ICMP echo request, id 2083, seq 3, length 64
14:53:41.944958 IP 172.16.0.1 > 172.17.0.1: GREv0, key=0x1, length 92: IP 1.1.1.1 > 1.1.1.2: ICMP echo request, id 2083, seq 4, length 64

Ka kite ahau ka whiwhi a Gate1 i nga paatete GRE mai i a R1. Kei te haere tonu ahau.

Hipanga 2. He aha te mahi a Gate1 ki nga paatete GRE

Ma te whakamahi i te whaipainga klogview ka kite au i nga mea e pa ana ki nga paatete GRE kei roto i te taraiwa S-Terra VPN:

root@Gate1:~# klogview -f 0xffffffff

filtration result for out packet 172.16.0.1->172.17.0.1, proto 47, len 112, if eth0: chain 4 "IPsecPolicy:CMAP", filter 8, event id IPsec:Protect:CMAP:1:LIST, status PASS
encapsulating with SA 31: 172.16.0.1->172.17.0.1, proto 47, len 112, if eth0
passed out packet 10.10.10.251->10.10.10.252, proto 50, len 160, if eth0: encapsulated

Ka kite ahau ko te mahinga GRE whainga (proto 47) 172.16.0.1 -> 172.17.0.1 i haere mai i raro i te ture whakamunatanga LIST i roto i te mahere crypto CMAP me te whakauru. I muri mai, ka tukuna te putea (kua pahemo). Kaore he hokohoko whakautu i roto i te putanga klogview.

Kei te tirotirohia e au nga rarangi uru ki te taputapu Gate1. Ka kite ahau i tetahi rarangi urunga RĀRANGI, e tautuhi ana i te hokohoko mo te whakamunatanga, ko te tikanga kaore i te whirihorahia nga ture paahi ahi:

Gate1#show access-lists
Extended IP access list LIST
    10 permit gre host 172.16.0.1 host 172.17.0.1

Whakamutunga: ko te raruraru ehara i te taputapu Gate1.

He korero ano mo klogview

Ko te taraiwa VPN te whakahaere i nga hokohoko whatunga katoa, kaua ko nga waka e tika ana kia whakamunatia. Ko enei nga karere ka kitea i roto i te klogview mena ka tukatukahia e te taraiwa VPN te hokohoko whatunga me te tuku kaore i whakamunatia:

root@R1:~# ping 172.17.0.1 -c 4

root@Gate1:~# klogview -f 0xffffffff

filtration result for out packet 172.16.0.1->172.17.0.1, proto 1, len 84, if eth0: chain 4 "IPsecPolicy:CMAP": no match
passed out packet 172.16.0.1->172.17.0.1, proto 1, len 84, if eth0: filtered

Ka kite ahau ko te hokohoko ICMP (proto 1) 172.16.0.1-> 172.17.0.1 kaore i whakauruhia (kaore he whakataetae) i roto i nga ture whakamunatanga o te kaari crypto CMAP. I tukuna (kua pahemo) te paakete i roto i nga tuhinga marama.

Hipanga 3. He aha te Gate2 ka whiwhi mai i te Gate1

Ka whakarewahia e ahau te hongi i runga i te atanga WAN (eth0) Gate2:

root@Gate2:~# tcpdump -i eth0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
16:05:45.104195 IP 10.10.10.251 > 10.10.10.252: ESP(spi=0x30088112,seq=0x1), length 140
16:05:46.093918 IP 10.10.10.251 > 10.10.10.252: ESP(spi=0x30088112,seq=0x2), length 140
16:05:47.117078 IP 10.10.10.251 > 10.10.10.252: ESP(spi=0x30088112,seq=0x3), length 140
16:05:48.141785 IP 10.10.10.251 > 10.10.10.252: ESP(spi=0x30088112,seq=0x4), length 140

Ka kite ahau ka whiwhi a Gate2 i nga paatete ESP mai i a Gate1.

Hipanga 4. He aha te mahi a Gate2 ki nga kohinga ESP

Ka whakarewahia e ahau te taputapu klogview i runga i te Gate2:

root@Gate2:~# klogview -f 0xffffffff
filtration result for in packet 10.10.10.251->10.10.10.252, proto 50, len 160, if eth0: chain 17 "FilterChain:L3VPN", filter 21, status DROP
dropped in packet 10.10.10.251->10.10.10.252, proto 50, len 160, if eth0: firewall

Ka kite ahau i tukuna nga paatete ESP (proto 50) (DROP) e te ture paahi ahi (L3VPN). Ka tino mohio ahau kei a Gi0/0 he rarangi uru L3VPN e piri ana ki a ia:

Gate2#show ip interface gi0/0
GigabitEthernet0/0 is up, line protocol is up
  Internet address is 10.10.10.252/24
  MTU is 1500 bytes
  Outgoing access list is not set
  Inbound  access list is L3VPN

I kitea e ahau te raru.

Hipanga 5. He aha te he ki te rārangi uru

Ka titiro ahau he aha te rarangi uru L3VPN:

Gate2#show access-list L3VPN
Extended IP access list L3VPN
    10 permit udp host 10.10.10.251 any eq isakmp
    20 permit udp host 10.10.10.251 any eq non500-isakmp
    30 permit icmp host 10.10.10.251 any

Ka kite ahau ka whakaaetia nga paatete ISAKMP, na reira kua whakaritea he kauhanga IPsec. Engari karekau he ture whakaahei mo te ESP. Ko te ahua, i poauau te tauira i te icmp me te esp.

Te whakatika i te rarangi uru:

Gate2(config)#
ip access-list extended L3VPN
no 30
30 permit esp host 10.10.10.251 any

Hipanga 6. Taki taumahinga

Tuatahi, ka whakarite ahau he tika te rarangi uru L3VPN:

Gate2#show access-list L3VPN
Extended IP access list L3VPN
    10 permit udp host 10.10.10.251 any eq isakmp
    20 permit udp host 10.10.10.251 any eq non500-isakmp
    30 permit esp host 10.10.10.251 any

Inaianei ka whakarewahia e ahau nga waka whainga mai i te taputapu R1:

root@R1:~# ping 1.1.1.2 -c 4
PING 1.1.1.2 (1.1.1.2) 56(84) bytes of data.
64 bytes from 1.1.1.2: icmp_seq=1 ttl=64 time=35.3 ms
64 bytes from 1.1.1.2: icmp_seq=2 ttl=64 time=3.01 ms
64 bytes from 1.1.1.2: icmp_seq=3 ttl=64 time=2.65 ms
64 bytes from 1.1.1.2: icmp_seq=4 ttl=64 time=2.87 ms

--- 1.1.1.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 2.650/10.970/35.338/14.069 ms

Te wikitoria. Kua whakaritea te kauhanga GRE. Ko te kaute hokohoko taumai i roto i nga tatauranga IPsec ehara i te kore:

root@Gate1:~# sa_mgr show
ISAKMP sessions: 0 initiated, 0 responded

ISAKMP connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) State Sent Rcvd
1 3 (10.10.10.251,500)-(10.10.10.252,500) active 1474 1350

IPsec connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) Protocol Action Type Sent Rcvd
1 4 (172.16.0.1,*)-(172.17.0.1,*) 47 ESP tunn 1920 480

I runga i te kuwaha Gate2, i roto i te putanga klogview, ka puta mai nga karere ko te waka whainga 172.16.0.1->172.17.0.1 i pai te wetemuna (PASS) e te ture LIST i te mahere crypto CMAP:

root@Gate2:~# klogview -f 0xffffffff
filtration result for in packet 172.16.0.1->172.17.0.1, proto 47, len 112, if eth0: chain 18 "IPsecPolicy:CMAP", filter 25, event id IPsec:Protect:CMAP:1:LIST, status PASS
passed in packet 172.16.0.1->172.17.0.1, proto 47, len 112, if eth0: decapsulated

Ngā putanga

Na tetahi tauira i takahi i tana ra whakatā.
Kia tupato ki nga ture ME.

Engineer ingoamuna
t.me/anonymous_engineer


Source: will.com

Tāpiri i te kōrero