This shows you the differences between two versions of the page.
pr:laboratoare:09 [2017/01/17 10:55] sergiu.costea |
pr:laboratoare:09 [2025/07/27 14:49] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~SHOWSOLUTION~~ | + | ===== Laboratorul 09. ===== |
- | + | ||
- | ===== Laboratorul 09. GRE și IPsec ===== | + | |
- | + | ||
- | ==== Topologie ==== | + | |
- | + | ||
- | {{ :pr:laboratoare:9_topologie.png |}} | + | |
- | + | ||
- | ==== Cerințe ==== | + | |
- | + | ||
- | === Setup === | + | |
- | <note important> Descărcați configurațiile inițiale de {{:pr:laboratoare:09_initial_configs.zip|aici}}. </note> | + | |
- | + | ||
- | === Exerciții === | + | |
- | <note info> | + | |
- | Toate configurațiile au fost încărcate pe rutere. Nu începeți taskurile acestui laborator fără să încărcați initial_configs. | + | |
- | </note> | + | |
- | + | ||
- | + | ||
- | ==== GRE ==== | + | |
- | + | ||
- | 1. [5p] Conectivitatea între Lucario și Machop a fost deja configurată folosind OSPF. Verificați faptul că Lucario poate da ping cu succes în Machop. | + | |
- | + | ||
- | 2. [10p] Configurați un tunel GRE între Lucario și Machop. Folosiți pentru sursă și destinație interfețele fizice. Pentru partea de adresare, folosiți adrese din rețeaua 192.168.0.0/30. | + | |
- | + | ||
- | 3. [10p] Folosind rute statice, configurați ca traficul între interfețele Lo1 ale lui Lucario și Machop să treacă prin tunelul GRE. Testați folosind ''traceroute''. | + | |
- | + | ||
- | <note hint> | + | |
- | Pentru testare, folosiți opțiunea ''source'' a comenzii ''traceroute''. | + | |
- | </note> | + | |
- | + | ||
- | <solution -hidden> | + | |
- | + | ||
- | Pe **Lucario**: | + | |
- | <code> | + | |
- | R1(config)#interface Tunnel 0 | + | |
- | *Jan 14 22:11:14.371: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0, changed state to down | + | |
- | R1(config-if)#tunnel destination 192.168.23.3 | + | |
- | R1(config-if)#tunnel source 192.168.12.1 | + | |
- | *Jan 14 22:11:44.219: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0, changed state to up | + | |
- | R1(config-if)#ip address 13.13.13.1 255.255.255.248 | + | |
- | R1(config-if)#exit | + | |
- | R1(config)#ip route 11.3.3.0 255.255.255.0 13.13.13.3 | + | |
- | </code> | + | |
- | + | ||
- | Pe **Machop**: | + | |
- | <code> | + | |
- | R3(config)#interface Tunnel 0 | + | |
- | R3(config-if)#tunnel source 192.168 | + | |
- | *Jan 14 22:12:27.599: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0, changed state to down | + | |
- | R3(config-if)#tunnel source 192.168.23.3 | + | |
- | R3(config-if)#tunnel destination 192.168.12.1 | + | |
- | *Jan 14 22:12:36.351: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0, changed state to up | + | |
- | R3(config-if)#ip address 13.13.13.3 255.255.255.248 | + | |
- | R3(config-if)#exit | + | |
- | R3(config)#ip route 11.1.1.0 255.255.255.0 13.13.13.1 | + | |
- | </code> | + | |
- | + | ||
- | If OSPF is running, the following commands are required to advertise the true loopback subnet masks (instead of the /32 masks): | + | |
- | + | ||
- | On **R1**: | + | |
- | <code> | + | |
- | R1(config)#interface Loopback 1 | + | |
- | R1(config-if)#ip ospf network point-to-point | + | |
- | R1(config-if)#exit | + | |
- | </code> | + | |
- | + | ||
- | On **R3**: | + | |
- | <code> | + | |
- | R3(config)#interface Loopback 1 | + | |
- | R3(config-if)#ip ospf network point-to-point | + | |
- | R3(config-if)#exit | + | |
- | </code> | + | |
- | + | ||
- | Test that traffic passes through the tunnel: | + | |
- | <code> | + | |
- | R1#traceroute 11.3.3.3 | + | |
- | Translating "11.3.3.3" | + | |
- | + | ||
- | Type escape sequence to abort. | + | |
- | Tracing the route to 11.3.3.3 | + | |
- | + | ||
- | 1 13.13.13.3 48 msec * 16 msec | + | |
- | </code> | + | |
- | + | ||
- | </solution> | + | |
- | + | ||
- | + | ||
- | ==== IPSec ==== | + | |
- | Dorim să criptăm traficul dintre Lo0 de pe Lucario și Lo0 de pe Machop. Vom configura un tunel IPsec între cele două rutere. | + | |
- | + | ||
- | 4. [15p] Configurați următoarea politică ISAKMP pe Lucario și Machop: | + | |
- | * autentificare: pre-shared keys | + | |
- | * criptare: aes 256 | + | |
- | * hash: sha1 | + | |
- | * grup diffie-hellman: 2 | + | |
- | * lifetime: 3600 | + | |
- | + | ||
- | <solution -hidden> | + | |
- | Pe **Lucario**: | + | |
- | <code> | + | |
- | Lucario(config)#crypto isakmp policy 1 | + | |
- | Lucario(config-isakmp)#authentication pre-share | + | |
- | Lucario(config-isakmp)#encryption aes 256 | + | |
- | Lucario(config-isakmp)#hash sha | + | |
- | Lucario(config-isakmp)#group 2 | + | |
- | Lucario(config-isakmp)#lifetime 3600 | + | |
- | Lucario(config-isakmp)#exit | + | |
- | </code> | + | |
- | + | ||
- | Pe **Machop**: | + | |
- | <code> | + | |
- | Machop(config)#crypto isakmp policy 1 | + | |
- | Machop(config-isakmp)#authentication pre-share | + | |
- | Machop(config-isakmp)#encryption aes 256 | + | |
- | Machop(config-isakmp)#hash sha | + | |
- | Machop(config-isakmp)#group 2 | + | |
- | Machop(config-isakmp)#lifetime 3600 | + | |
- | Machop(config-isakmp)#exit | + | |
- | </code> | + | |
- | </solution> | + | |
- | + | ||
- | 5. [10p] Configurați 'prrulz' ca pre-shared key pe Lucario și Machop. | + | |
- | + | ||
- | <solution -hidden> | + | |
- | + | ||
- | Pe **Lucario**: | + | |
- | <code> | + | |
- | Lucario(config)#crypto isakmp key 0 prrulz address 191.105.157.2 | + | |
- | </code> | + | |
- | + | ||
- | Pe **Machop**: | + | |
- | <code> | + | |
- | Machop(config)#crypto isakmp key 0 prrulz address 66.218.168.5 | + | |
- | </code> | + | |
- | + | ||
- | </solution> | + | |
- | + | ||
- | 6. [10p] Configurați următorul transform set pe Lucario și Machop: | + | |
- | * Nume: TS_PR | + | |
- | * Transform set: esp-aes 256 esp-sha-hmac | + | |
- | * Mod: tunel | + | |
- | + | ||
- | <solution -hidden> | + | |
- | + | ||
- | Pe **Lucario**: | + | |
- | <code> | + | |
- | Lucario(config)#crypto ipsec transform-set TS_PR esp-aes 256 esp-sha-hmac | + | |
- | Lucario(cfg-crypto-trans)#mode tunnel | + | |
- | Lucario(cfg-crypto-trans)#exit | + | |
- | </code> | + | |
- | + | ||
- | Pe **Machop**: | + | |
- | <code> | + | |
- | Machop(config)#crypto ipsec transform-set TS_PR esp-aes 256 esp-sha-hmac | + | |
- | Machop(cfg-crypto-trans)#mode tunnel | + | |
- | Machop(cfg-crypto-trans)#exit | + | |
- | </code> | + | |
- | + | ||
- | </solution> | + | |
- | + | ||
- | 7. [20p] Creați câte un ACL pe Lucario și Machop care să facă match pe traficul ce urmează să fie criptat (traficul dintre Lo0 Lucario - Lo0 Machop). | + | |
- | + | ||
- | <solution -hidden> | + | |
- | Pe **Lucario**: | + | |
- | <code> | + | |
- | Lucario(config)#ip access-list extended INTERESTING | + | |
- | Lucario(config-ext-nacl)#permit ip host 10.10.10.1 host 20.20.20.1 | + | |
- | Lucario(config-ext-nacl)#exit | + | |
- | </code> | + | |
- | + | ||
- | Pe **Machop**: | + | |
- | <code> | + | |
- | Machop(config)#ip access-list extended INTERESTING | + | |
- | Machop(config-ext-nacl)#permit ip host 20.20.20.1 host 10.10.10.1 | + | |
- | Machop(config-ext-nacl)#exit | + | |
- | </code> | + | |
- | + | ||
- | </solution> | + | |
- | + | ||
- | 8. [10p] Creați un crypto map pe Lucario și Machop. Aveți în vedere următoarele aspecte: | + | |
- | * crypto map-ul trebuie să selecteze traficul conform ACL-ului | + | |
- | * folosiți interfețele fizice drept capetele tunelului IPsec | + | |
- | * folosiți transform set-ul configurat anterior | + | |
- | + | ||
- | Aplicați crypto map-ul pe interfețele fizice de pe Lucario și Machop. | + | |
- | + | ||
- | <solution -hidden> | + | |
- | Pe **Lucario**: | + | |
- | <code> | + | |
- | Lucario(config)#crypto map TUNNEL_MAP 10 ipsec-isakmp | + | |
- | % NOTE: This new crypto map will remain disabled until a peer | + | |
- | and a valid access list have been configured. | + | |
- | Lucario(config-crypto-map)#set peer 191.105.157.2 | + | |
- | Lucario(config-crypto-map)#match address INTERESTING | + | |
- | Lucario(config-crypto-map)#set transform-set TS_PR | + | |
- | Lucario(config-crypto-map)#exit | + | |
- | Lucario(config)#int fa 2/0 | + | |
- | Lucario(config-if)#crypto map TUNNEL_MAP | + | |
- | Lucario(config-if)# | + | |
- | *Mar 1 00:22:02.835: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON | + | |
- | Lucario(config-if)#exit | + | |
- | </code> | + | |
- | + | ||
- | Pe **Machop**: | + | |
- | <code> | + | |
- | Machop(config)#crypto map TUNNEL_MAP 10 ipsec-isakmp | + | |
- | % NOTE: This new crypto map will remain disabled until a peer | + | |
- | and a valid access list have been configured. | + | |
- | Machop(config-crypto-map)#set peer 66.218.168.5 | + | |
- | Machop(config-crypto-map)#match address INTERESTING | + | |
- | Machop(config-crypto-map)#set transform-set TS_PR | + | |
- | Machop(config-crypto-map)#exit | + | |
- | Machop(config)#int fa1/0 | + | |
- | Machop(config-if)#crypto map TUNNEL_MAP | + | |
- | Machop(config-if)# | + | |
- | *Mar 1 00:22:15.719: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON | + | |
- | Machop(config-if)#exit | + | |
- | </code> | + | |
- | + | ||
- | </solution> | + | |
- | + | ||
- | + | ||
- | 9. [10p] Testați tunelul generând trafic între Lo0 de pe Lucario și Lo0 de pe Machop. Afișați SA-urile create și verificați incrementarea contoarelor de trafic. | + | |
- | <note important> | + | |
- | Pentru ca acest exercițiu să funcționeze trebuie adăugate și niște rute. Pe ce rutere și de ce? | + | |
- | </note> | + | |
- | + | ||
- | <hidden> | + | |
- | Lucario și Machop nu știu de Lo0 al celuilalt, deci traficul generat nu va fi rutat. Trebuie pusă câte o rută statică pe Lucario și pe Machop. Blastoise nu trebuie să știe de aceste rețele deoarece IPsec lucrează în tunnel mode. | + | |
- | </hidden> | + | |
- | + | ||
- | <solution -hidden> | + | |
- | + | ||
- | Ne lipsesc niște rute: | + | |
- | <code> | + | |
- | Lucario(config)#ip route 20.20.20.1 255.255.255.255 66.218.168.6 | + | |
- | </code> | + | |
- | + | ||
- | <code> | + | |
- | Machop(config)#ip route 10.10.10.1 255.255.255.255 191.105.157.1 | + | |
- | </code> | + | |
- | + | ||
- | <code> | + | |
- | Lucario#ping 20.20.20.1 source 10.10.10.1 | + | |
- | + | ||
- | Type escape sequence to abort. | + | |
- | Sending 5, 100-byte ICMP Echos to 20.20.20.1, timeout is 2 seconds: | + | |
- | Packet sent with a source address of 10.10.10.1 | + | |
- | .!!!! | + | |
- | Success rate is 80 percent (4/5), round-trip min/avg/max = 36/45/52 ms | + | |
- | + | ||
- | </code> | + | |
- | + | ||
- | <code> | + | |
- | R3(config-if)#crypto map TUNNEL_MAP | + | |
- | R3 | + | |
- | Construct an access-list that will match the traffic that you want to encrypt. | + | |
- | * The access-list will have to define both the source and the destination of the traffic. | + | |
- | * An access-list must be defined on both R1 and R3. | + | |
- | * Watch out for the fact that the 2 ACLs must mirror each other. | + | |
- | * The access-list can match all IP traffic(config-if)# | + | |
- | *Jan 14 20:24:31.351: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON | + | |
- | R3(config-if)#exit | + | |
- | </code> | + | |
- | + | ||
- | Create traffic to start tunnel setup: | + | |
- | <code> | + | |
- | R1#ping 10.3.3.3 source 10.1.1.1 | + | |
- | Translating "10.3.3.3" | + | |
- | + | ||
- | Type escape sequence to abort. | + | |
- | Sending 5, 100-byte ICMP Echos to 10.3.3.3, timeout is 2 seconds: | + | |
- | Packet sent with a source address of 10.1.1.1 | + | |
- | .!!!! | + | |
- | Success rate is 80 percent (4/5), round-trip min/avg/max = 12/14/20 ms | + | |
- | </code> | + | |
- | + | ||
- | Check security associations: | + | |
- | <code> | + | |
- | R1#show crypto isakmp sa | + | |
- | IPv4 Crypto ISAKMP SA | + | |
- | dst src state conn-id slot status | + | |
- | 192.168.23.3 192.168.12.1 QM_IDLE 1001 0 ACTIVE | + | |
- | + | ||
- | IPv6 Crypto ISAKMP SA | + | |
- | + | ||
- | R1#show crypto ipsec sa | + | |
- | + | ||
- | interface: FastEthernet0/0 | + | |
- | Crypto map tag: TUNNEL_MAP, local addr 192.168.12.1 | + | |
- | + | ||
- | protected vrf: (none) | + | |
- | local ident (addr/mask/prot/port): (10.1.1.1/255.255.255.255/0/0) | + | |
- | remote ident (addr/mask/prot/port): (10.3.3.3/255.255.255.255/0/0) | + | |
- | current_peer 192.168.23.3 port 500 | + | |
- | PERMIT, flags={origin_is_acl,} | + | |
- | #pkts encaps: 4, #pkts encrypt: 4, #pkts digest: 4 | + | |
- | #pkts decaps: 4, #pkts decrypt: 4, #pkts verify: 4 | + | |
- | #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.: 192.168.12.1, remote crypto endpt.: 192.168.23.3 | + | |
- | path mtu 1500, ip mtu 1500, ip mtu idb FastEthernet0/0 | + | |
- | current outbound spi: 0xD480DB37(3565214519) | + | |
- | + | ||
- | inbound esp sas: | + | |
- | spi: 0xB3825B11(3011664657) | + | |
- | transform: esp-256-aes esp-sha-hmac , | + | |
- | in use settings ={Tunnel, } | + | |
- | conn id: 1, flow_id: SW:1, crypto map: TUNNEL_MAP | + | |
- | sa timing: remaining key lifetime (k/sec): (4558528/3557) | + | |
- | IV size: 16 bytes | + | |
- | replay detection support: Y | + | |
- | Status: ACTIVE | + | |
- | + | ||
- | inbound ah sas: | + | |
- | + | ||
- | inbound pcp sas: | + | |
- | + | ||
- | outbound esp sas: | + | |
- | spi: 0xD480DB37(3565214519) | + | |
- | transform: esp-256-aes esp-sha-hmac , | + | |
- | in use settings ={Tunnel, } | + | |
- | conn id: 2, flow_id: SW:2, crypto map: TUNNEL_MAP | + | |
- | sa timing: remaining key lifetime (k/sec): (4558528/3555) | + | |
- | IV size: 16 bytes | + | |
- | replay detection support: Y | + | |
- | Status: ACTIVE | + | |
- | + | ||
- | outbound ah sas: | + | |
- | + | ||
- | outbound pcp sas: | + | |
- | </code> | + | |
- | + | ||
- | + | ||
- | </solution> | + | |
- | + | ||
- | 10. [10p] Folosind Wireshark, interceptați traficul criptat dintre Lucario și Machop. | + | |
- | + | ||
- | <note hint> | + | |
- | * Folosiți comanda ''capture'' din consola **dynagen** pentru a porni o captură | + | |
- | * Generați trafic ce trece prin tunel | + | |
- | * Opriți captura de trafic din consola dynagen | + | |
- | * Deschideți fișierul de captură rezultat folosind Wireshark | + | |
- | </note> | + | |