好消息,超酷的在线虚拟网络实验室上线了!点击开始实验

为获得更好的浏览效果,建议您使用 Firefox 或者 Chrome 浏览器



8.3 多角色主机典型配置

【需求】

属于vpnaPC1192.168.11.2)既可以访问vpna又可以访问vpnb

 

【组网图】

 

【配置脚本】

RT1配置脚本

#

 sysname RT1

#

 router id 1.1.1.1

#

 mpls lsr-id 1.1.1.1

#

radius scheme system

#

mpls

#

 mpls ldp

#

ip vpn-instance vpna

 route-distinguisher 100:1

 vpn-target 100:1 export-extcommunity

 vpn-target 100:1 import-extcommunity

#

ip vpn-instance vpnb

 route-distinguisher 200:1

 vpn-target 200:1 export-extcommunity

 vpn-target 200:1 import-extcommunity

#

domain system

#                                        

acl number 3000              /指定多角色主机的地址,用于策略路由中使用/

 rule 0 permit ip vpn-instance vpna source 192.168.11.2 0

#

interface Ethernet1/0/0

 ip binding vpn-instance vpna

 ip address 192.168.11.1 255.255.255.0

 ip policy route-policy multi-role          

/在接口上应用策略路由,实现多角色主机功能/

#

interface Serial2/0/0

 link-protocol ppp

 ip address 10.0.0.1 255.255.255.252

 mpls

 mpls ldp enable

#

interface NULL0

#

interface LoopBack0

 ip address 1.1.1.1 255.255.255.255

#

interface LoopBack21

 ip binding vpn-instance vpnb

 ip address 192.168.21.1 255.255.255.0

#

bgp 100

 undo synchronization                    

 group inter internal                    

 peer 2.2.2.2 group inter                

 peer 2.2.2.2 connect-interface LoopBack0

 #

 ipv4-family vpn-instance vpna

  import-route direct

  undo synchronization

 #

 ipv4-family vpn-instance vpnb

  import-route direct

  import-route static                      /vpnb中引入静态路由/

  undo synchronization

 #

 ipv4-family vpnv4

  peer inter enable

  peer 2.2.2.2 group inter

#

ospf 1

 area 0.0.0.0

  network 1.1.1.1 0.0.0.0

  network 10.0.0.0 0.0.0.3

#

route-policy multi-role permit node 10      

/定义策略路由,实现多角色主机在vpnb中查找路由/

 if-match acl 3000                           /引用ACL 3000/

 apply access-vpn vpn-instance vpnb          /实现多角色主机在vpnb中查找路由/

#                                         

 ip route-static vpn-instance vpnb 192.168.11.2 255.255.255.255 vpn-instance vpna 192.168.11.2  preference 60

/vpnb中添加一条访问PC1的静态路由,保证vpnb的返回报文可以转发给PC1 /

#                                        

user-interface con 0

user-interface vty 0 4

#

return

RT2配置脚本

#

 sysname RT2

#

 router id 2.2.2.2

#

 mpls lsr-id 2.2.2.2

#

radius scheme system

#

mpls

#

 mpls ldp

#

ip vpn-instance vpna

 route-distinguisher 100:1

 vpn-target 100:1 export-extcommunity

 vpn-target 100:1 import-extcommunity

#

ip vpn-instance vpnb

 route-distinguisher 200:1

 vpn-target 200:1 export-extcommunity

 vpn-target 200:1 import-extcommunity

#

domain system

#                                        

interface Serial2/0/0                    

 link-protocol ppp

 ip address 10.0.0.2 255.255.255.252

 mpls

 mpls ldp enable

#

interface Serial2/0/1

 link-protocol ppp

 ip address 10.0.0.5 255.255.255.252

 mpls

 mpls ldp enable

#

interface NULL0

#

interface LoopBack0

 ip address 2.2.2.2 255.255.255.255

#

interface LoopBack12

 ip binding vpn-instance vpna

 ip address 192.168.12.1 255.255.255.0

#

interface LoopBack22

 ip binding vpn-instance vpnb

 ip address 192.168.22.1 255.255.255.0

#                                        

bgp 100                                  

 undo synchronization                     

 group inter internal

 peer inter reflect-client

 peer 1.1.1.1 group inter

 peer 1.1.1.1 connect-interface LoopBack0

 peer 3.3.3.3 group inter

 peer 3.3.3.3 connect-interface LoopBack0

 #

 ipv4-family vpn-instance vpna

  import-route direct

  undo synchronization

 #

 ipv4-family vpn-instance vpnb

  import-route direct

  undo synchronization

 #

 ipv4-family vpnv4

  peer inter enable

  peer inter reflect-client

  peer 1.1.1.1 group inter

  peer 3.3.3.3 group inter

#

ospf 1

 area 0.0.0.0

  network 2.2.2.2 0.0.0.0                

  network 10.0.0.0 0.0.0.3               

  network 10.0.0.4 0.0.0.3               

#

user-interface con 0

user-interface vty 0 4

#

return

RT3配置脚本

#

 sysname RT3

#

 router id 3.3.3.3

#

 mpls lsr-id 3.3.3.3

#

radius scheme system

#

mpls

#

 mpls ldp

#

ip vpn-instance vpna

 route-distinguisher 100:1

 vpn-target 100:1 export-extcommunity

 vpn-target 100:1 import-extcommunity

#

ip vpn-instance vpnb

 route-distinguisher 200:1

 vpn-target 200:1 export-extcommunity

 vpn-target 200:1 import-extcommunity

#

domain system

#                                        

interface Serial2/0/0                    

 link-protocol ppp

 ip address 10.0.0.6 255.255.255.252

 mpls

 mpls ldp enable

#

interface NULL0

#

interface LoopBack0

 ip address 3.3.3.3 255.255.255.255

#

interface LoopBack13

 ip binding vpn-instance vpna

 ip address 192.168.13.1 255.255.255.0

#

interface LoopBack23

 ip binding vpn-instance vpnb

 ip address 192.168.23.1 255.255.255.0

#

bgp 100

 undo synchronization

 group inter internal

 peer 2.2.2.2 group inter

 peer 2.2.2.2 connect-interface LoopBack0

 #                                       

 ipv4-family vpn-instance vpna           

  import-route direct                    

  undo synchronization

 #

 ipv4-family vpn-instance vpnb

  import-route direct

  undo synchronization

 #

 ipv4-family vpnv4

  peer inter enable

  peer 2.2.2.2 group inter

#

ospf 1

 area 0.0.0.0

  network 3.3.3.3 0.0.0.0

  network 10.0.0.4 0.0.0.3

#

user-interface con 0

user-interface vty 0 4

#

return   

 


【配置要点】

通过配置静态路由路由策略,使PC1访问不同VPN的报文在不同的VPN-instance中查找路由

 

【验证】

RT1上vpnb的私网路由表:

disp ip rout vpn vpnb

  vpnb   Route Information

 Routing Table:  vpnb   Route-Distinguisher:   200:1

Destination/Mask   Protocol Pre  Cost        Nexthop         Interface

192.168.11.2/32    STATIC   60   0           192.168.11.2    Ethernet1/0/0

192.168.21.0/24    DIRECT   0    0           192.168.21.1    LoopBack21

192.168.21.1/32    DIRECT   0    0           127.0.0.1       InLoopBack0

192.168.22.0/24    BGP      256  0           2.2.2.2         InLoopBack0

192.168.23.0/24    BGP      256  0           3.3.3.3         InLoopBack0

 

RT3上vpnb的私网路由表:

disp ip rout vpn vpnb

  vpnb   Route Information

 Routing Table:  vpnb   Route-Distinguisher:   200:1

Destination/Mask   Protocol Pre  Cost        Nexthop         Interface

192.168.11.2/32    BGP      256  0           1.1.1.1         InLoopBack0

192.168.21.0/24    BGP      256  0           1.1.1.1         InLoopBack0

192.168.22.0/24    BGP      256  0           2.2.2.2         InLoopBack0

192.168.23.0/24    DIRECT   0    0           192.168.23.1    LoopBack23

192.168.23.1/32    DIRECT   0    0           127.0.0.1       InLoopBack0

 

 

【提示】

1 多角色主机的配置都在和该主机相连的PE上完成。

2 当存在多个VPN时,可以使用apply access-vpn vpn-instance指定多个VPN,但是最多可以指定6VPN

3、通过配置静态路由路由策略,使PC1访问不同VPN的报文在不同的VPN-instance中查找路由

 

X Close
X Close