組網及說明
網絡拓撲圖如下:
業務地址、互聯地址、Loopback地址如拓撲圖所示。其中VLAN 10、VLAN 100屬於vpn-rt中,VLAN 20、VLAN 200屬於vpn-nrt實例中,另外SW1與SW2之間的互聯採用trunk,互聯的VLAN使用VLAN 400(綁定到vpn-rt)和VLAN 500(綁定到vpn-nrt),全網採用多VPN實例OSPF互聯互通,不通VPN實例的業務地址不能互通。
vpn-rt規劃如下:
- RD:100:1
- RT:100:1
vpn-nrt規劃如下:
- RD:200:1
- RT:200:1
配置步驟
1、分別在SW1和SW2創建VPN實例
2、根據組網說明將各業務地址、互聯地址、loopback綁定到vpn實例
3、創建多實例OSPF,併發布業務地址實現互通
4、SW1與SW2之間的互聯採用trunk,僅允許互聯的VLAN互通。
配置關鍵點
SW1:
<code>[H3C]sysname SW1
#創建vpn-rt實例,並配置RD值和RT值
[SW1]ip vpn-instance vpn-rt
[SW1-vpn-instance-vpn-rt]route-distinguisher 100:1
[SW1-vpn-instance-vpn-rt]vpn-target 100:1
[SW1-vpn-instance-vpn-rt]vpn-target 100:1
[SW1-vpn-instance-vpn-rt]quit
#創建vpn-nrt實例,並配置RD值和RT值
[SW1]ip vpn-instance vpn-nrt
[SW1-vpn-instance-vpn-nrt]route-distinguisher 200:1
[SW1-vpn-instance-vpn-nrt]vpn-target 200:1
[SW1-vpn-instance-vpn-nrt]quit
[SW1]int LoopBack 0
[SW1-LoopBack0]ip binding vpn-instance vpn-rt //將Loopback0綁定到vpn-rt
Some configurations on the interface are removed.
[SW1-LoopBack0]ip address 1.1.1.1 32
[SW1-LoopBack0]quit
[SW1]int LoopBack 1
[SW1-LoopBack1]ip binding vpn-instance vpn-nrt //將Loopback1綁定到vpn-nrt
Some configurations on the interface are removed.
[SW1-LoopBack1]ip address 1.1.1.1 32
[SW1-LoopBack1]quit
[SW1]vlan 10
[SW1-vlan10]quit
[SW1]vlan 20
[SW1-vlan20]quit
[SW1]vlan 400
[SW1-vlan400]quit
[SW1]vlan 500
[SW1-vlan500]quit
[SW1]int vlan 10
[SW1-Vlan-interface10]ip binding vpn-instance vpn-rt //將VLAN 10綁定到vpn-rt
Some configurations on the interface are removed.
[SW1-Vlan-interface10]ip address 192.168.10.1 24
[SW1-Vlan-interface10]quit
[SW1]int vlan 20
[SW1-Vlan-interface20]ip binding vpn-instance vpn-nrt //將VLAN 20綁定到vpn-nrt
Some configurations on the interface are removed.
[SW1-Vlan-interface20]ip address 192.168.20.1 24
[SW1-Vlan-interface20]quit
[SW1]int vlan 400
[SW1-Vlan-interface400]ip binding vpn-instance vpn-rt //將VLAN400綁定到vpn-rt
Some configurations on the interface are removed.
[SW1-Vlan-interface400]description
[SW1-Vlan-interface400]ip address 10.0.0.1 30
[SW1-Vlan-interface400]quit
[SW1]int vlan 500
[SW1-Vlan-interface500]ip binding vpn-instance vpn-nrt //將VLAN 500綁定到vpn-nrt
Some configurations on the interface are removed.
[SW1-Vlan-interface500]description
[SW1-Vlan-interface500]ip address 10.0.0.1 30
[SW1-Vlan-interface500]quit
[SW1]
[SW1]int gi 1/0/2
[SW1-GigabitEthernet1/0/2]port link-type access
[SW1-GigabitEthernet1/0/2]port access vlan 10
[SW1-GigabitEthernet1/0/2]quit
[SW1]int gi 1/0/3
[SW1-GigabitEthernet1/0/3]port link-type access
[SW1-GigabitEthernet1/0/3]port access vlan 20
[SW1-GigabitEthernet1/0/3]quit
[SW1]
[SW1]int gi 1/0/1
[SW1-GigabitEthernet1/0/1]description
[SW1-GigabitEthernet1/0/1]port link-type trunk
[SW1-GigabitEthernet1/0/1]undo port trunk permit vlan 1
[SW1-GigabitEthernet1/0/1]port trunk permit vlan 400 500
[SW1-GigabitEthernet1/0/1]quit
[SW1]ospf 10 vpn-instance vpn-rt router-id 1.1.1.1 //將OSPF 10綁定到vpn-rt
[SW1-ospf-10]area 0.0.0.0
[SW1-ospf-10-area-0.0.0.0]network 10.0.0.1 0.0.0.0
[SW1-ospf-10-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[SW1-ospf-10-area-0.0.0.0]network 192.168.10.0 0.0.0.255
[SW1-ospf-10-area-0.0.0.0]quit
[SW1-ospf-10]quit
[SW1]ospf 20 vpn-instance vpn-nrt router-id 1.1.1.1 //將OSPF 20綁定到vpn-nrt
[SW1-ospf-20]area 0.0.0.0
[SW1-ospf-20-area-0.0.0.0]network 10.0.0.1 0.0.0.0
[SW1-ospf-20-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[SW1-ospf-20-area-0.0.0.0]network 192.168.20.0 0.0.0.255
[SW1-ospf-20-area-0.0.0.0]quit
[SW1-ospf-20]quit/<code>
SW2:
<code>[H3C]sysname SW2
[SW2]ip vpn-instance vpn-rt
[SW2-vpn-instance-vpn-rt]route-distinguisher 100:1
[SW2-vpn-instance-vpn-rt]vpn-target 100:1
[SW2-vpn-instance-vpn-rt]quit
[SW2]ip vpn-instance vpn-nrt
[SW2-vpn-instance-vpn-nrt]route-distinguisher 200:1
[SW2-vpn-instance-vpn-nrt]vpn-target 200:1
[SW2-vpn-instance-vpn-nrt]quit
[SW2]int LoopBack 0
[SW2-LoopBack0]ip binding vpn-instance vpn-rt
Some configurations on the interface are removed.
[SW2-LoopBack0]ip address 2.2.2.2 32
[SW2-LoopBack0]quit
[SW2]int LoopBack 1
[SW2-LoopBack1]ip binding vpn-instance vpn-nrt
Some configurations on the interface are removed.
[SW2-LoopBack1]ip address 2.2.2.2 32
[SW2-LoopBack1]quit
[SW2]vlan 100
[SW2-vlan100]quit
[SW2]vlan 200
[SW2-vlan200]quit
[SW2]vlan 400
[SW2-vlan400]quit
[SW2]vlan 500
[SW2-vlan500]quit
[SW2]int vlan 100
[SW2-Vlan-interface100]ip binding vpn-instance vpn-rt
Some configurations on the interface are removed.
[SW2-Vlan-interface100]ip address 172.16.20.1 24
[SW2-Vlan-interface100]quit
[SW2]int vlan 200
[SW2-Vlan-interface200]ip binding vpn-instance vpn-nrt
Some configurations on the interface are removed.
[SW2-Vlan-interface200]ip address 172.16.10.1 24
[SW2-Vlan-interface200]quit
[SW2]int vlan 400
[SW2-Vlan-interface400]ip binding vpn-instance vpn-rt
Some configurations on the interface are removed.
[SW2-Vlan-interface400]description
[SW2-Vlan-interface400]ip address 10.0.0.2 30
[SW2-Vlan-interface400]quit
[SW2]int vlan 500
[SW2-Vlan-interface500]ip binding vpn-instance vpn-nrt
Some configurations on the interface are removed.
[SW2-Vlan-interface500]description
[SW2-Vlan-interface500]ip address 10.0.0.2 30
[SW2-Vlan-interface500]quit
[SW2]int gi 1/0/2
[SW2-GigabitEthernet1/0/2]port link-type access
[SW2-GigabitEthernet1/0/2]port access vlan 100
[SW2-GigabitEthernet1/0/2]quit
[SW2]int gi 1/0/3
[SW2-GigabitEthernet1/0/3]port link-type access
[SW2-GigabitEthernet1/0/3]port access vlan 200
[SW2-GigabitEthernet1/0/3]quit
[SW2]int gi 1/0/1
[SW2-GigabitEthernet1/0/1]description
[SW2-GigabitEthernet1/0/1]port link-type trunk
[SW2-GigabitEthernet1/0/1]undo port trunk permit vlan 1
[SW2-GigabitEthernet1/0/1]port trunk permit vlan 400 500
[SW2-GigabitEthernet1/0/1]quit
[SW2]ospf 1 vpn-instance vpn-rt router-id 2.2.2.2
[SW2-ospf-1]area 0.0.0.0
[SW2-ospf-1-area-0.0.0.0]network 10.0.0.2 0.0.0.0
[SW2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[SW2-ospf-1-area-0.0.0.0]network 172.16.20.0 0.0.0.255
[SW2-ospf-1-area-0.0.0.0]quit
[SW2-ospf-1]quit
[SW2]ospf 2 vpn-instance vpn-nrt router-id 2.2.2.2
[SW2-ospf-2]area 0.0.0.0
[SW2-ospf-2-area-0.0.0.0]network 10.0.0.2 0.0.0.0
[SW2-ospf-2-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[SW2-ospf-2-area-0.0.0.0]network 172.16.10.0 0.0.0.255
[SW2-ospf-2-area-0.0.0.0]quit
[SW2-ospf-2]quit/<code>
查看OSPF鄰居狀態:
<code>dis ospf peer
OSPF Process 10 with Router ID 1.1.1.1
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
2.2.2.2 10.0.0.2 1 37 Full/BDR Vlan400
OSPF Process 20 with Router ID 1.1.1.1
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
2.2.2.2 10.0.0.2 1 35 Full/BDR Vlan500
[SW2]dis ospf peer
OSPF Process 1 with Router ID 2.2.2.2
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
1.1.1.1 10.0.0.1 1 37 Full/DR Vlan400
OSPF Process 2 with Router ID 2.2.2.2
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
1.1.1.1 10.0.0.1 1 38 Full/DR Vlan500
[SW2]/<code>
查看VPN路由表是否已學習到對端的VPN路由:
<code>dis ip routing-table vpn-instance vpn-rt
Destinations : 19 Routes : 19
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 O_INTRA 10 1 10.0.0.2 Vlan400
10.0.0.0/30 Direct 0 0 10.0.0.1 Vlan400
10.0.0.0/32 Direct 0 0 10.0.0.1 Vlan400
10.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
10.0.0.3/32 Direct 0 0 10.0.0.1 Vlan400
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
172.16.20.0/24 O_INTRA 10 2 10.0.0.2 Vlan400
192.168.10.0/24 Direct 0 0 192.168.10.1 Vlan10
192.168.10.0/32 Direct 0 0 192.168.10.1 Vlan10
192.168.10.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.10.255/32 Direct 0 0 192.168.10.1 Vlan10
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
dis ip routing-table vpn-instance vpn-nrt
Destinations : 19 Routes : 19
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 O_INTRA 10 1 10.0.0.2 Vlan500
10.0.0.0/30 Direct 0 0 10.0.0.1 Vlan500
10.0.0.0/32 Direct 0 0 10.0.0.1 Vlan500
10.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
10.0.0.3/32 Direct 0 0 10.0.0.1 Vlan500
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
172.16.10.0/24 O_INTRA 10 2 10.0.0.2 Vlan500
192.168.20.0/24 Direct 0 0 192.168.20.1 Vlan20
192.168.20.0/32 Direct 0 0 192.168.20.1 Vlan20
192.168.20.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.20.255/32 Direct 0 0 192.168.20.1 Vlan20
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[SW2]dis ip routing-table vpn-instance vpn-rt
Destinations : 19 Routes : 19
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 O_INTRA 10 1 10.0.0.1 Vlan400
2.2.2.2/32 Direct 0 0 127.0.0.1 InLoop0
10.0.0.0/30 Direct 0 0 10.0.0.2 Vlan400
10.0.0.0/32 Direct 0 0 10.0.0.2 Vlan400
10.0.0.2/32 Direct 0 0 127.0.0.1 InLoop0
10.0.0.3/32 Direct 0 0 10.0.0.2 Vlan400
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
172.16.20.0/24 Direct 0 0 172.16.20.1 Vlan100
172.16.20.0/32 Direct 0 0 172.16.20.1 Vlan100
172.16.20.1/32 Direct 0 0 127.0.0.1 InLoop0
172.16.20.255/32 Direct 0 0 172.16.20.1 Vlan100
192.168.10.0/24 O_INTRA 10 2 10.0.0.1 Vlan400
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[SW2]
[SW2]dis ip routing-table vpn-instance vpn-nrt
Destinations : 19 Routes : 19
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 O_INTRA 10 1 10.0.0.1 Vlan500
2.2.2.2/32 Direct 0 0 127.0.0.1 InLoop0
10.0.0.0/30 Direct 0 0 10.0.0.2 Vlan500
10.0.0.0/32 Direct 0 0 10.0.0.2 Vlan500
10.0.0.2/32 Direct 0 0 127.0.0.1 InLoop0
10.0.0.3/32 Direct 0 0 10.0.0.2 Vlan500
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
172.16.10.0/24 Direct 0 0 172.16.10.1 Vlan200
172.16.10.0/32 Direct 0 0 172.16.10.1 Vlan200
172.16.10.1/32 Direct 0 0 127.0.0.1 InLoop0
172.16.10.255/32 Direct 0 0 172.16.10.1 Vlan200
192.168.20.0/24 O_INTRA 10 2 10.0.0.1 Vlan500
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[SW2]/<code>
PC填寫相應的IP地址,同VPN實例能互通,不同VPN實例不能互通
同VPN實例能PING通,不同VPN實例不能互通:
至此,多VPN實例OSPF典型組網配置案例已完成!
閱讀更多 思恆科技 的文章