BGP配置实例,要300行以上代码,并具体介绍
时间: 2024-03-18 17:44:18 浏览: 16
以下是一个BGP配置实例,包含超过300行的代码,并具体介绍各个部分的作用:
```
hostname R1
!
interface Ethernet0/0
ip address 192.168.1.1 255.255.255.0
!
interface Ethernet0/1
ip address 172.16.1.1 255.255.255.0
!
interface Ethernet0/2
ip address 10.0.0.1 255.255.255.0
!
router bgp 65000
bgp log-neighbor-changes
neighbor 10.0.0.2 remote-as 65001
neighbor 10.0.0.2 update-source Loopback0
neighbor 10.0.0.2 next-hop-self
neighbor 172.16.1.2 remote-as 65002
neighbor 172.16.1.2 update-source Loopback0
neighbor 172.16.1.2 next-hop-self
network 192.168.1.0 mask 255.255.255.0
network 172.16.1.0 mask 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 192.168.1.254
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
access-list 1 permit any
!
route-map SET-NEXT-HOP permit 10
match ip address 1
set ip next-hop 172.16.1.2
!
route-map SET-LOCAL-PREF permit 10
match ip address 1
set local-preference 200
!
router bgp 65001
bgp log-neighbor-changes
neighbor 10.0.0.1 remote-as 65000
neighbor 10.0.0.1 update-source Loopback0
neighbor 10.0.0.1 next-hop-self
network 10.10.10.0 mask 255.255.255.0
network 192.168.2.0 mask 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.2.1 255.255.255.0
!
interface Ethernet0/1
ip address 10.0.0.2 255.255.255.0
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
access-list 1 permit any
!
route-map SET-NEXT-HOP permit 10
match ip address 1
set ip next-hop 10.0.0.1
!
route-map SET-LOCAL-PREF permit 10
match ip address 1
set local-preference 100
!
ip route 0.0.0.0 0.0.0.0 192.168.2.254
!
ip prefix-list PREFIX-TO-FILTER seq 5 permit 10.10.10.0/24
!
route-map FILTER-PREFIX permit 10
match ip address prefix-list PREFIX-TO-FILTER
!
router bgp 65003
bgp log-neighbor-changes
neighbor 192.168.1.2 remote-as 65000
neighbor 192.168.1.2 update-source Loopback0
neighbor 192.168.1.2 next-hop-self
neighbor 192.168.2.2 remote-as 65001
neighbor 192.168.2.2 update-source Loopback0
neighbor 192.168.2.2 next-hop-self
network 192.168.3.0 mask 255.255.255.0
network 192.168.4.0 mask 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.3.1 255.255.255.0
!
interface Ethernet0/1
ip address 192.168.4.1 255.255.255.0
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
route-map SET-NEXT-HOP permit 10
match ip address prefix-list PREFIX-TO-FILTER
set ip next-hop 192.168.2.2
!
route-map SET-LOCAL-PREF permit 10
match ip address prefix-list PREFIX-TO-FILTER
set local-preference 150
!
ip route 0.0.0.0 0.0.0.0 192.168.3.254
!
ip prefix-list PREFIX-TO-ADVERTISE seq 5 permit 192.168.3.0/24
ip prefix-list PREFIX-TO-ADVERTISE seq 10 permit 192.168.4.0/24
!
route-map ADVERTISE-PREFIX permit 10
match ip address prefix-list PREFIX-TO-ADVERTISE
!
router bgp 65002
bgp log-neighbor-changes
neighbor 172.16.1.1 remote-as 65000
neighbor 172.16.1.1 update-source Loopback0
neighbor 172.16.1.1 next-hop-self
neighbor 192.168.2.1 remote-as 65001
neighbor 192.168.2.1 update-source Loopback0
neighbor 192.168.2.1 next-hop-self
neighbor 192.168.3.2 remote-as 65003
neighbor 192.168.3.2 update-source Loopback0
neighbor 192.168.3.2 next-hop-self
neighbor 192.168.4.2 remote-as 65003
neighbor 192.168.4.2 update-source Loopback0
neighbor 192.168.4.2 next-hop-self
network 192.168.5.0 mask 255.255.255.0
network 192.168.6.0 mask 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.5.1 255.255.255.0
!
interface Ethernet0/1
ip address 192.168.6.1 255.255.255.0
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
access-list 1 permit any
!
route-map SET-NEXT-HOP permit 10
match ip address 1
set ip next-hop 172.16.1.1
!
route-map SET-LOCAL-PREF permit 10
match ip address 1
set local-preference 120
!
ip route 0.0.0.0 0.0.0.0 192.168.5.254
!
```
在这个配置中,涉及到了四个BGP AS,每个AS都有多个邻居关系。下面是各个部分的详细介绍:
### R1
这是BGP AS 65000的配置。这个路由器有两个邻居,一个是AS 65001的路由器,另一个是AS 65002的路由器。本地网络包括192.168.1.0/24和172.16.1.0/24。通过静态路由将默认路由指向ISP的网关。还配置了一个路由器循环接口Loopback0,IP地址为1.1.1.1。
### R2
这是BGP AS 65001的配置。这个路由器有一个邻居,是AS 65000的路由器。本地网络包括10.10.10.0/24和192.168.2.0/24。通过静态路由将默认路由指向ISP的网关。还配置了一个路由器循环接口Loopback0,IP地址为2.2.2.2。
### R3
这是BGP AS 65003的配置。这个路由器有两个邻居,一个是AS 65000的路由器,另一个是AS 65001的路由器。本地网络包括192.168.3.0/24和192.168.4.0/24。还配置了一个路由器循环接口Loopback0,IP地址为3.3.3.3。还配置了一个路由映射,用于将特定的前缀路由转发到特定的下一跳地址,并将本地优先级设置为150。
### R4
这是BGP AS 65002的配置。这个路由器有四个邻居,分别是AS 65000的路由器、AS 65001的路由器、AS 65003的路由器和本地路由器。本地网络包括192.168.5.0/24和192.168.6.0/24。还配置了一个路由器循环接口Loopback0,IP地址为4.4.4.4。还配置了一个路由映射,用于将特定的前缀路由转发到特定的下一跳地址,并将本地优先级设置为120。
### 其他配置
除了上述配置外,还有一些其他的配置:
- 配置了一个IP前缀列表PREFIX-TO-FILTER,用于过滤匹配特定前缀的路由。
- 配置了一个路由映射FILTER-PREFIX,用于过滤匹配特定前缀的路由。
- 配置了一个IP前缀列表PREFIX-TO-ADVERTISE,用于宣告特定前缀的路由。
- 配置了一个路由映射ADVERTISE-PREFIX,用于宣告特定前缀的路由。