Thiết lập Mạng GRE Đa Điểm với OSPF trên Thiết Bị Huawei

Thực hiện cấu hình mạng GRE đa điểm (mGRE) kết hợp giao thức định tuyến OSPF nhằm đảm bảo liên thông toàn bộ mạng riêng và truy cập đến tài nguyên công cộng. Mô hình bao gồm hai miền mGRE độc lập: một cấu trúc sao với R1 làm nút trung tâm, và một cấu trúc mesh đầy đủ giữa R1–R4–R5. Toàn bộ thiết bị sử dụng hệ điều hành VRP (Huawei).

Kế hoạch địa chỉ IP

Địa chỉ cho các máy tính đầu cuối:

Thiết bị Cổng mặc định Địa chỉ IP
PC1 192.168.1.1/24 192.168.1.2/24
PC2 192.168.2.1/24 192.168.2.2/24
PC3 192.168.3.1/24 192.168.3.2/24
PC4 192.168.4.1/24 192.168.4.2/24
PC5 192.168.5.1/24 192.168.5.2/24

Địa chỉ giao diện thiết bị:

Thiết bị Giao diện Địa chỉ/IP
R1 GigabitEthernet0/0/0 192.168.1.1/24
GigabitEthernet0/0/1 16.1.1.1/24
GigabitEthernet0/0/2 61.1.1.1/24
R2 GigabitEthernet0/0/0 192.168.2.1/24
GigabitEthernet0/0/1 26.1.1.2/24
R3 GigabitEthernet0/0/0 192.168.3.1/24
GigabitEthernet0/0/1 36.1.1.3/24
R4 GigabitEthernet0/0/0 192.168.4.1/24
GigabitEthernet0/0/1 46.1.1.4/24
R5 GigabitEthernet0/0/0 192.168.5.1/24
GigabitEthernet0/0/1 56.1.1.5/24
R6 GigabitEthernet0/0/0 16.1.1.6/24
GigabitEthernet0/0/1 26.1.1.6/24
GigabitEthernet0/0/2 36.1.1.6/24
GigabitEthernet2/0/0 61.1.1.6/24
GigabitEthernet3/0/0 56.1.1.6/24
GigabitEthernet4/0/0 46.1.1.6/24
LoopBack0 6.6.6.6/24

Cấu hình đường đi mặc định

Mỗi router nội bộ được định tuyến ra Internet qua R6 bằng đường tĩnh:

[R1] ip route-static 0.0.0.0 0.0.0.0 16.1.1.6
[R2] ip route-static 0.0.0.0 0.0.0.0 26.1.1.6
[R3] ip route-static 0.0.0.0 0.0.0.0 36.1.1.6
[R4] ip route-static 0.0.0.0 0.0.0.0 46.1.1.6
[R5] ip route-static 0.0.0.0 0.0.0.0 56.1.1.6

Cấu hình NAT ra ngoài

Tất cả thiết bị biên (R1–R5) thực hiện chuyển đổi địa chỉ cho lưu lượng từ mạng LAN ra mạng công cộng:

[R1] acl number 2000
[R1-acl-basic-2000] rule 5 permit source any
[R1-GigabitEthernet0/0/1] nat outbound 2000

[R2] acl number 2000
[R2-acl-basic-2000] rule 5 permit source any
[R2-GigabitEthernet0/0/1] nat outbound 2000

[R3] acl number 2000
[R3-acl-basic-2000] rule 5 permit source any
[R3-GigabitEthernet0/0/1] nat outbound 2000

[R4] acl number 2000
[R4-acl-basic-2000] rule 5 permit source any
[R4-GigabitEthernet0/0/1] nat outbound 2000

[R5] acl number 2000
[R5-acl-basic-2000] rule 5 permit source any
[R5-GigabitEthernet0/0/1] nat outbound 2000

Cấu hình mGRE sao (R1–R2–R3)

R1 đóng vai trò hub; R2 và R3 là spoke:

[R1] interface Tunnel0/0/0
[R1-Tunnel0/0/0] ip address 10.1.1.1 255.255.255.0
[R1-Tunnel0/0/0] tunnel-protocol gre p2mp
[R1-Tunnel0/0/0] source 61.1.1.1
[R1-Tunnel0/0/0] nhrp network-id 100

[R2] interface Tunnel0/0/0
[R2-Tunnel0/0/0] ip address 10.1.1.2 255.255.255.0
[R2-Tunnel0/0/0] tunnel-protocol gre p2mp
[R2-Tunnel0/0/0] source GigabitEthernet0/0/1
[R2-Tunnel0/0/0] nhrp entry 10.1.1.1 61.1.1.1 register
[R2-Tunnel0/0/0] nhrp network-id 100

[R3] interface Tunnel0/0/0
[R3-Tunnel0/0/0] ip address 10.1.1.3 255.255.255.0
[R3-Tunnel0/0/0] tunnel-protocol gre p2mp
[R3-Tunnel0/0/0] source GigabitEthernet0/0/1
[R3-Tunnel0/0/0] nhrp entry 10.1.1.1 61.1.1.1 register
[R3-Tunnel0/0/0] nhrp network-id 100

Cấu hình mGRE mesh (R1–R4–R5)

Cả ba nút đều tham gia vào mạng mGRE chung với ID mạng 101:

[R1] interface Tunnel0/0/1
[R1-Tunnel0/0/1] ip address 20.1.1.1 255.255.255.0
[R1-Tunnel0/0/1] tunnel-protocol gre p2mp
[R1-Tunnel0/0/1] source 16.1.1.1
[R1-Tunnel0/0/1] nhrp network-id 101
[R1-Tunnel0/0/1] nhrp entry 20.1.1.2 46.1.1.4 register
[R1-Tunnel0/0/1] nhrp entry 20.1.1.3 56.1.1.5 register

[R4] interface Tunnel0/0/1
[R4-Tunnel0/0/1] ip address 20.1.1.2 255.255.255.0
[R4-Tunnel0/0/1] tunnel-protocol gre p2mp
[R4-Tunnel0/0/1] source 46.1.1.4
[R4-Tunnel0/0/1] nhrp network-id 101
[R4-Tunnel0/0/1] nhrp entry 20.1.1.1 16.1.1.1 register
[R4-Tunnel0/0/1] nhrp entry 20.1.1.3 56.1.1.5 register

[R5] interface Tunnel0/0/1
[R5-Tunnel0/0/1] ip address 20.1.1.3 255.255.255.0
[R5-Tunnel0/0/1] tunnel-protocol gre p2mp
[R5-Tunnel0/0/1] source 56.1.1.5
[R5-Tunnel0/0/1] nhrp network-id 101
[R5-Tunnel0/0/1] nhrp entry 20.1.1.1 16.1.1.1 register
[R5-Tunnel0/0/1] nhrp entry 20.1.1.2 46.1.1.4 register

Cấu hình OSPF đa vùng

Sử dụng area 0 duy nhất để quảng bá tất cả mạng con thuộc mGRE và LAN nội bộ:

[R1] ospf 1 router-id 1.1.1.1
[R1-ospf-1] area 0
[R1-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0] network 20.1.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255

[R2] ospf 1 router-id 2.2.2.2
[R2-ospf-1] area 0
[R2-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0] network 192.168.2.0 0.0.0.255

[R3] ospf 1 router-id 3.3.3.3
[R3-ospf-1] area 0
[R3-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0] network 192.168.3.0 0.0.0.255

[R4] ospf 1 router-id 4.4.4.4
[R4-ospf-1] area 0
[R4-ospf-1-area-0.0.0.0] network 20.1.1.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0] network 192.168.4.0 0.0.0.255

[R5] ospf 1 router-id 5.5.5.5
[R5-ospf-1] area 0
[R5-ospf-1-area-0.0.0.0] network 20.1.1.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0] network 192.168.5.0 0.0.0.255

Điều chỉnh kiểu mạng OSPF và NHRP

Chuyển các tunnel sang chế độ broadcast để hỗ trợ giao thức OSPF đầy đủ, đồng thời kích hoạt cơ chế multicast động cho NHRP:

[R1] interface Tunnel0/0/0
[R1-Tunnel0/0/0] ospf network-type broadcast
[R1] interface Tunnel0/0/1
[R1-Tunnel0/0/1] ospf network-type broadcast
[R1-Tunnel0/0/0] nhrp entry multicast dynamic
[R1-Tunnel0/0/1] nhrp entry multicast dynamic

[R2] interface Tunnel0/0/0
[R2-Tunnel0/0/0] ospf network-type broadcast
[R2-Tunnel0/0/0] nhrp entry multicast dynamic

[R3] interface Tunnel0/0/0
[R3-Tunnel0/0/0] ospf network-type broadcast
[R3-Tunnel0/0/0] nhrp entry multicast dynamic

[R4] interface Tunnel0/0/1
[R4-Tunnel0/0/1] ospf network-type broadcast
[R4-Tunnel0/0/1] nhrp entry multicast dynamic

[R5] interface Tunnel0/0/1
[R5-Tunnel0/0/1] ospf network-type broadcast
[R5-Tunnel0/0/1] nhrp entry multicast dynamic

Thiết lập ưu tiên DR

Loại bỏ khả năng trở thành DR trên các tunnel spoke bằng cách đặt dr-priority 0:

[R2] interface Tunnel0/0/0
[R2-Tunnel0/0/0] ospf dr-priority 0

[R3] interface Tunnel0/0/0
[R3-Tunnel0/0/0] ospf dr-priority 0

Kết quả kiểm tra ping từ PC1 tới địa chỉ loopback của R6 (6.6.6.6) cho thấy kết nối ổn định với độ trễ thấp và tỷ lệ mất gói dưới 25% — xác nhận toàn bộ cấu hình mGRE và OSPF đã vận hành đúng.

Thẻ: huawei-vrp ospf mgre nhrp nat

Đăng vào ngày 6 tháng 6 lúc 04:03