Lab Configuring Site-to-Site IPsec VPNs with the IOS CLI by GNS3
ช่วงนี้หลังจากหยุดงานมาหลายวันเพราะเสื้อแดงมาชุมนมหน้าที่ทำงาน เลยมีเวลาว่างๆมาเขียนลองมั่วๆกับ GNS3 กับ LAB CCNP ISCW หน่อยหนึ่ง
Topology Diagram
ในแล็บนี้เราจะ config site-to-site IPsec VPN Traffic ระหว่าง R1 และ R3
ข้อมูลต่างๆ
1.ใช้ graphical network simulator (GNS3 0.7) ในการทำ LAB ข้อมูลของ GNS3 เพิ่มเติมที่ http://www.gns3.net/
2.ในการทำ LAB นี้ Emulation Cisco Router โดยใช้ตัว 2961 IOS: c2691-adventerprisek9-mz.124-15.T12.bin
3.LAB นี้ผมได้ลองมั่วทำตามของเอกสารLAB CCNP: Implementing Secure Converged Wide-area Networks v5.0 - Lab 3-5
เรามาเริ่มจัดเตรียมจะทำ Lab กันเลย เปิดโปรแกรม GNS3 ขึ้นมาเลยลาก Router 2691 ใน GNS3 มา 3 ตัวมาวางบน workspace ได้เป็น R1, R2, R3 อย่างที่บอกไปด้วนบนนะครับผมใช้ cisco2691 ผมเซตไว้ตามนั้นครับ
เราก็มาใส่ interface ต่างๆให้กับตัว router ให้คล้ายเป็นไปตาม Topology Diagram ด้านบน โดยคลิกขวาที่ตัว router เลือก configure
ที่ R1 ปกติของ 2961 ใน GNS3 มี fastethernet มาสอง port อยู่แล้วไม่จำเป็นต้องใส่อะไรเพิ่มใน LAB นี้
ที่ R2 เราก็ใส่ interface serial เพิ่มไปตามรูป
ส่วนที่ R3 ก็เช่นกัน ใส่ interface serial เพิ่มเข้าไป
เสร็จแล้วเราก็มาลากสายต่อ router เข้าด้วยกันตาม Topology Diagram ครับ
เสร็จแล้วๆ เราก็กดรัน router ทั้งสามตัวที่ปุ่มเขียวๆ เปิด consol ของ router กดที่ปุ่มรูปหน้าจอคอมสีดำๆ หรือจะคลิกขวาที่ router เลือก console เอาก็ได้ครับ โดยค่า default ของโปรแกรม GNS3 แล้วจะเป็น putty ครับตามรูปครับ
ซึ่งผมโดยส่วนตัวไม่ค่อยชอบเท่าไร ชอบใช้ secureCRT มากกว่า ใครอยากใช้ secureCRT เป็น console ของ GNS3 ก็หาวิธีได้จาก google
เมื่อ router รันเสร็จพร้อมใช้งานทุกตัวแล้วเราก็น่าเช็คสักหน่อยว่า interface ของ router แต่ล่ะตัวมีอะไรบ้างและถูกตามที่ Topology Diagram หรือเปล่า เพราะ interface ของ router เราไม่สามรถทำให้เหมือนตาม Topology Diagram ได้ทั้งหมดดูไว้จะได้ config ถูก interface
ที่R1
R1#sh ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/0 unassigned YES unset administratively down down FastEthernet0/1 unassigned YES unset administratively down down R1#
ที่R2
R2#sh ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/0 unassigned YES unset administratively down down FastEthernet0/1 unassigned YES unset administratively down down Serial1/0 unassigned YES unset administratively down down Serial1/1 unassigned YES unset administratively down down Serial1/2 unassigned YES unset administratively down down Serial1/3 unassigned YES unset administratively down down R2#
ที่R3
R3#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/0 unassigned YES unset administratively down down FastEthernet0/1 unassigned YES unset administratively down down Serial1/0 unassigned YES unset administratively down down Serial1/1 unassigned YES unset administratively down down Serial1/2 unassigned YES unset administratively down down Serial1/3 unassigned YES unset administratively down down R3#เอาล่ะครับเมื่อเตรียม GNS3 เสร็จแล้ว ก็มาเริ่ม Configuring Site-to-Site IPsec VPNs กัน
Step 1: Configure Addressing
ใส่ IP ต่างๆตาม Topology Diagram กับเปลี่ยน hostname หน่อยเพื่อกันไม่ให้เราสับสน ครับเริ่มที่ R1 ก่อน
ที่ R1
Router(config)#hostname R1 R1(config)# interface loopback0 R1(config-if)# ip address 172.16.1.1 255.255.255.0 R1(config-if)# interface fastethernet0/0 R1(config-if)# ip address 192.168.12.1 255.255.255.0 R1(config-if)# no shutdown
ที่ R2
Router(config)#hostname R2 R2(config)# interface fastethernet0/0 R2(config-if)# ip address 192.168.12.2 255.255.255.0 R2(config-if)# no shutdown R2(config-if)# interface serial1/0 R2(config-if)# ip address 192.168.23.2 255.255.255.0 R2(config-if)# clockrate 64000 R2(config-if)# no shutdown
ที่ R3
Router(config)#hostname R3 R3(config)# interface loopback0 R3(config-if)# ip address 172.16.3.1 255.255.255.0 R3(config-if)# interface serial1/0 R3(config-if)# ip address 192.168.23.3 255.255.255.0 R3(config-if)# no shutdown
เพื่อความแน่ใจก็ ping ใน local subnets เดียวกันว่าได้หรือเปล่า
Step 2: Configure EIGRP
ใช้ EIGRP เพื่อเชื่อมต่อระหว่างเครือข่าย
ที่ R1
R1(config)# router eigrp 1 R1(config-router)# no auto-summary R1(config-router)# network 172.16.0.0 R1(config-router)# network 192.168.12.0
ที่ R2
R2(config)# router eigrp 1 R2(config-router)# no auto-summary R2(config-router)# network 192.168.12.0 R2(config-router)# network 192.168.23.0
ที่ R3
R3(config)# router eigrp 1 R3(config-router)# no auto-summary R3(config-router)# network 172.16.0.0 R3(config-router)# network 192.168.23.0แล้วเราก็ตรวจเช็ค connectivity ต่างโดย ping IP เหล่านี้ได้หมดก็โอเคครับ
172.16.1.1
192.168.12.1
192.168.12.2
192.168.23.2
172.16.3.1
192.168.23.3
Step 3: Create IKE Policies
โดยปกติแล้ว IKE จะถูก enabled default บน IOS images ที่รอง cryptographic feature อยู่แล้วครับ แต่บางครั้งอาจจะถูกปิดไปโดยเหตุผลอื่นก็เป็นไปได้เราสามารถ enable โดยใช้ command crypto isakmp enable เช่น
R1(config)# crypto isakmp enable
พิเศษนิดหน่อยถ้าใช้ command crypto isakmp enable ไม่ได้แสดงว่า IOS ของ router ที่ใช้มันไม่รองรับครับ
ใช้บ่ได้เน้อ
มา config IKE Phase 1 ที่เป็น Internet Security Association and Key Management Protocol (ISAKMP)
ที่ global configuration ใช้คำสั่ง crypto isakmp policy {number} ตามด้านล่าง
R1(config)#crypto isakmp policy 10 R1(config-isakmp)#
ใน (config-isakmp) นี้เราต้องกำหนดการ Authentication, การ Encryption และ Algorithm และอะไรต่าง
อันนี้ผมไม่ไม่ค่อยรู้เท่าไร เพราะผมไม่มีปัญญาไปสอบ CCNA เลยนี้ระดับ CCNP แล้วผมมั่วเอาครับ สรุปว่าถ้าตามเอกสาร LAB จะเป็นตามนี้ครับ เป็นค่ายอดฮิตผมเห็นที่ไหนๆก็ config แต่แบบนี้ ไปซะหมด
Authentication type pre-shared keys
Encryption เป็น AES 256
Algorithm เป็น SHA
Diffie-Hellman group 5
Config ก็ตามด้านล่าง
ที่ R1
R1(config)# crypto isakmp policy 10 R1(config-isakmp)# authentication pre-share R1(config-isakmp)# encryption aes 256 R1(config-isakmp)# hash sha R1(config-isakmp)# group 5 R1(config-isakmp)# lifetime 3600
ที่R3
R3(config)# crypto isakmp policy 10 R3(config-isakmp)# authentication pre-share R3(config-isakmp)# encryption aes 256 R3(config-isakmp)# hash sha R3(config-isakmp)# group 5 R3(config-isakmp)# lifetime 3600
โดยใน LAB นี้เราจะทำ Site-to-Site IPsec VPNs ระหว่าง R1 และ R3 เราก็ควร Config ไปพร้อมๆกันดีกว่าครับจะได้ไม่งง เดี่ยวไป config ตามที่หลังจะลืมว่าใช้ค่าเป็นเท่าไร เพราะ config แทบที่จะเหมือนกันเลยทั้งสอง router
เสร็จแล้วให้ออกมาก่อน เราสามารถตรวจ IKE policy โดยใช้คำสั่ง show crypto isakmp policy
R1#sh crypto isakmp policy
Global IKE policy Protection suite of priority 10 encryption algorithm: AES - Advanced Encryption Standard (256 bit keys). hash algorithm: Secure Hash Standard authentication method: Pre-Shared Key Diffie-Hellman group: #5 (1536 bit) lifetime: 3600 seconds, no volume limit Default protection suite encryption algorithm: DES - Data Encryption Standard (56 bit keys). hash algorithm: Secure Hash Standard authentication method: Rivest-Shamir-Adleman Signature Diffie-Hellman group: #1 (768 bit) lifetime: 86400 seconds, no volume limit R1#
R3#sh crypto isakmp policy
Global IKE policy Protection suite of priority 10 encryption algorithm: AES - Advanced Encryption Standard (256 bit keys). hash algorithm: Secure Hash Standard authentication method: Pre-Shared Key Diffie-Hellman group: #5 (1536 bit) lifetime: 3600 seconds, no volume limit Default protection suite encryption algorithm: DES - Data Encryption Standard (56 bit keys). hash algorithm: Secure Hash Standard authentication method: Rivest-Shamir-Adleman Signature Diffie-Hellman group: #1 (768 bit) lifetime: 86400 seconds, no volume limit R3#
Step 4: Configure Pre-Shared Keys
จากในที่เรา config IKE policy เราใช้การ Authentication type เป็นแบบ Pre-Shared Keys
กลับมาที่โหมด global configuration ใช้ Command
crypto isakmp key key-string address address
ใส่ pre-shared key ที่ต้องการ ตาม LAB เป็น “cisco” ใส่ IP address ของ router remote peer ที่จะทำ VPN ด้วย
ได้เป็นแบบนี้ครับ
R1(config)# crypto isakmp key cisco address 192.168.23.3
R3(config)# crypto isakmp key cisco address 192.168.12.1
Step 5: Configure the IPsec Transform Set and Lifetimes
The IPsec transform เป็นค่าพารามิเตอร์ crypto ที่เราเตอร์เอาไว้คุยกัน เพื่อสร้างความสัมพันธ์ด้านความปลอดภัย ถ้าในความคิดของน่าจะเอาไว้ใช้ในการ Encrypt ในการส่งข้อมูลนะ มั่วเอา
สร้างโดยใช้ syntax แบบนี้ครับ จากใน router
R1(config)#crypto ipsec transform-set ? WORD Transform set tag
หลัง set เราก็ใส่ชื่อของ Transform Set ครับ ผมใส่ 50 ตามใน Lab
R1(config)#crypto ipsec transform-set 50 ? ah-md5-hmac AH-HMAC-MD5 transform ah-sha-hmac AH-HMAC-SHA transform comp-lzs IP Compression using the LZS compression algorithm esp-3des ESP transform using 3DES(EDE) cipher (168 bits) esp-aes ESP transform using AES cipher esp-des ESP transform using DES cipher (56 bits) esp-md5-hmac ESP transform using HMAC-MD5 auth esp-null ESP transform w/o cipher esp-seal ESP transform using SEAL cipher (160 bits) esp-sha-hmac ESP transform using HMAC-SHA auth
เลือก Encrypt แบบ esp-aes แล้วกัน
R1(config)#crypto ipsec transform-set 50 esp-aes ? 128 128 bit keys. 192 192 bit keys. 256 256 bit keys. ah-md5-hmac AH-HMAC-MD5 transform ah-sha-hmac AH-HMAC-SHA transform comp-lzs IP Compression using the LZS compression algorithm esp-md5-hmac ESP transform using HMAC-MD5 auth esp-sha-hmac ESP transform using HMAC-SHA auth <cr>
เลือกใช้แบบ 256 bit
R1(config)#crypto ipsec transform-set 50 esp-aes 256 ? ah-md5-hmac AH-HMAC-MD5 transform ah-sha-hmac AH-HMAC-SHA transform comp-lzs IP Compression using the LZS compression algorithm esp-md5-hmac ESP transform using HMAC-MD5 auth esp-sha-hmac ESP transform using HMAC-SHA auth
เลิอก esp-sha-hmac ต่อครับ หลังๆนี้ไม่เข้าใส่ว่ามันคืออะไรหนักหนาเอาให้ปลอดภัยสุดๆแล้ว ทพตามเอกสาร Lab ไป
R1(config)#crypto ipsec transform-set 50 esp-aes 256 esp-sha-hmac ? ah-md5-hmac AH-HMAC-MD5 transform ah-sha-hmac AH-HMAC-SHA transform comp-lzs IP Compression using the LZS compression algorithm
เลือก ah-sha-hmac จบครับ config แล้วก็ exit ออกมา อย่าลืมใส่ที่ R3 ด้วยนะครับ
R1(config)# crypto ipsec transform-set 50 esp-aes 256 esp-sha-hmac ah-sha-hmac R1(cfg-crypto-trans)# exit R1(config) R3(config)# crypto ipsec transform-set 50 esp-aes 256 esp-sha-hmac ah-sha-hmac R3(cfg-crypto-trans)# exit R3(config)#
ต่อก็เป็นค่าของ IPsec security association lifetimes โดยค่า default 3600 seconds หรือ 4,608,000 kilobytes ตามเอกสาร LAB ใช้ 1800 seconds ครับ
R1(config)# crypto ipsec security-association lifetime seconds 1800 R3(config)# crypto ipsec security-association lifetime seconds 1800
Step 6: Define Interesting Traffic
พอมาถึงตรงนี้แล้วผมก็เริ่มมั่วๆเอาซะจริง เป็นตั้งแต่ step ที่ผ่านมาแล้วก็ว่าได้ครับ แต่เท่าที่ผมเคยเจอนะค่าต่างๆพวกนี้มันก็แล้วว่าจะตกลงมาจะใช้เป็นอะไรกันบ้าง ใช้ให้เหมือนกันทั้งสองฝั่งที่จะทำ VPN หากันก็พอแล้วครับ ความหมายของมันก็ลองหาใน อาgoogleดู
พอถึงขั้นตอนนี้แล้วสังเกตว่าขั้นตอนต่างๆที่ผ่านมาส่วนใหญ่ของการตั้งค่าการเข้ารหัส พอถึงตรงนี้แล้วจะเป็นการเลือกว่า traffic ไหนวิ่งผ่าน IPsec ไปโดยใช้ access list
ใน LAB นี้ traffic ที่ต้องการเข้ารหัสเป็น traffic ไปจาก loopback ของ R1 ไปยัง loopback ของ R3 ทั้งไปกลับ เขียน ACL ที่ router R1 และ R3 เป็นตามนี้
R1(config)# access-list 101 permit ip 172.16.1.0 0.0.0.255 172.16.3.0 0.0.0.255 R3(config)# access-list 101 permit ip 172.16.3.0 0.0.0.255 172.16.1.0 0.0.0.255
Step 7: Create and Apply Crypto Maps
ขั้นตอนนี้
R3(config)# crypto map MYMAP 10 ipsec-isakmp R1(config-crypto-map)# match address 101 R1(config-crypto-map)# set peer 192.168.23.3 R1(config-crypto-map)# set pfs group5 R1(config-crypto-map)# set transform-set 50 R1(config-crypto-map)# set security-association lifetime seconds 900
R3(config)# crypto map MYMAP 10 ipsec-isakmp R3(config-crypto-map)# match address 101 R3(config-crypto-map)# set peer 192.168.12.1 R3(config-crypto-map)# set pfs group5 R3(config-crypto-map)# set transform-set 50 R3(config-crypto-map)# set security-association lifetime seconds 900
เมื่อสร้างเสร็จแล้วก้เอาไป Apply บน interface ด้วย
R1(config)# interface fastethernet0/0 R1(config-if)# crypto map MYMAPR3(config)# interface serial0/0/1 R3(config-if)# crypto map MYMAP
เท่านี้ก็เป็นการเสร็จการทำ Site-to-Site IPsec VPNs แล้วครับ







