题目


2024-01-08T12:22:05.png

拓扑图


命令


STP(生成树协议)配置:

S1:

(config)#spanning-tree vlan 3,99 priority 4096  # 为 VLAN 3 和 99 设置优先级为 4096
(config)#spanning-tree vlan 4,100 priority 8192 # 为 VLAN 4 和 100 设置优先级为 8192

S2:

(config)#spanning-tree vlan 3,99 priority 8192  # 为 VLAN 3 和 99 设置优先级为 8192
(config)#spanning-tree vlan 4,100 priority 4096 # 为 VLAN 4 和 100 设置优先级为 4096

链路集合配置:

S1:

interface range GigabitEthernet0/1 - 2
 switchport trunk encapsulation dot1q
 switchport mode trunk
 channel-group 1 mode active
!  # 进入子接口范围,配置 trunk 端口

interface Port-channel1
 switchport trunk encapsulation dot1q  # 配置端口通信使用的 VLAN 封装协议为 dot1q
 switchport mode trunk  # 配置端口为 trunk 模式,允许发送和接收所有 VLAN 的数据流量

S2:

interface range GigabitEthernet0/1 - 2
 switchport trunk encapsulation dot1q
 switchport mode trunk
 channel-group 1 mode active
!  # 进入子接口范围,配置 trunk 端口

interface Port-channel1
 switchport trunk encapsulation dot1q  # 配置端口通信使用的 VLAN 封装协议为 dot1q
 switchport mode trunk  # 配置端口为 trunk 模式,允许发送和接收所有 VLAN 的数据流量

主备根配置:

S1:

interface Vlan3                            # 进入 VLAN 3 接口配置模式
  mac-address 0090.21d9.7501               # 配置 VLAN 3 接口的 MAC 地址
  ip address 192.168.3.101 255.255.255.0   # 配置 VLAN 3 接口的 IP 地址和子网掩码
  standby 3 ip 192.168.3.254               # 配置 HSRP 的虚拟 IP 地址
  standby 3 priority 101                   # 配置 HSRP 优先级为 101
  standby 3 preempt                        # 启用 HSRP 抢占模式
  standby 3 track FastEthernet0/21         # 配置接口跟踪,用于优先级降低
  
# 配置 HSRP 主备根,使用接口跟踪
# (以下相同格式,省略注释)

interface Vlan4
mac-address 0090.21d9.7502
ip address 192.168.4.101 255.255.255.0
standby 4 ip 192.168.4.254
standby 4 preempt

interface Vlan99
mac-address 0090.21d9.7503
ip address 192.168.99.101 255.255.255.0
standby 99 ip 192.168.99.254
standby 99 priority 101
standby 99 preempt
standby 99 track FastEthernet0/21

interface Vlan100
mac-address 0090.21d9.7504
ip address 192.168.100.101 255.255.255.0
standby 100 ip 192.168.100.254
standby 100 preempt

S2:

interface Vlan3                            # 进入 VLAN 3 接口配置模式
  mac-address 000c.cf84.d101               # 配置 VLAN 3 接口的 MAC 地址
  ip address 192.168.3.102 255.255.255.0   # 配置 VLAN 3 接口的 IP 地址和子网掩码
  standby 3 ip 192.168.3.254               # 配置 HSRP 的虚拟 IP 地址
  standby 3 preempt                        # 启用 HSRP 抢占模式

# 配置 HSRP 主备根
# (以下相同格式,省略注释)

interface Vlan4
mac-address 000c.cf84.d102
ip address 192.168.4.102 255.255.255.0
standby 4 ip 192.168.4.254
standby 4 priority 101
standby 4 preempt
standby 4 track FastEthernet0/22

interface Vlan99
mac-address 000c.cf84.d103
ip address 192.168.99.102 255.255.255.0
standby 99 ip 192.168.99.254
standby 99 preempt

interface Vlan100
mac-address 000c.cf84.d104
ip address 192.168.100.102 255.255.255.0
standby 100 ip 192.168.100.254
standby 100 priority 101
standby 100 preempt
standby 100 track FastEthernet0/22

OSPF 配置:

S1:

router ospf 1                           # 进入 OSPF 进程配置模式
  router-id 1.1.1.1                      # 配置 OSPF 进程的 Router ID
  log-adjacency-changes                 # 启用日志记录邻居关系更改
  passive-interface Vlan3                # 将 Vlan3 接口设置为被动接口
  passive-interface Vlan4                # 将 Vlan4 接口设置为被动接口
  passive-interface Vlan100              # 将 Vlan100 接口设置为被动接口
  network 192.168.3.0 0.0.0.255 area 0   # 配置网络 192.168.3.0/24 在区域 0
  network 192.168.4.0 0.0.0.255 area 0   # 配置网络 192.168.4.0/24 在区域 0
  network 192.168.99.0 0.0.0.255 area 0  # 配置网络 192.168.99.0/24 在区域 0
  network 192.168.100.0 0.0.0.255 area 0 # 配置网络 192.168.100.0/24 在区域 0
  network 192.168.101.0 0.0.0.255 area 0 # 配置网络 192.168.101.0/24 在区域 0

S2:

bashCopy coderouter ospf 1
router-id 2.2.2.2
 log-adjacency-changes
 passive-interface Vlan3
 passive-interface Vlan4
 passive-interface Vlan100
 network 192.168.3.0 0.0.0.255 area 0
 network 192.168.4.0 0.0.0.255 area 0
 network 192.168.99.0 0.0.0.255 area 0
 network 192.168.100.0 0.0.0.255 area 0
 network 192.168.102.0 0.0.0.255 area 0

ROUTE:

router ospf 1                           # 进入 OSPF 进程配置模式
  router-id 3.3.3.3                      # 配置 OSPF 进程的 Router ID
  log-adjacency-changes                 # 启用日志记录邻居关系更改
  network 192.168.101.0 0.0.0.255 area 0 # 配置网络 192.168.101.0/24 在区域 0
  network 192.168.102.0 0.0.0.255 area 0 # 配置网络 192.168.102.0/24 在区域 0
  default-information originate          # 启用默认信息来源,将缺省路由信息分发至 OSPF

PPP 配置:

R-ZZZ:

username Router-ISP1 password 0 123456  # 配置对方路由器的用户名和密码
interface Serial0/0/0
encapsulation ppp                      # 配置 PPP 封装协议
ppp authentication chap                 # 启用 CHAP 认证方式

!  # 配置 PPP,启用 CHAP 认证方式

S-ISP1:

username RouterZZZ password 0 123456  # 配置对方路由器的用户名和密码
interface Serial0/0/0
encapsulation ppp                      # 配置 PPP 封装协议
ppp authentication chap                 # 启用 CHAP 认证方式

!  # 配置 PPP,启用 CHAP 认证方式

BGP 配置:

R-ZZZ:

router bgp 65000                        # 进入 BGP 进程配置模式,指定本地 AS 号为 65000
neighbor 192.168.2.2 remote-as 65001    # 配置 BGP 邻居,指定对方 AS 号为 65001
network 192.168.3.0                      # 将网络 192.168.3.0/24 广播给 BGP 邻居
network 192.168.4.0                      # 将网络 192.168.4.0/24 广播给 BGP 邻居
network 192.168.100.0                    # 将网络 192.168.100.0/24 广播给 BGP 邻居

!  # 配置 BGP 进程,指定邻居和网络范围

R-ZZZ-Branch:

router bgp 65001                        # 进入 BGP 进程配置模式,指定本地 AS 号为 65001
neighbor 192.168.2.1 remote-as 65000    # 配置 BGP 邻居,指定对方 AS 号为 65000
network 172.16.11.0 mask 255.255.255.0  # 将网络 172.16.11.0/24 广播给 BGP 邻居
network 172.16.12.0 mask 255.255.255.0  # 将网络 172.16.12.0/24 广播给 BGP 邻居

!  # 配置 BGP 进程,指定邻居和网络范围

隧道配置:

R-ZZZ:

interface Tunnel0                     # 进入 Tunnel0 接口配置模式
  ip address 192.168.2.1 255.255.255.0 # 配置 Tunnel0 接口的 IP 地址和子网掩码
  tunnel source Serial0/0/0            # 配置隧道源,即指定封装源地址的接口
  tunnel destination 208.76.54.238     # 配置隧道目标,即指定隧道的目的地 IP 地址
  
!  # 配置 GRE 隧道,指定隧道 IP 地址、源和目的地

R-ZZZ-Branch:

interface Tunnel0                     # 进入 Tunnel0 接口配置模式
  ip address 192.168.2.2 255.255.255.0 # 配置 Tunnel0 接口的 IP 地址和子网掩码
  tunnel source FastEthernet0/1  # 配置隧道源,即指定封装源地址的接口和端口
  tunnel destination 108.76.54.229     # 配置隧道目标,即指定隧道的目的地 IP 地址

!  # 配置 GRE 隧道,指定隧道 IP 地址、源和目的地
文章目录