OSPF和bgp配置实例

OSPF和bgp配置实例_第1张图片

组网需求:

某公司有一个总部和两个分部,其公司网络拥有3个自治系统:AS100、AS200、AS300。AS100是总部网络,AS200和AS300是两个分部网络,自治系统内运行OSPF。总部和两个分部之间运行BGP协议进行互联。客户希望,分部之间可以经过总部核心网络互访。同时,通过配置路由策略,使OSPF和BGP交互时,通过路由策略控制引入的路由信息,只引入需要的路由信息。


sysname ce1

interface GE1/0/0
 undo portswitch
 undo shutdown
 ip address 192.168.10.1 255.255.255.0
#
interface GE1/0/1
 undo portswitch
 undo shutdown
 ip address 192.168.30.1 255.255.255.0
#
interface GE1/0/2
 undo portswitch
 undo shutdown
 ip address 192.168.20.1 255.255.255.0

#
interface LoopBack0
 ip address 10.1.1.1 255.255.255.255
#
interface NULL0
#
bfd 3 bind peer-ip 1.1.1.1
#
bgp 100
 router-id 10.1.1.1
 peer 192.168.10.2 as-number 200
 peer 192.168.20.2 as-number 300
 peer 192.168.30.2 as-number 100
 #
 ipv4-family unicast
  network 192.168.10.0 255.255.255.0
  network 192.168.20.0 255.255.255.0
  network 192.168.30.0 255.255.255.0
  peer 192.168.10.2 enable
  peer 192.168.20.2 enable
  peer 192.168.30.2 enable


return

sysname CE2
interface MEth0/0/0
 undo shutdown
#
interface GE1/0/0
 undo portswitch
 undo shutdown
 ip address 192.168.40.1 255.255.255.0
#
interface GE1/0/1
 undo portswitch
 undo shutdown
 ip address 192.168.30.2 255.255.255.0
#
interface GE1/0/2
 undo portswitch
 undo shutdown
 ip address 192.168.50.1 255.255.255.0

interface LoopBack0
 ip address 10.2.2.2 255.255.255.255
#
interface NULL0
#
bgp 100
 router-id 10.2.2.2
 peer 192.168.30.1 as-number 100
 peer 192.168.40.2 as-number 300
 peer 192.168.50.2 as-number 200
 #
 ipv4-family unicast
  network 192.168.30.0 255.255.255.0
  network 192.168.40.0 255.255.255.0
  network 192.168.50.0 255.255.255.0
  peer 192.168.30.1 enable
  peer 192.168.40.2 enable
  peer 192.168.50.2 enable

return

sysname SW1

interface Vlanif10
 ip address 192.168.10.2 255.255.255.0
#
interface Vlanif20
 ip address 192.168.50.2 255.255.255.0
#
interface Vlanif30
 ip address 192.168.60.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 10
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 20
#
interface GigabitEthernet0/0/4
 port link-type access
 port default vlan 10

interface LoopBack0
 ip address 10.3.3.3 255.255.255.255
#
bgp 200
 router-id 10.3.3.3
 peer 192.168.10.1 as-number 100
 peer 192.168.50.1 as-number 100
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.10.0
  network 192.168.50.0
  network 192.168.60.0
  import-route ospf 1
  peer 192.168.10.1 enable
  peer 192.168.50.1 enable
#
ospf 1 router-id 10.4.4.4
 import-route bgp route-policy ospf_import
 area 0.0.0.0
  network 192.168.10.0 0.0.0.255
  network 192.168.60.0 0.0.0.255
  network 192.168.50.0 0.0.0.255
#
route-policy 10 permit node 10
 if-match ip-prefix ospf_import
#
ip ip-prefix ospf_import index 10 permit 166.3.2.0 24
#
user-interface con 0
user-interface vty 0 4
#
return

sysname SW2

#
interface Vlanif10
 ip address 192.168.20.2 255.255.255.0
#
interface Vlanif20
 ip address 192.168.40.2 255.255.255.0
#
interface Vlanif30
 ip address 192.168.70.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 20
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 10

interface LoopBack0
 ip address 10.4.4.4 255.255.255.255
#
bgp 300
 router-id 10.4.4.4
 peer 192.168.20.1 as-number 100
 peer 192.168.40.1 as-number 100
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.20.0
  network 192.168.40.0
  network 192.168.70.0
  import-route ospf 1
  peer 192.168.20.1 enable
  peer 192.168.40.1 enable
#
ospf 1 router-id 10.4.4.4
 import-route bgp route-policy ospf_import
 area 0.0.0.0
  network 192.168.20.0 0.0.0.255
  network 192.168.40.0 0.0.0.255
  network 192.168.70.0 0.0.0.255
#
route-policy 10 permit node 10
 if-match ip-prefix ospf_import
#
ip ip-prefix ospf_import index 10 permit 166.2.2.0 24

#
return

sysname SW3

#
interface Vlanif10
 ip address 192.168.60.2 255.255.255.0
#
interface Vlanif20
 ip address 166.2.1.1 255.255.255.0
#
interface Vlanif30
 ip address 166.2.2.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 10
#
interface GigabitEthernet0/0/23
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/24
 port link-type access
 port default vlan 20
#
interface NULL0
#
interface LoopBack0
 ip address 10.5.5.5 255.255.255.255
#
ospf 1 router-id 10.5.5.5
 area 0.0.0.0
  network 192.168.60.0 0.0.0.255
  network 166.2.1.0 0.0.0.255
  network 166.2.2.0 0.0.0.255
#
user-interface con 0
user-interface vty 0 4
#
returnsysname SW6
#
vlan batch 10 20 30

#
interface Vlanif10
 ip address 192.168.70.2 255.255.255.0
#
interface Vlanif20
 ip address 166.3.1.1 255.255.255.0
#
interface Vlanif30
 ip address 166.3.2.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 10
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 20
#
#
interface GigabitEthernet0/0/24
 port link-type access
 port default vlan 30
#
interface NULL0
#
interface LoopBack0
 ip address 10.6.6.6 255.255.255.255
#
ospf 1 router-id 10.6.6.6
 area 0.0.0.0
  network 192.168.70.0 0.0.0.255
  network 166.3.1.0 0.0.0.255
  network 166.3.2.0 0.0.0.255

return






你可能感兴趣的:(OSPF和bgp配置实例)