Nếu bạn muốn chuyển một cách an toàn lưu lượng truy cập đa hướng hoặc không phải IP giữa các Site thì IPSEC một mình sẽ không hoạt động. May mắn thay, các bộ định tuyến của Cisco hỗ trợ giao thức GRE (Generic Routing Encapsulation), là một giao thức đường hầm có thể đóng gói nhiều loại gói dữ liệu lớp mạng khác nhau vào một đường hầm GRE. GRE có thể đóng gói các gói tin lưu lượng đa hướng, giao thức định tuyến (OSPF, EIGRP, v.v.) và các lưu lượng không phải IP khác bên trong một đường hầm điểm-điểm. Nhược điểm của GRE là nó không an toàn như IPSEC. Giờ đây, bằng cách sử dụng GRE qua IPSEC, chúng ta có thể có cả hai công nghệ tốt nhất: Bảo mật và hỗ trợ nhiều giao thức mạng. Một số ứng dụng của việc sử dụng GRE qua IPSEC như sau: Chuyển lưu lượng truy cập đa hướng từ máy chủ video của một Site này sang một Site khác qua Internet. Chuyển các bản cập nhật giao thức định tuyến (lưu lượng đa hướng) giữa các Site hoạt động trong cấu trúc liên kết IPSEC VPN. Chạy Novel IPX giữa các Site IPSEC VPN. Sử dụng cân bằng tải với giao thức định tuyến giữa các Site IPSEC VPN. Configuration example Dưới đây chúng ta sẽ mô tả một ví dụ cấu hình giữa hai bộ định tuyến Cisco chạy GRE qua IPSEC thông qua Internet. Từ sơ đồ trên, chúng ta có hai mạng LAN riêng 192.168.1.0/24 và 192.168.2.0/24 và chúng ta muốn gửi lưu lượng non-IP giữa chúng (ví dụ: lưu lượng máy chủ video multicast từ Site-A đến Site-B hoặc bất kỳ mạng nào khác lưu lượng truy cập non-IP non-unicast). Đối với mỗi bộ định tuyến, chúng ta có một địa chỉ IP Public tĩnh trên giao diện bên ngoài FE0 / 1 (100.100.100.1 và 200.200.200.1) qua đó chúng ta sẽ thiết lập đường hầm IPSEC. Các đường hầm GRE sẽ chạy giữa hai địa chỉ IP riêng (10.0.0.1 và 10.0.0.2) được cấu hình trên mỗi bộ định tuyến (với lệnh interface Tunnel). Kịch bản cũng liên quan đến NAT để truy cập internet chung của các mạng cục bộ. Cấu hình Router-Site-A version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname SITE-A ! boot-start-marker boot-end-marker ! enable secret 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ! no aaa new-model ip subnet-zero ! !— Đây là cấu hình IPsec (This is the IPsec configuration). ! crypto isakmp policy 10 authentication pre-share crypto isakmp key testkey123 address 200.200.200.1 ! crypto ipsec transform-set ESPDES-TS esp-des esp-md5-hmac ! crypto map myvpn 10 ipsec-isakmp ! set peer 200.200.200.1 set transform-set ESPDES-TS match address 101 ! !— Đây là một đầu của đường hầm GRE (This is one end of the GRE tunnel). ! interface Tunnel0 ip address 10.0.0.1 255.255.255.0 !— Liên kết đường hầm với giao diện vật lý bên ngoài (Associate the tunnel with the physical outside interface). tunnel source FastEthernet0/1 tunnel destination 200.200.200.1 !— Đính kèm bản đồ crypto IPSEC vào đường hầm GRE (Attach the IPSEC crypto map to the GRE tunnel). crypto map myvpn !— Đây là mạng nội bộ (This is the internal network). interface FastEthernet0/0 ip address 192.168.1.1 255.255.255.0 ip nat inside !— Đây là giao diện bên ngoài và một đầu của đường hầm GRE (This is the external interface and one end of the GRE tunnel). interface FastEthernet0/1 ip address 100.100.100.1 255.255.255.0 ip nat outside crypto map myvpn !— Xác định nhóm NAT (Define the NAT pool). ip nat pool NATPOOL 100.100.100.2 100.100.100.20 netmask 255.255.255.0 ip nat inside source route-map nonat pool NATPOOL overload ip classless ip route 0.0.0.0 0.0.0.0 100.100.100.254 !— Buộc lưu lượng truy cập mạng riêng vào đường hầm (Force the private network traffic into the tunnel). ip route 192.168.2.0 255.255.255.0 10.0.0.2 !— Tất cả lưu lượng truy cập vào đường hầm GRE đều được mã hóa bởi IPsec (All traffic that enters the GRE tunnel is encrypted by IPsec). access-list 101 permit gre host 100.100.100.1 host 200.200.200.1 !— Sử dụng danh sách truy cập trong route-map để giải quyết những gì cần NAT (Use access list in route-map to address what to NAT). access-list 175 deny ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255 access-list 175 permit ip 192.168.1.0 0.0.0.255 any route-map nonat permit 10 match ip address 175 end Cấu hình Router-Site-B version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname SITE-B ! boot-start-marker boot-end-marker ! enable secret 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ! no aaa new-model ip subnet-zero ! !— Đây là cấu hình IPsec (This is the IPsec configuration). ! crypto isakmp policy 10 authentication pre-share crypto isakmp key testkey123 address 100.100.100.1 ! crypto ipsec transform-set ESPDES-TS esp-des esp-md5-hmac ! crypto map myvpn 10 ipsec-isakmp ! set peer 100.100.100.1 set transform-set ESPDES-TS match address 101 ! !— Đây là một đầu của đường hầm GRE (This is one end of the GRE tunnel). ! interface Tunnel0 ip address 10.0.0.2 255.255.255.0 !— Liên kết đường hầm với giao diện vật lý bên ngoài (Associate the tunnel with the physical outside interface). tunnel source FastEthernet0/1 tunnel destination 100.100.100.1 !— Đính kèm bản đồ crypto IPSEC vào đường hầm GRE (Attach the IPSEC crypto map to the GRE tunnel). crypto map myvpn !— Đây là mạng nội bộ (This is the internal network). interface FastEthernet0/0 ip address 192.168.2.1 255.255.255.0 ip nat inside !— Đây là giao diện bên ngoài và một đầu của đường hầm GRE (This is the external interface and one end of the GRE tunnel). interface FastEthernet0/1 ip address 200.200.200.1 255.255.255.0 ip nat outside crypto map myvpn !— Xác định nhóm NAT (Define the NAT pool). ip nat pool NATPOOL 200.200.200.2 200.200.200.20 netmask 255.255.255.0 ip nat inside source route-map nonat pool NATPOOL overload ip classless ip route 0.0.0.0 0.0.0.0 200.200.200.254 !— Buộc lưu lượng truy cập mạng riêng vào đường hầm (Force the private network traffic into the tunnel). ip route 192.168.1.0 255.255.255.0 10.0.0.1 !— Tất cả lưu lượng truy cập vào đường hầm GRE đều được mã hóa bởi IPsec (All traffic that enters the GRE tunnel is encrypted by IPsec). access-list 101 permit gre host 200.200.200.1 host 100.100.100.1 !— Sử dụng danh sách truy cập trong route-map để giải quyết những gì cần NAT (Use access list in route-map to address what to NAT). access-list 175 deny ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255 access-list 175 permit ip 192.168.2.0 0.0.0.255 any route-map nonat permit 10 match ip address 175 end Chúc các bạn thành công. Chi tiết xem tại: Cấu hình VPN Site-to-Site bằng GRE(Generic Routing Encapsulation) qua IPSEC VPN với Router Cisco