首先配置好底层互通:
1.配置IP
2.配置isis (环回口也需开启isis)
3.配置mpls
配置完检查是否正常通信:dis mpls lsp (检查标签) dis fib(检查转发表)
4.重点配置:
[R2]bgp 200
[R2-bgp]router-id 2.2.2.2
[R2-bgp]undo default ipv4-unicast //关闭普通ipv4地址族
[R2-bgp]peer 5.5.5.5 as-number 200
[R2-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[R2-bgp]ipv4-family vpnv4 //在vpnv4地址簇下使能5.5.5.5这个邻居
[R2-bgp-af-vpnv4]peer 5.5.5.5 enable
[R5]bgp 200
[R5-bgp]router-id 5.5.5.5
[R5-bgp]undo default ipv4-unicast
[R5-bgp]peer 2.2.2.2 as-number 200
[R5-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R5-bgp]ipv4-family vpnv4
[R5-bgp-af-vpnv4]peer 2.2.2.2 enable
[R2]ip vpn-instance 1 //创建VPN实例
[R2-vpn-instance-1]ipv4-family //进入VPN ipv4视图
[R2-vpn-instance-1-af-ipv4]route-distinguisher 2:2 //配置RD
[R2-vpn-instance-1-af-ipv4]vpn-target 2:5 export-extcommunity //配置去往5的RT
[R2-vpn-instance-2-af-ipv4]vpn-target 5:2 import-extcommunity //配置5回来的RT
[R5]ip vpn-instance 2 //创建VPN实例
[R5-vpn-instance-2]ipv4-family //进入VPN ipv4视图
[R5-vpn-instance-2-af-ipv4]route-distinguisher 5:5 //配置RD
[R5-vpn-instance-2-af-ipv4]vpn-target 2:5 import-extcommunity //配置2过来的RT
[R5-vpn-instance-2-af-ipv4]vpn-target 5:2 export-extcommunity //配置去往2的RT
在VPN实例里建立EBGP邻居
[R2]bgp 200
[R2-bgp]ipv4-family vpn-instance 1
[R2-bgp-1]peer 12.1.1.1 as-number 100
[R5]bgp 200
[R5-bgp]ipv4-family vpn-instance 2
[R5-bgp-2]peer 56.1.1.6 as-number 300
[R2]interface GigabitEthernet 0/0/0 //将该接口绑定VPN实例
[R2-GigabitEthernet0/0/0]ip binding vpn-instance 1
[R2-GigabitEthernet0/0/0]ip address 12.1.1.2 255.255.255.0
[R5]interface GigabitEthernet 0/0/1 //将该接口绑定VPN实例
[R5-GigabitEthernet0/0/1]ip binding vpn-instance 2
[R5-GigabitEthernet0/0/1]ip address 56.1.1.5 255.255.255.0
查看bgp vpnv4路由
[R2]dis bgp vpnv4 all routing-table
BGP Local router ID is 2.2.2.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total number of routes from all PE: 2
Route Distinguisher: 2:2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 12.1.1.1 0 0 100i
Route Distinguisher: 5:5
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 6.6.6.6/32 5.5.5.5 0 100 0 300i
VPN-Instance 1, Router ID 2.2.2.2:
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 12.1.1.1 0 0 100i
*>i 6.6.6.6/32 5.5.5.5 0 100 0 300i
<R5>dis bgp vpnv4 all routing-table
BGP Local router ID is 5.5.5.5
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total number of routes from all PE: 2
Route Distinguisher: 2:2
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 2.2.2.2 0 100 0 100i
Route Distinguisher: 5:5
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 6.6.6.6/32 56.1.1.6 0 0 300i
VPN-Instance 2, Router ID 5.5.5.5:
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 2.2.2.2 0 100 0 100i
*> 6.6.6.6/32 56.1.1.6 0 0 300i