Az internetes fórumok szerint nem csak nekem, hanem másoknak is elég “confusing” topik a PPP authentikáció. Megpróbálom kicsit kitisztázni, hogyan működik a PAP, illetve a CHAP.
Topológia:
1. PAP
- Password Authentication Protocol
- Clear text-ben küldi el a felhasználónevet/jelszót
- Nem kötelező mindkét oldalon hitelesíteni. Lehetséges, hogy csak az egyik oldal hitelesíti a másikat, és így felépül a PPP kapcsolat.
- A hitelesítést a LCP végzi (ez igaz a CHAP-nál is)
- Könnyebb megérteni, ha szerverként és kliensként gondolunk a routerekre. A “szerver” authentikálja a “klienst”
- Működése:
- Az authentikációt végző routeren bekapcsoljuk a ppp authentikációt. Ez az oldal vár a másik oldalra, tehát nem kezdeményez hitelesítést.
- A kliens oldalon bekapcsoljuk a pap hitelesítést, és az interface-n beállítjuk, milyen felhasználónév/jelszó párossal akarjuk hitelesíteni magunkat.
- A szerver oldal a lokális adatbázis alapján (vagy AAA alapján) hitelesít/visszautasít.
Nézzük a gyakorlatban. R1 fogja hitelesíteni R2-t.
Alap konfiguráció, hitelesítés nélkül:
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int s0/0
R1(config-if)#ip add 12.0.0.1 255.255.255.0
R1(config-if)#encap ppp
R1(config-if)#no shut
R1(config-if)#^Z
R1#
*Mar 1 00:13:48.203: %SYS-5-CONFIG_I: Configured from console by console
R1#
*Mar 1 00:13:49.903: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R1#
*Mar 1 00:14:03.083: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1#
R2#
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int s0/0
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#encap ppp
R2(config-if)#no shut
R2(config-if)#^Z
R2#
*Mar 1 00:14:15.039: %SYS-5-CONFIG_I: Configured from console by console
R2#
*Mar 1 00:14:15.711: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R2#
*Mar 1 00:14:16.751: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R2#
Tehát amit tennünk kell:
– R1-en létrehozunk egy R2 usert CISCO jelszóval
– R1-et beállítjuk hitelesítő szerverként
– R2 lesz a kliens, amely authentikálja magát
R1:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#username R2 password cisco !!! R2 adatai !!!!
R1(config)#int s0/0
R1(config-if)#ppp authentication pap !!! "Szerver" mód, én hitelesítek !!!
R1(config-if)#^Z
R1#
R1#
*Mar 1 00:16:25.731: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
*Mar 1 00:16:26.507: %SYS-5-CONFIG_I: Configured from console by console
R1#
R1#
A line protocol leesett, mert a másik oldal nem hitelesíti magát még.
R1#
R1#debug ppp auth
PPP authentication debugging is on
R1#
*Mar 1 00:18:24.055: Se0/0 PPP: Authorization required
R1#
*Mar 1 00:18:26.151: Se0/0 PPP: Authorization required
R1#
*Mar 1 00:18:28.155: Se0/0 PPP: Authorization required
R1#
*Mar 1 00:18:30.163: Se0/0 PPP: Authorization required
R1#
Konfiguráljuk fel, de közben bekapcsolva hagyom a debug-ot R1-n, hogy lássuk, mi történik.
R2#sh run int s0/0
Building configuration...
Current configuration : 154 bytes
!
interface Serial0/0
ip address 12.0.0.2 255.255.255.0
encapsulation ppp
shutdown
clock rate 2000000
ppp pap sent-username R2 password 0 cisco !!! Hitelesítő adatok, amiket küldök !!!!
end
R2#
Debug:
R1#debug ppp auth
PPP authentication debugging is on
R1#
*Mar 1 00:28:02.535: Se0/0 PPP: Authorization required
*Mar 1 00:28:02.543: Se0/0 PAP: I AUTH-REQ id 129 len 13 from "R2" !!! R2 névvel próbál hitelesíteni valaki. I az inbound, O az outbound a debug-ban !!!
*Mar 1 00:28:02.547: Se0/0 PAP: Authenticating peer R2
*Mar 1 00:28:02.551: Se0/0 PPP: Sent PAP LOGIN Request !!! Hitelesítsd magad !!!
*Mar 1 00:28:02.559: Se0/0 PPP: Received LOGIN Response PASS !!! Hitelesítette magát !!!
*Mar 1 00:28:02.563: Se0/0 PPP: Sent LCP AUTHOR Request
*Mar 1 00:28:02.567: Se0/0 PPP: Sent IPCP AUTHOR Request
*Mar 1 00:28:02.575: Se0/0 LCP: Received AAA AUTHOR Response PASS
*Mar 1 00:28:02.575: Se0/0 IPCP: Received AAA AUTHOR Response PASS
*Mar 1 00:28:02.579: Se0/0 PAP: O AUTH-ACK id 129 len 5
*Mar 1 00:28:02.583: Se0/0 PPP: Sent CDPCP AUTHOR Request
R1#
*Mar 1 00:28:02.591: Se0/0 CDPCP: Received AAA AUTHOR Response PASS
*Mar 1 00:28:02.599: Se0/0 PPP: Sent IPCP AUTHOR Request
R1#
Sikeres! Pingeljünk át R2 felé R1-ről:
R1#ping 12.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/12/28 ms
R1#
Ugyan nem a hitelesítéshez tartozik, de van a PPP-nek egy tulajdonsága. Nézzük meg a route táblát:
R1#sh ip route | i 0/0
C 12.0.0.0/24 is directly connected, Serial0/0
C 12.0.0.2/32 is directly connected, Serial0/0
R1#
A PPP egy host route-t is átküld a szomszédnak. Ezt jó észben tartani!
2. CHAP
- Challange-Handshare Authentication Protocol
- Működése:
Nézzük a gyakorlatban. A magyarázó rajzon R1 hitelesíti R2-t, de én most fordítva csinálom.
R1#sh run | i username
username R2 password 0 cisco !!! R2 hitelesítő adatai R1-n !!!
R2#sh run | i username
username R1 password 0 cisco !!! R1 hitelesítő adatai R2-n !!!
R2 (authentikálja R1-t):
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int s0/0
R2(config-if)#ppp authentication chap
R2(config-if)#
R1#
interface Serial0/0
end
R1#
Debug:
R2#debug ppp auth
PPP authentication debugging is on
R2#
*Mar 1 00:51:59.275: Se0/0 PPP: Authorization required
*Mar 1 00:51:59.315: Se0/0 CHAP: O CHALLENGE id 2 len 23 from "R2" !!! R1, hitelesítsd magad !!!
*Mar 1 00:51:59.331: Se0/0 CHAP: I CHALLENGE id 1 len 23 from "R1"
*Mar 1 00:51:59.335: Se0/0 CHAP: I RESPONSE id 2 len 23 from "R1" !!! R1 vagyok, és hitelesítem magam !!!
*Mar 1 00:51:59.343: Se0/0 PPP: Sent CHAP LOGIN Request
*Mar 1 00:51:59.347: Se0/0 CHAP: Using hostname from unknown source
*Mar 1 00:51:59.347: Se0/0 CHAP: Using password from AAA
*Mar 1 00:51:59.347: Se0/0 CHAP: O RESPONSE id 1 len 23 from "R2"
*Mar 1 00:51:59.359: Se0/0 PPP: Received LOGIN Response PASS !!! Hitelesítve !!!
*Mar 1 00:51:59.363: Se0/0 PPP: Sent LCP AUTHOR Request
R2#
*Mar 1 00:51:59.367: Se0/0 PPP: Sent IPCP AUTHOR Request
*Mar 1 00:51:59.371: Se0/0 LCP: Received AAA AUTHOR Response PASS
*Mar 1 00:51:59.375: Se0/0 IPCP: Received AAA AUTHOR Response PASS
*Mar 1 00:51:59.375: Se0/0 CHAP: O SUCCESS id 2 len 4
*Mar 1 00:51:59.379: Se0/0 CHAP: I SUCCESS id 1 len 4
*Mar 1 00:51:59.383: Se0/0 PPP: Sent CDPCP AUTHOR Request
*Mar 1 00:51:59.391: Se0/0 PPP: Sent IPCP AUTHOR Request
*Mar 1 00:51:59.399: Se0/0 CDPCP: Received AAA AUTHOR Response PASS
R2#
*Mar 1 00:52:00.379: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R2#
A PAP és CHAP hitelesítés kombinálható, azaz lehetséges, hogy R1 PAP-pal hitelesíti R2-t, R2 pedig CHAP-pal R1-t.
Egyéb:
- CHAP-nál van 2 interface szintű parancs: ppp chap hostname és ppp chap password. Ezekkel tudjuk beállítani, hogy milyen hitelesítő adatokat KÜLDÜNK a bejövő hitelesítési kérésre. Minden kérésre forrástól függetlenül ezeket válaszolja a router.