Showing posts with label Cisco. Show all posts
Showing posts with label Cisco. Show all posts

Wednesday, December 5, 2018

1. Cấu hình các interface cho router .
Cấu hình R1 :

R1#conf t
R1(config)#int lo1
R1(config-if)#ip add 192.168.1.1 255.255.255.252
R1(config-if)#int l02
R1(config-if)#ip add 192.168.1.3 255.255.255.252
Bad mask /30 for address 192.168.1.3
R1(config-if)#ip add 192.168.2.1 255.255.255.252
R1(config-if)#int lo3
R1(config-if)#ip add 192.168.3.1 255.255.255.252
R1(config-if)#int lo4
R1(config-if)#ip add 192.168.4.1 255.255.255.252
R1(config-if)#int s2/0
R1(config-if)#no sh
R1(config-if)#ip add 1.1.1.1 255.255.255.248
R1(config-if)#int s2/1
R1(config-if)#no sh
R1(config-if)#ip add 2.2.2.2 255.255.255.248
Cấu hình trên R2 :
R2#conf t
R2(config)#int s2/0
R2(config-if)#no sh
R2(config-if)#ip add 1.1.1.2 255.255.255.248
R2(config-if)#int s2/1
R2(config-if)#no sh
R2(config-if)#ip add 3.3.3.2 255.255.255.248
Cấu hình trên R3 :
R3#conf t
R3(config)#int s2/0
R3(config-if)#no sh
R3(config-if)#ip add 3.3.3.1 255.255.255.248
R3(config-if)#
R3(config-if)#int s2/1
R3(config-if)#no sh
R3(config-if)#ip add 2.2.2.1 255.255.255.248 

R3(config-if)#int lo1
R3(config-if)#ip add 172.16.1.1 255.255.255.252
R3(config-if)#int lo2
R3(config-if)#ip add 172.16.2.1 255.255.255.252
R3(config-if)#int lo3
R3(config-if)#ip add 172.16.3.1 255.255.255.252
R3(config-if)#int lo4
R3(config-if)#ip add 172.16.4.1 255.255.255.252

2. Cấu hình và kiểm tra Route EIGRP:
- Cấu hình EIGRP
 
R1(config-if)#do show run | begin eigrp
router eigrp 10
 network 1.1.1.1 0.0.0.0
 network 2.2.2.2 0.0.0.0
 network 192.168.1.1 0.0.0.0
 network 192.168.2.1 0.0.0.0
 network 192.168.3.1 0.0.0.0
 network 192.168.4.1 0.0.0.0


R2(config-if)#do show run | begin eigrp
router eigrp 10
 network 1.1.1.2 0.0.0.0
 network 3.3.3.2 0.0.0.0


R3(config-router)#do show run | begin eigrp
router eigrp 10
 network 2.2.2.1 0.0.0.0
 network 3.3.3.1 0.0.0.0
 network 172.16.1.1 0.0.0.0
 network 172.16.2.1 0.0.0.0
 network 172.16.3.1 0.0.0.0
 network 172.16.4.1 0.0.0.0
!

- Kiểm tra EIGRP câu lệnh : Show ip eigrp neighbor và show ip route eigrp.

R1#show ip eigrp neighbor
EIGRP-IPv4 Neighbors for AS(10)
H   Address                 Interface              Hold Uptime   SRTT   RTO  Q  Seq
                                                   (sec)         (ms)       Cnt Num
1   2.2.2.1                 Se2/1                    11 00:10:07   15   100  0  14
0   1.1.1.2                 Se2/0                    13 00:15:53   13   100  0  31



R2#show ip eigrp neighbor
EIGRP-IPv4 Neighbors for AS(10)
H   Address                 Interface              Hold Uptime   SRTT   RTO  Q  Seq
                                                   (sec)         (ms)       Cnt Num
1   3.3.3.1                 Se2/1                    13 00:09:43   12   100  0  15
0   1.1.1.1                 Se2/0                    14 00:14:57   11   100  0  29

R3#show ip eigrp neighbor                                                   
EIGRP-IPv4 Neighbors for AS(10)
H   Address                 Interface              Hold Uptime   SRTT   RTO  Q  Seq
                                                   (sec)         (ms)       Cnt Num
1   2.2.2.2                 Se2/0                    12 00:11:11   11   100  0  30
0   3.3.3.2                 Se2/1                    12 00:11:43  430  2580  0  32

3. Cấu hình Summarization :
- Để cấu hình Auto Summarization ta vào EIGR và gõ câu lệnh :
R1(config-if)#router eigrp 10
R1(config-router)#auto-summary 

R2(config)#router eigrp 10
R2(config-router)#auto-summary

R3(config)#router eigrp 10
R3(config-router)#auto-summary
Sau khi cấu hình autosum kiểm tra lại route EIGRP
R1#show ip route eigrp

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 3 subnets, 3 masks
D        1.0.0.0/8 is a summary, 00:04:43, Null0
      2.0.0.0/8 is variably subnetted, 3 subnets, 3 masks
D        2.0.0.0/8 is a summary, 00:04:27, Null0
D     3.0.0.0/8 [90/2681856] via 2.2.2.1, 00:04:27, Serial2/1
                [90/2681856] via 1.1.1.2, 00:04:27, Serial2/0
D     172.16.0.0/16 [90/2297856] via 2.2.2.1, 00:04:27, Serial2/1
      192.168.1.0/24 is variably subnetted, 3 subnets, 3 masks
D        192.168.1.0/24 is a summary, 00:04:56, Null0
      192.168.2.0/24 is variably subnetted, 3 subnets, 3 masks
D        192.168.2.0/24 is a summary, 00:04:57, Null0
      192.168.3.0/24 is variably subnetted, 3 subnets, 3 masks
D        192.168.3.0/24 is a summary, 00:04:57, Null0
      192.168.4.0/24 is variably subnetted, 3 subnets, 3 masks
D        192.168.4.0/24 is a summary, 00:04:56, Null0

Tuesday, December 4, 2018



Cấu hình trên R1 : Đặt IP cho các cổng.
R1#conf t
R1(config)#int e0/0
R1(config-if)#no sh
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#int e0/1
R1(config-if)#no sh
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#int lo1  
R1(config-if)#ip add 1.1.1.1 255.255.255.255
Xem IP các cổng đã cấu hình :
R1(config-router)#do show ip int bri | inc up
Ethernet0/0                192.168.1.1     YES manual up                    up      
Ethernet0/1                192.168.2.1     YES manual up                    up      
Loopback1                  1.1.1.1         YES manual up                    up      
1. Cấu hình EIGRP vs AS = 10 !
Trên R1 :
R1(config-if)#router eigrp 10
R1(config-router)#net 1.1.1.1 0.0.0.0
R1(config-router)#net 192.168.1.1 0.0.0.0
R1(config-router)#net 192.168.2.1 0.0.0.0
Trên R2 :
R2#conf t
R2(config)#int e0/0
R2(config-if)#no sh
R2(config-if)#ip add 192.168.1.2 255.255.255.0
R2(config-if)#int e0/1
R2(config-if)#no sh
R2(config-if)#ip add 192.168.3.2 255.255.255.0
R2(config-router)#net 192.168.3.2 0.0.0.0
R2(config-router)#net 192.168.1.2 0.0.0.0
Trên R3 :
R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int e0/1
R3(config-if)#no sh
R3(config-if)#ip add 192.168.2.2 255.255.255.0
R3(config-if)#int e0/0
R3(config-if)#no sh
R3(config-if)#ip add 192.168.4.2 255.255.255.0
R3(config-if)#router eigrp 10
R3(config-router)#net 192.168.2.2 0.0.0.0
R3(config-router)#net 192.168.4.2 0.0.0.0
Trên R4 :
R4#conf t
R4(config)#int e0/1
R4(config-if)#no sh
R4(config-if)#ip add 192.168.4.1 255.255.255.0
R4(config-if)#int e0/0
R4(config-if)#no sh
R4(config-if)#ip add 192.168.3.1 255.255.255.0
R4(config)#router eigrp 10  
R4(config-router)#net 192.168.3.1 0.0.0.0
R4(config-router)#net 192.168.4.1 0.0.0.0
R4(config-router)#net 4.4.4.4 0.0.0.0
R4(config-router)#int l01
R4(config-if)#ip add 4.4.4.4 255.255.255.255 
Kiểm tra AS :
R4(config-router)#do show ip protocol

*** IP Routing is NSF aware ***

Routing Protocol is "eigrp 10"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Default networks flagged in outgoing updates
  Default networks accepted from incoming updates
  EIGRP-IPv4 Protocol for AS(10)
    Metric weight K1=1, K2=0, K3=1, K4=0, K5=0
    NSF-aware route hold timer is 240
    Router-ID: 192.168.4.1
...............................................
2. Cấu hình trên tất cả các Router chỉ tính metric bằng Delay:
Như chúng ta đã biết công thức tính metric của EIGRP là :
Để cho các Router chỉ tính metric bằng Delay thì k1,k2,k4,k5 = 0.
Mặc định : Metric weight K1=1, K2=0, K3=1, K4=0, K5=0
Cho nên chúng ta chỉ cần cấu hình K1 = 0 là thỏa mãn yêu cầu bài lab.

 - Cấu hình K1 = 0 trên cả 3 Router :
R1(config-if)#router eigrp 10
R1(config-router)#metric weights ?
  <0-8>  Type (Only TOS 0 supported)
R1(config-router)#metric weights 0 0 0 1 0 0
=========================================== 
R2(config-router)#router eigrp 10
R2(config-router)#metric weights 0 0 0 1 0 0
=========================================== 
R3(config-router)#router eigrp 10
R3(config-router)#metric weights 0 0 0 1 0 0
=========================================== 
R4(config)#router eigrp 10
R4(config-router)#metric weights 0 0 0 1 0 0

3. Cấu hình cân bằng tải trên R1!


R1(config)#router eigrp 10
R1(config-router)#vari
R1(config-router)#variance ?
  <1-128>  Metric variance multiplier
      
R1(config-router)#variance 2
Để traffice đi qua R3 gấp đôi R2 thì đường đi qua R3 phải tốt gấp đôi R2, mà metric chỉ dựa vào Delay nên ta chỉ cần cấu hình chỉnh giá trị Delay trên interface e0/0 của R1 :

R1(config-if)#int e0/0
R1(config-if)#delay ?  
  <1-16777215>  Throughput delay (tens of microseconds) 
R1(config-if)#delay 800 
R1(config-if)#end
R1#show int e0/0 

Ethernet0/0 is up, line protocol is up
  Hardware is AmdP2, address is aabb.cc00.0100 (bia aabb.cc00.0100)
  Internet address is 192.168.1.1/24
  MTU 1500 bytes, BW 10000 Kbit/sec, DLY 8000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  ..........................................
 4. Kiểm tra :
R1#show ip route 4.4.4.4

Routing entry for 4.4.4.4/32
  Known via "eigrp 10", distance 90, metric 179200, type internal
  Redistributing via eigrp 10
  Last update from 192.168.1.2 on Ethernet0/0, 00:00:36 ago
  Routing Descriptor Blocks:
  * 192.168.2.2, from 192.168.2.2, 00:00:36 ago, via Ethernet0/1
      Route metric is 179200, traffic share count is 2
      Total delay is 7000 microseconds, minimum bandwidth is 10000 Kbit
      Reliability 255/255, minimum MTU 1500 bytes
      Loading 1/255, Hops 2
    192.168.1.2, from 192.168.1.2, 00:00:36 ago, via Ethernet0/0
      Route metric is 358400, traffic share count is 1
      Total delay is 14000 microseconds, minimum bandwidth is 10000 Kbit
      Reliability 255/255, minimum MTU 1500 bytes
      Loading 1/255, Hops 2

Download Lab : Google Drive 

Tài liệu học CCNP Full




Monday, January 22, 2018

OSPF - Open shortest path first Open Shortest Path First là một giao thức định tuyến link – state điển hình. Đây là một giao thức được sử dụng rộng rãi trong các mạng doanh nghiệp có kích thước lớn. Mỗi router khi chạy giao thức sẽ gửi các trạng thái đường link của nó cho tất cả các router trong vùng.
Dưới đây là các câu lệnh rất thường được sử dụng trong quá trình cấu hình cũng như theo dõi hay troubleshoot OSPF:
R1(config)#router ospf process-id
 
Câu lệnh enable tiến trình ospf trên router.


R1(config-router)#network network[wildcard-mask]
 
Định nghĩa một network tham gia vào tiến trình ospf .


R1(config-router)#ip ospf priority 0
 

Ngăn không cho một interface tham gia vào quá trình bầu chọn DR.

R1(config-router)#area number virtual-lin router-id
 
Câu lệnh thiết lập một virtual-links từ vùng không có kết nối trực tiếp với Area 0 để tiến trình ospf được thiết lập.
- number = là area nằm giữa area 0 và area cần thiết lập với area 0
- router-id= là router nằm giữa area 0 và area cần  thiết lập với area 0

R1(config-router)#neighbor ip-address
 
Cấu hình static ospf trên các đường kết nối không hỗ trợ gói tin broadcast (nonbroadcast).


R2#show ip route
 

Danh sách các định tuyến được thêm vào bảng định tuyến trên router.


R2#show ip ospf neighbor
 
Hiện thị những "hàng xóm" mà ospf thiết lập được.


R2#show ip ospf interface [interface-id]
 
Xem những thiết lập trên một Interface cho quá trình thiết lập ospf với hàng xóm như hello time, dead time, Area....


R1#show ip ospf virtual-links 
 
Cung cấp các thông tin trạng thái về virtual-links.


R1#debug ip ospf packet
 
Kiểm tra các gói tin ospf trao đổi giữa các Router.

R1#show run | begin router ospf
 
Hiện thị tất cả cấu hình bắt đầu từ ospf.

Wednesday, January 3, 2018

Một trong những tính năng nổi bật khác của GNS3 là có thể kết nối các thiết bị ảo ra Internet.
Ta có sơ đồ như sau :
Cloud 1 được kết nối với Wireless máy tính thật.
Bài Lab bao gồn :
1.Cấu hình cổng E0/1 nhận IP DHCP từ ISP (giả lập CLoud 1 là ISP)
2.Cấu hình DHCP  server trên R1 cấp ip cho mạng LAN 192.168.100.0/24
3. Cấu hình NAT cho mạng LAN 192.168.100.0 ra internet.

Cấu hình cổng e0/1 nhận IP DHCP 


enable
conf t
interface e0/0
ip add 192.168.100.1 255.255.255.0
interface e0/1
ip add dhcp
mac-address aabb.ccdd.eeff ( điền MAC wiffi máy tính của các bạn)


Để xem Mac wifi của máy tính :
 Ấn chuột phải vào biểu tưởng wifi ==> Open network and sharing center :
Tiếp theo 
Tiếp theo
Tiếp theo
Đây chính là MAC wifi của máy các bạn.

Cấu hình R1 làm DHCP server


ip dhcp pool P1
network 192.168.100.0 255.255.255.0 //dải ip muốn cấp dhcp
default-router 192.168.100.1     // default getway cho client
dns server 8.8.8.8 
                         

Cấu hình NAT cho mạng LAN ra internet 


inteface e0/1
ip nat outside
interface e0/0
ip nat inside
ip access-list extended NAT
permit ip 192.168.100.0 0.0.0.255 any
exit
ip nat inside source list NAT interface e0/1 overload 

Video tham khảo :

Friday, December 22, 2017

Site to Site VPN tunnel đang được sử dụng để cho phép truyền dữ liệu an toàn, dữ liệu void hoặc dữ liệu video giữa 2 site với nhau ( ví dụ : giữa trụ sở chính và chi nhánh hoặc giữa các chi nhánh với nhau.....)
VPN tunnel được tạo thông qua mạng internet, và được mã hóa với các loại thuật toán mã hóa tiên tiến để đảm bảo bảo mật khi truyền dữ liệu.
Trong bài này sẽ trình bày làm sao cấu hình tạo một kết nối an toàn vpn tunnel giữa hai router cisco, sử dụng IP Secutiy potocol(IPsec).
IPsec VPN tunnel cũng có thể cấu hình bằng GRE (Generic Routing Encapsulation) Tunnel. VPN GRE có cấu hình đơn giản có thể tham khảo tại bài viết Cấu hình GRE VPN Tunnel
Trong bài LAB này sử dụng IP public giữa 2 router, sơ đồ kết nối như sau :
Ở đây mô phỏng kết nối VPN site to site giữa trụ sở ở Sài gòn và trụ sở ở Đà nẵng.
Cấu hình trên Router Sài gòn :
Cấu hình ISAKMP Phase 1 :

SG(config)# crypto isakmp policy 1
SG(config-isakmp)# encr 3des
SG(config-isakmp)# hash md5
SG(config-isakmp)# authentication pre-share
SG(config-isakmp)# group 2
SG(config-isakmp)# lifetime 86400

- 3DES Phương thức mã hóa được sử dụng cho phase 1
- md5 là thuật toán hashing
- group 2 Deffie-Hellman Group
-86400 Session key lifetime. đây là giá trị default.
 Định nghĩa key cho pre share key bằng câu lệnh :
SG(config)# crypto isakmp key 0 cisco address 1.1.1.1
    Key pre share được đặt là cisco để xác thực với router có địa chỉ là 1.1.1.1.
   Tạo IPsec Transform (ISAKMP Phase 2):
   Tạo transform set để bảo vệ dữ liệu với tên là myset :

SG(config)# crypto ipsec transform-set myset esp-3des esp-md5-hmac

Tạo ACL :
ACL cho phép lớp mạng nào được tham gia VPN


SG(config)# ip access-list extended VPN
SG(config-ext-nacl)# permit ip 192.168.100.0 0.0.0.255 172.16.100.0 0.0.0.255

Tạo Crypto MAP :

SG(config)# crypto map CMAP 10 ipsec-isakmp
SG(config-crypto-map)# set peer 2.2.2.1
SG(config-crypto-map)# set transform-set myset
SG(config-crypto-map)# match address VPN


Apply Crypto MAP vào Interface Public:

SG(config)# interface Ethernet0/1
SG(config- if)# crypto map mymap

Tương tự với Router ở Đà nẵng :

DN(config)# crypto isakmp policy 1
DN(config-isakmp)# encr 3des
DN(config-isakmp)# hash md5
DN(config-isakmp)# authentication pre-share
DN(config-isakmp)# group 2
DN(config-isakmp)# lifetime 86400
DN(config)# crypto isakmp key cisco address 1.1.1.1
DN(config)# ip access-list extended VPN
DN(config-ext-nacl)# permit ip 172.16.100.0 0.0.0.255 192.168.100.0 0.0.0.255
DN(config)# crypto ipsec transform-set TS esp-3des esp-md5-hmac
DN(config)# crypto map CMAP 10 ipsec-isakmp
DN(config-crypto-map)# set peer 1.1.1.1
DN(config-crypto-map)# set transform-set myset 
DN(config-crypto-map)# match address VPN
DN(config)# interface Ethernet0/1
DN(config- if)# crypto map mymap

Tạo route giữa hai mạng :

SG(config)#ip route 192.168.100.0 255.255.255.0 1.1.1.2 


DN(config)#ip route 172.16.100.0 255.255.255.0 2.2.2.2

Video tham khảo :







Wednesday, December 20, 2017

Giao thức Point to Point Tunnel (PPTP) là một giao thức mạng sử dụng để tạo VPN tunnel giữa các mạng Public với nhau. Dữ liệu đi trong các VPN tunnel này đã được mã hóa end to end, PPTP thường được sử dụng trong trường hợp kết nối từ client tới Server. Trong đó Server là mạng của công ty còn client là máy tính người dùng có thể kết nối tới mạng LAN công ty bất cứ nơi đâu khi có internet bằng PPTP.
Thuật toán mã hóa của PPTP là đã đạt được một mức độ bảo mật, nhưng PPTP không phải là thuật toán mã hóa tốt ngày nay. PPTP còn có nhiều nhược điểm nên không được sử dụng cho các kết nối dài hạn. PPTP sử dụng thuật toán mã hóa Password Authentication Protocol and the Challenge Handshake Authentication Protocol. PPTP cung cấp các tùy chọn mã hóa là : 40, 56 và 128.
PPTP là giải pháp tối ưu cho việc kết nối VPN tạm thời bởi vì trên nền tảng Windows hỗ trợ tất cả và không cần phải cài đặt thêm ứng dụng hay driver nào.
Router Cisco có thể thiết lập PPTP server, hay còn có cách gọi khác là Virtual Private Dialup Network (VPDN) server.

Sơ đồ kết nối :
Nói qua một tý về sơ đồ :
Router internet mô phỏng môi trườn internet.
Router Home mô phỏng router ở nhà hay ở quán cà phê hay bất cứ nơi đâu :)
Router Company là router cần cấu hình PPTP server để máy tính kết nối tới.

Mặc định thì máy tính của bạn sẽ ping được tới ip public của công ty nhé. ở đây  để đơn giản mình sẽ chạy ospf để thông các ip public với nhau.
Bắt đầu vào cấu hình VPDN nào :
trên route Company :
Bước 1 : bật chức năng VPDN trên router
R1# configure terminal
R1(config)# vpdn enable 
R1(config)# vpdn-group 1 
R1(config-vpdn)# accept-dialin
R1(config-vpdn-acc-in)# protocol pptp 
R1(config-vpdn-acc-in)# virtual-template 1 
R1(config-vpdn-acc-in)# exit
Bước 2: tạo liên kết giữa virtual interface và interface vật lý :

R1(config)# interface Virtual-Template1
R1(config-if)# ip unnumbered Ethernet 0/0
R1(config-if)# peer default ip address pool PPTP
R1(config-if)# no keepalive
R1(config-if)# ppp encrypt mppe 128
R1(config-if)# ppp authentication ms-chap ms-chap-v2
Câu lệnh ppp encrypt là câu lệnh quy định kểu mã hóa được sử dụng, trong trường hợp này đang sử dụng à 128 bit, các bạn có thể sử dụng tùy chọn auto ....
Kiểu chứng thực ms-chap ms-chap-v2 là kiểu chứng thực tốt nhất được sử dụng hiện nay.
Tất các VPDN client sẽ nhận được IP là một phần của mạng |LAN hiện tại (ví như ở ví dụ này), hoặc client sẽ được gán ip hoàn toàn khác với ip LAN hiện tại ví dụ như : 192.168.0.2 192.168.0.100
Nếu muốn gán cho VPDN lient cho mạng LAN hiện tại thì ta cần liên kết virtual intface và interface vật lý bằng câu lệnh "ip unnumbered" cổng vật lý trong ví dụ này Ehternet 0/0.
Cấu hình gán IP cho VPDN client một phần của mạng nội bộ hiện tại :
R1(config)# ip local pool PPTP 192.168.100.5 192.168.100.10

Cấu hình tên và Password chứng thực khi user truy cập tới router:

R1(config)# username admin password cisco
Truy cập từ xa phải thành công khi đăng nhập bằng user trên.
Thiết lập tại máy client ở đây sử dụng windows 7 :
vào Network sharching and center
Clink vào set up a new connection or network :
Chọn connect to a workplace rồi next :
chọn Use my internet connection (VPN)

Internet address điền ip public của công ty vào rồi ấn next

Video tham khảo :

Thursday, December 14, 2017

Generic Routing Encapsulation (GRE)  là một giao thức được phát triển bởi Cisco, cho phép đóng gói nhiều giao thức ở tầng Network layer trong kết nối point-to-point.
Một tunnel GRE được sử dụng khi cần gưởi gói tin từ mạng này qua mạng khác hoặc mạng không an toàn. Với GRE, một virtual tunnel được tạo ra giữa hai router đầu cuối và gói tin được đóng gói gửi qua virtual tunnel. 
Một điều quna trong là các gói tin gửi qua GRE chưa được mã hóa vì GRE không mã hóa mà chỉ đóng một hearder GRE. Nếu cần mã hóa, thì phải cấu hình thêm IPsec.
Quy trình đóng gói khi qua GRE không mã hóa :


Nhiều người thường nghĩ GRE IPsec tunnel giữa hai cisco router giống như là site to site IPsec VPN, nhưng thực chất là không giống. Sự khác biệt cở bản giữa hai loại này là GRE IPsec tunnel cho phép gói tin multicast gửi qua còn IPsec VPN thì không hỗ trợ gói tin này. Trong một mạng lớn khi chúng ta cần cầu hình OSPF, EIGRP....GRE tunnel là sự lựa chọn tốt nhất. Và phần cấu hình GRE cũng đơn giản hơn nhiều so với IPsec VPN nên hầu hết sẽ ưu tiên GRE tunnel hơn là IPsec VPN.
Trong bài lab này giả lập internet (ISP) là một router. Trên các cổng WAN sẽ chạy ospf để thông với nhau, mặc định khi thuê ip public của ISP thì các ip wan phải ping thấy nhau.
Sơ đồ kết nối :

Đặt interface và cấu hình ospf cho các cổng WAN ping thấy nhau:

Trên SiteA :

SiteA#show run int e0/0
Building configuration...
Current configuration : 82 bytes
!
interface Ethernet0/0
 ip address 1.1.1.1 255.255.255.0
 ip ospf 10 area 0
end

SiteA(config-if)#do show run int tun 0
Building configuration...

Current configuration : 150 bytes
!
interface Tunnel0
 ip address 172.16.0.1 255.255.255.0
 ip mtu 1400
 ip tcp adjust-mss 1360
 tunnel source 1.1.1.1
 tunnel destination 2.2.2.1
end

SiteA#show run int e0/1
Building configuration...

Current configuration : 68 bytes
!
interface Ethernet0/1   // không tham gia ospf
 ip address 192.168.10.1 255.255.255.0
end


Trên SiteB:

SiteB#show run int e0/0
Building configuration...

Current configuration : 82 bytes
!
interface Ethernet0/0
 ip address 2.2.2.1 255.255.255.0
 ip ospf 10 area 0
end


SiteB#show run int e0/1
Building configuration...

Current configuration : 68 bytes
!
interface Ethernet0/1   //không tham ospf
 ip address 192.168.20.1 255.255.255.0
end
================================================
Trên Router Internet :
Internet#show run int e0/0
Building configuration...

Current configuration : 82 bytes
!
interface Ethernet0/0
 ip address 1.1.1.2 255.255.255.0
 ip ospf 10 area 0
end
================================================
SiteB#show run int tun 0
Building configuration...

Current configuration : 150 bytes
!
interface Tunnel0
 ip address 172.16.0.2 255.255.255.0
 ip mtu 1400
 ip tcp adjust-mss 1360
 tunnel source 2.2.2.1
 tunnel destination 1.1.1.1
end
====================================================
Internet#show run int e0/1
Building configuration...

Current configuration : 82 bytes
!
interface Ethernet0/1
 ip address 2.2.2.2 255.255.255.0
 ip ospf 10 area 0
end

Để 2 mạng LAN có thể ping thấy nhau chúng ta sẽ tạo static route trên siteA và SiteB:
Trên SiteA:

SiteA(config)#ip route 192.168.20.0 255.255.255.0 172.16.0.2

Trên SiteB :
SiteB(config)#ip route 192.168.10.0 255.255.255.0 172.16.0.1

Kiểm tra bằng lệnh traceroute xem gói tin qua GRE tunnel :









Vậy là gói tin đã đi qua tunnel. Nhưng đây là gói tin chưa có mã hóa, để mã hóa chúng ta cấu hình thêm IPsec.
Trên SiteA :
SiteA(config)# crypto isakmp policy 1
SiteA(config-isakmp)# encr 3des
SiteA(config-isakmp)# hash md5
SiteA(config-isakmp)# authentication pre-share
SiteA(config-isakmp)# group 2
SiteA(config-isakmp)# lifetime 86400
============================================================
3des là phương thức mã hóa được sử dụng ở phase 1
MD5 là thuật toán hashing
pre-share sử dụng pre-share trong phương thức chứng thực.
group 2 sử dụng nhóm Diffie-Hellman 
============================================================
SiteA(config)# crypto isakmp key cisco address 2.2.2.1
============================================================
thiết lập pre-share key của peer đầu kia để chứng thực là cisco
============================================================
SiteA(config)# crypto ipsec transform-set myset esp-3des esp-md5-hmac
SiteA(cfg-crypto-trans)# mode transport
============================================================
esp-3des là phương thức mã hóa phase 2
md5 thuật toán hashing
thiết lập IPsec ở mode transport
============================================================
SiteA(config)# crypto ipsec profile protect-gre
SiteA(ipsec-profile)# set security-association lifetime seconds 86400
SiteA(ipsec-profile)# set transform-set myset

Apply IPsec lên interface tunnel 0 :

SiteA(config)# interface Tunnel 0SiteA(config-if)# tunnel protection ipsec profile protect-gre
===========================================================
Tương tự trên SiteB :
SiteB(config)# crypto isakmp policy 1
SiteB(config-isakmp)# encr 3des
SiteB(config-isakmp)# hash md5
SiteB(config-isakmp)# authentication pre-share
SiteB(config-isakmp)# group 2
SiteB(config-isakmp)# lifetime 86400
SiteB(config)# crypto isakmp key firewallcx address 1.1.1.1
SiteB(config)# crypto ipsec transform-set myset esp-3des esp-md5-hmac
SiteB(cfg-crypto-trans)# mode transport
SiteB(config)# crypto ipsec profile protect-gre
SiteB(ipsec-profile)# set security-association lifetime seconds 86400
SiteB(ipsec-profile)# set transform-set myset
SiteB(config)# interface Tunnel 0
SiteB(config-if)# tunnel protection ipsec profile protect-gre

Video hướng dẫn :



Bài viết có tham khảo trên trang: firewall.cx





Tuesday, December 12, 2017

Phương thức hoạt động của DMVPN:

trước khi đi vào cấu hình DMVPN chúng ta tìm hiểu qua phương thức hoạt động của DMVPN nhé :

  • Mỗi Spoke sẽ kết nối về Hub bằng 1 đường IPsec Tunnel
  • Mỗi Spoke sẽ đăng ký là 1 client của NHRP server. Hub router đảm nhận là NHRP server
  • Khi Lan của Spoke này muốn gưởi gói tin cho LAN của Spoke kia, nó sẽ hỏi NHRP server địa chỉ ip của Spoke kia.
  • Sau khi nó biết được địa chỉ của Spoke đã nói nó sẽ tạo 1 đường hầm tới Spoke kia.
  • Kết nối tunnel Spoke-to-Spoke được thiết lập bằng mGRE interface.
  • Kết nối tunnel Spoke-to-Spoke được thiết lập bất cứ khi nào có trao đổi gói tin.
  • Tất cả dữ liệu đi qua tunnel đều được mã hóa IPsec.
Sơ đồ mô phỏng :

NOTE: Ở đây môi trường giả lập nên Internet sẽ được thay thế bằng 1 router nhé. Mặc định khi công ty thuê 1 hay 2 hay 3 hoặc nhiều ip public thì đều có thể ping thấy nhau trên các ip public này. để đơn giản mình sẽ chay ospf cho các cổng WAN của các router cho các ip public ping thấy nhau nhé.

Cấu hình trên HUB:

Cấu hình cổng LAN và WAN cho router :

interface FastEthernet0/0


 description WAN-Network
 ip address 1.1.1.1 255.255.255.0
 ip ospf 10 area 0
 duplex auto
 speed auto
!
interface FastEthernet0/1  // không than gia ospf nhé.
 description LAN-Network
 ip address 192.168.10.1 255.255.255.0
 duplex auto
 speed auto

Cấu hình cổng Tunnel cho Router:

interface Tunnel0
 description mGRE - DMVPN Tunnel
 ip address 172.16.0.1 255.255.255.0
 no ip redirects
 ip nhrp authentication cisco
 ip nhrp map multicast dynamic
 ip nhrp network-id 1
 tunnel source 1.1.1.1
 tunnel mode gre multipoint
============================================
Ở đây tunnel des đã được thay bằng multipoit. nó được thay thế bằng câu lệnh  tunnel mode gre multipoint.
 ip nhrp map multicast dynamic là câu lệnh bật tính năng truyền multicast tới nhrp server.
 ip nhrp authentication cisco  là câu lệnh chứng thực với nhrp server mật khẩu là cisco.
 ip nhrp network-id 1 là lệnh để xác định cloud của DMVPN này. có thể nói nó giống area trong ospf vậy.


Cấu hình trên Spoke1 và Spoke2:

interface FastEthernet0/0
 ip ospf 10 area 0

 description WAN-Network
 ip address 2.2.2.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1 // không tham gia ospf nhé
 description LAN-Network
 ip address 192.168.20.1 255.255.255.0
 duplex auto
 speed auto

interface Tunnel0
 description R2 mGRE - DMVPN Tunnel
 ip address 172.16.0.2 255.255.255.0   //trên spoke2 là 172.16.0.3 255.255.255.0
 no ip redirects
 ip nhrp authentication cisco
 ip nhrp map multicast dynamic
 ip nhrp map 172.16.0.1 1.1.1.1
 ip nhrp map multicast 1.1.1.1
 ip nhrp network-id 1
 ip nhrp nhs 172.16.0.1
 tunnel source 2.2.2.1   // trên spoke 2 thay là 3.3.3.1
 tunnel mode gre multipoin
Cấu hình trên Spoke 2 tương tự như Spoke1 chỉ cần thay ip vào.
====================================================
 ip nhrp nhs 172.16.0.1  là câu lệnh nói cho Spoke biết đâu nhrp server, nhs là next hop server.
 ip nhrp map multicast 1.1.1.1 là câu lệnh để đảm bảo răng gói tin multicast chỉ gửi cho nhrp server là 1.1.1.1


Trên Router đóng vai trò là Internet :

interface Ethernet0/0
 ip address 1.1.1.2 255.255.255.0
 ip ospf 10 area 0
interface Ethernet0/1
 ip address 2.2.2.2 255.255.255.0
 ip ospf 10 area 0
end
interface Ethernet0/2
 ip address 3.3.3.2 255.255.255.0
 ip ospf 10 area 0
end

Bây giờ thì các cổng WAN đã ping thấy nhau rồi. Và thiết lập DMVPN đã xong ta kiểm tra bằng lệnh

HUB#show dmvpn
Legend: Attrb --> S - Static, D - Dynamic, I - Incomplete
        N - NATed, L - Local, X - No Socket
        # Ent --> Number of NHRP entries with same NBMA peer
        NHS Status: E --> Expecting Replies, R --> Responding, W --> Waiting
        UpDn Time --> Up or Down Time for a Tunnel
==========================================================================

Interface: Tunnel0, IPv4 NHRP Details
Type:Hub, NHRP Peers:2,

 # Ent  Peer NBMA Addr Peer Tunnel Add State  UpDn Tm Attrb
 ----- --------------- --------------- ----- -------- -----
     1 2.2.2.1              172.16.0.2    UP 01:30:49     D
     1 3.3.3.1              172.16.0.3    UP 01:31:43     D

Spoke1#show dmvpn 
Legend: Attrb --> S - Static, D - Dynamic, I - Incomplete
        N - NATed, L - Local, X - No Socket
        # Ent --> Number of NHRP entries with same NBMA peer
        NHS Status: E --> Expecting Replies, R --> Responding, W --> Waiting
        UpDn Time --> Up or Down Time for a Tunnel
==========================================================================

Interface: Tunnel0, IPv4 NHRP Details 
Type:Spoke, NHRP Peers:2, 

 # Ent  Peer NBMA Addr Peer Tunnel Add State  UpDn Tm Attrb
 ----- --------------- --------------- ----- -------- -----
     1 1.1.1.1              172.16.0.1    UP 01:31:14     S
     1 3.3.3.1              172.16.0.3    UP 00:58:50     D


Spoke2#show dmvpn 
Legend: Attrb --> S - Static, D - Dynamic, I - Incomplete
        N - NATed, L - Local, X - No Socket
        # Ent --> Number of NHRP entries with same NBMA peer
        NHS Status: E --> Expecting Replies, R --> Responding, W --> Waiting
        UpDn Time --> Up or Down Time for a Tunnel
==========================================================================

Interface: Tunnel0, IPv4 NHRP Details 
Type:Spoke, NHRP Peers:2, 

 # Ent  Peer NBMA Addr Peer Tunnel Add State  UpDn Tm Attrb
 ----- --------------- --------------- ----- -------- -----
     1 1.1.1.1              172.16.0.1    UP 01:32:29     S
     1 2.2.2.1              172.16.0.2    UP 00:59:11     D


Mã hóa DMVPN mGRE Tunnel với IPsec

Cấu hình IPsec cho HUB:

crypto isakmp policy 1
encr 3des
hash md5
authentication pre-share
group 2
lifetime 86400
!
crypto isakmp key cisco address 0.0.0.0
!
crypto ipsec transform-set myset esp-3des esp-md5-hmac
!
crypto ipsec profile protect-gre
set security-association lifetime seconds 86400
set transform-set myset
!
interface Tunnel 0
tunnel protection ipsec profile protect-gre
============================================
để có thể peer tới các Spoke nhận ip động từ ISP nên ta phải dùng câu lệnh crypto isakmp key cisco address 0.0.0.0 
Cấu hình IPsec cho Spoke1 và Spoke2 :
crypto isakmp policy 1
encr 3des
hash md5
authentication pre-share
group 2
lifetime 86400
!
crypto isakmp key cisco address 0.0.0.0 0.0.0.0
!
crypto ipsec transform-set myset esp-3des esp-md5-hmac
!
crypto ipsec profile protect-gre
set security-association lifetime seconds 86400
set transform-set myset
!
interface Tunnel 0
tunnel protection ipsec profile protect-gre

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


Kiểm tra các thiết lập IPsec:

HUB#show crypto ses
Crypto session current status

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 3.3.3.1 port 500 
  Session ID: 0  
  IKEv1 SA: local 1.1.1.1/500 remote 3.3.3.1/500 Active 
  IPSEC FLOW: permit 47 host 1.1.1.1 host 3.3.3.1 
        Active SAs: 2, origin: crypto map

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 2.2.2.1 port 500 
  Session ID: 0  
  IKEv1 SA: local 1.1.1.1/500 remote 2.2.2.1/500 Active 
  Session ID: 0  
  IKEv1 SA: local 1.1.1.1/500 remote 2.2.2.1/500 Active 
  IPSEC FLOW: permit 47 host 1.1.1.1 host 2.2.2.1 
        Active SAs: 2, origin: crypto map


Spoke1#show crypto session
Crypto session current status

Interface: Tunnel0
Session status: UP-ACTIVE   
Peer: 3.3.3.1 port 500
  Session ID: 0
  IKEv1 SA: local 2.2.2.1/500 remote 3.3.3.1/500 Active
  Session ID: 0
  IKEv1 SA: local 2.2.2.1/500 remote 3.3.3.1/500 Active
  IPSEC FLOW: permit 47 host 2.2.2.1 host 3.3.3.1
        Active SAs: 2, origin: crypto map

Interface: Tunnel0
Session status: UP-ACTIVE   
Peer: 1.1.1.1 port 500
  Session ID: 0
  IKEv1 SA: local 2.2.2.1/500 remote 1.1.1.1/500 Active
  Session ID: 0
  IKEv1 SA: local 2.2.2.1/500 remote 1.1.1.1/500 Active
  IPSEC FLOW: permit 47 host 2.2.2.1 host 1.1.1.1
        Active SAs: 2, origin: crypto map

Routing giữa các DMVPN với nhau:

Để các mạng LAN giữa các Router có thể Ping thấy nhau ta phải route cho nó:
Trên HUB:
ip route 192.168.20.0 255.255.255.0 172.16.0.2
ip route 192.168.30.0 255.255.255.0 172.16.0.3

Trên Spoke1:
ip route 192.168.10.0 255.255.255.0 172.16.0.1
ip route 192.168.30.0 255.255.255.0 172.16.0.3
Trên Spoke2 :
ip route 192.168.1.0 255.255.255.0 172.16.0.1
ip route 192.168.2.0 255.255.255.0 172.16.0.2
Video hướng dẫn: 

Bài viết có tham khảo tại : firewall.cx

Xem nhiều nhất