A-A+

隔离公司各个部门——虚拟路由器(OSPF)的使用方法

2015年11月20日 站长资讯 暂无评论

在很多企业网里,为了隔离公司的各个不同的业务部门,就需要建立虚拟路由器(ospf),下面以此为例子来说明其配置和使用方法。

首先公司网络的拓扑图:

R4配置:

  1. ip vrf retail  
  2. rd 1:1  
  3. !   
  4. ip vrf trading  
  5. rd 2:2  
  6. !  
  7. interface Loopback0  
  8. ip address 4.4.4.4 255.255.255.255  
  9. !  
  10. interface Loopback1  
  11. ip vrf forwarding trading  
  12. ip address 20.1.1.4 255.255.255.0  
  13. ip ospf network point-to-point  
  14. !  
  15. interface FastEthernet0/0  
  16. ip vrf forwarding retail  
  17. ip address 10.1.1.4 255.255.255.0  
  18. duplex auto  
  19. speed auto  
  20. !  
  21. interface FastEthernet0/1  
  22. no ip address  
  23. duplex auto  
  24. speed auto  
  25. !  
  26. interface FastEthernet0/1.100  
  27. encapsulation dot1Q 100  
  28. ip vrf forwarding retail  
  29. ip address 192.168.14.4 255.255.255.0  
  30. !  
  31. interface FastEthernet0/1.200  
  32. encapsulation dot1Q 200  
  33. ip vrf forwarding trading  
  34. ip address 172.16.14.4 255.255.255.0  
  35. !  
  36. router ospf 100 vrf retail  
  37. log-adjacency-changes  
  38. network 10.1.1.0 0.0.0.255 area 0  
  39. network 192.168.14.0 0.0.0.255 area 0   
  40. !  
  41. router ospf 200 vrf trading  
  42. log-adjacency-changes  
  43. network 20.1.1.0 0.0.0.255 area 0  
  44. network 172.16.14.0 0.0.0.255 area 0  

R5配置:

  1. ip vrf retail  
  2. rd 1:1  
  3. !   
  4. ip vrf trading  
  5. rd 2:2  
  6. !  
  7. interface Loopback0  
  8. ip address 5.5.5.5 255.255.255.255  
  9. !  
  10. interface Loopback1  
  11. ip vrf forwarding trading  
  12. ip address 40.1.1.5 255.255.255.0  
  13. ip ospf network point-to-point  
  14. !  
  15. interface FastEthernet0/0  
  16. no ip address  
  17. duplex auto  
  18. speed auto  
  19. !  
  20. interface FastEthernet0/0.100  
  21. encapsulation dot1Q 100  
  22. ip vrf forwarding retail  
  23. ip address 192.168.35.5 255.255.255.0  
  24. !  
  25. interface FastEthernet0/0.200  
  26. encapsulation dot1Q 200  
  27. ip vrf forwarding trading  
  28. ip address 172.16.35.5 255.255.255.0  
  29. !  
  30. interface FastEthernet0/1  
  31. ip vrf forwarding retail  
  32. ip address 30.1.1.5 255.255.255.0  
  33. duplex auto  
  34. speed auto  
  35. !  
  36. router ospf 100 vrf retail  
  37. log-adjacency-changes  
  38. network 30.1.1.0 0.0.0.255 area 0  
  39. network 192.168.35.0 0.0.0.255 area 0  
  40.   
  41.   
  42. !  
  43. router ospf 200 vrf trading  
  44. log-adjacency-changes  
  45. network 40.1.1.0 0.0.0.255 area 0  
  46. network 172.16.35.0 0.0.0.255 area 0  

R1配置:

  1. ip vrf retail  
  2. rd 100:100  
  3. route-target export 100:100  
  4. route-target import 100:100  
  5. !  
  6. ip vrf trading  
  7. rd 100:200  
  8. route-target export 100:200  
  9. route-target import 100:200  
  10. !  
  11. mpls label range 100 199  
  12. mpls label protocol ldp  
  13. !  
  14. interface Loopback0  
  15. ip address 1.1.1.1 255.255.255.255  
  16. http://www.xiaoxiongboke.com   
  17. !  
  18. interface FastEthernet0/0  
  19. ip address 12.1.1.1 255.255.255.0  
  20. duplex auto  
  21. speed auto  
  22. mpls ip  
  23. !  
  24. interface FastEthernet0/1  
  25. no ip address  
  26. duplex auto  
  27. speed auto  
  28. !  
  29. interface FastEthernet0/1.100  
  30. encapsulation dot1Q 100  
  31. ip vrf forwarding retail  
  32. ip address 192.168.14.1 255.255.255.0  
  33. !  
  34. interface FastEthernet0/1.200  
  35. encapsulation dot1Q 200  
  36.   
  37.   
  38. ip vrf forwarding trading  
  39. ip address 172.16.14.1 255.255.255.0  
  40. !   
  41. router ospf 110 vrf retail  
  42. log-adjacency-changes  
  43. redistribute bgp 100 subnets  
  44. network 192.168.14.0 0.0.0.255 area 0  
  45. !  
  46. router ospf 210 vrf trading  
  47. log-adjacency-changes  
  48. redistribute bgp 100 subnets  
  49. network 172.16.14.0 0.0.0.255 area 0  
  50. !  
  51. router ospf 100  
  52. router-id 1.1.1.1  
  53. log-adjacency-changes  
  54. network 1.1.1.1 0.0.0.0 area 0  
  55. network 12.1.1.0 0.0.0.255 area 0  
  56. !  
  57. router bgp 100  
  58. bgp router-id 1.1.1.1  
  59. no bgp default ipv4-unicast  
  60. bgp log-neighbor-changes  
  61. neighbor 3.3.3.3 remote-as 100  
  62. neighbor 3.3.3.3 update-source Loopback0  
  63. !   
  64. address-family vpnv4  
  65. neighbor 3.3.3.3 activate  
  66. neighbor 3.3.3.3 send-community extended  
  67. exit-address-family  
  68. !  
  69. address-family ipv4 vrf trading  
  70. redistribute ospf 210 vrf trading match internal external 1 external 2 nssa-external 1 nssa-external 2   
  71. no synchronization  
  72. exit-address-family  
  73. !  
  74. address-family ipv4 vrf retail  
  75. redistribute ospf 110 vrf retail match internal external 1 external 2 nssa-external 1 nssa-external 2  
  76. no synchronization  
  77. exit-address-family  
  78. !  
  79. mpls ldp router-id Loopback0  

R2配置:

  1. mpls label range 200 299  
  2. mpls label protocol ldp  
  3. interface Loopback0  
  4. ip address 2.2.2.2 255.255.255.255  
  5. !  
  6. interface FastEthernet0/0  
  7. ip address 12.1.1.2 255.255.255.0  
  8. duplex auto  
  9. speed auto  
  10. mpls ip  
  11. !  
  12. interface FastEthernet0/1  
  13. ip address 23.1.1.2 255.255.255.0  
  14. duplex auto  
  15. speed auto  
  16. mpls ip  
  17. !  
  18. router ospf 100  
  19. router-id 2.2.2.2  
  20. log-adjacency-changes  
  21. network 2.2.2.2 0.0.0.0 area 0  
  22. network 12.1.1.0 0.0.0.255 area 0  
  23. network 23.1.1.0 0.0.0.255 area 0  
  24. !  
  25. mpls ldp router-id Loopback0  

R3配置:

  1. ip vrf retail  
  2. rd 100:100  
  3. route-target export 100:100  
  4. route-target import 100:100  
  5. !  
  6. ip vrf trading  
  7. rd 100:200  
  8. route-target export 100:200  
  9. route-target import 100:200  
  10. !  
  11. mpls label range 300 399  
  12. mpls label protocol ldp  
  13. interface Loopback0  
  14. ip address 3.3.3.3 255.255.255.255  
  15. !  
  16. interface FastEthernet0/0  
  17. no ip address  
  18. duplex auto  
  19. speed auto  
  20. !  
  21. interface FastEthernet0/0.100  
  22. encapsulation dot1Q 100  
  23. ip vrf forwarding retail  
  24. ip address 192.168.35.3 255.255.255.0  
  25. !  
  26. interface FastEthernet0/0.200  
  27. encapsulation dot1Q 200  
  28. ip vrf forwarding trading  
  29. ip address 172.16.35.3 255.255.255.0  
  30. !  
  31. interface FastEthernet0/1  
  32. ip address 23.1.1.3 255.255.255.0  
  33. duplex auto  
  34. speed auto  
  35. mpls ip  
  36. !   
  37. router ospf 110 vrf retail  
  38. log-adjacency-changes  
  39. redistribute bgp 100 subnets  
  40. network 192.168.35.0 0.0.0.255 area 0  
  41.   
  42.   
  43. !  
  44. router ospf 210 vrf trading  
  45. log-adjacency-changes  
  46. redistribute bgp 100 subnets  
  47. network 172.16.35.0 0.0.0.255 area 0  
  48. !  
  49. router ospf 100  
  50. router-id 3.3.3.3  
  51. log-adjacency-changes  
  52. network 3.3.3.3 0.0.0.0 area 0  
  53. network 23.1.1.0 0.0.0.255 area 0  
  54. !  
  55. router bgp 100  
  56. bgp router-id 3.3.3.3  
  57. no bgp default ipv4-unicast  
  58. bgp log-neighbor-changes  
  59. neighbor 1.1.1.1 remote-as 100  
  60. neighbor 1.1.1.1 update-source Loopback0  
  61. !   
  62. address-family vpnv4  
  63. neighbor 1.1.1.1 activate  
  64. neighbor 1.1.1.1 send-community extended  
  65. exit-address-family  
  66. !  
  67. address-family ipv4 vrf trading  
  68. redistribute ospf 210 vrf trading match internal external 1 external 2 nssa-external 1 nssa-external 2  
  69. no synchronization  
  70. exit-address-family  
  71. !  
  72. address-family ipv4 vrf retail  
  73. redistribute ospf 110 vrf retail match internal external 1 external 2 nssa-external 1 nssa-external 2   
  74. no synchronization  
  75. exit-address-family  
  76. !  
  77. mpls ldp router-id Loopback0  

验证:

从上图可以看出并没有收到同一部门的路由,查看OSPF数据库

从上图可以看出路由已经放进了OSPF 的数据库,但是由于设置了down选项,OSPF检查忽略了这些路由。

解决办法:

禁用DOWN检查

验证:

标签:

给我留言