实验环境 准备四台交换机分别命令为SW1、SW2、SW3、SW4; 需求如下: SW1接口配置
#
interface GigabitEthernet0/0/0
description to SW2_G0/0/0
ip address 1.1.1.1 255.255.255.252
#
interface GigabitEthernet0/0/3
description to SW4_G0/0/3
ip address 1.1.1.14 255.255.255.252
#
interface LoopBack1
ip address 192.168.1.254 255.255.255.0
#
SW2接口配置
#
interface GigabitEthernet0/0/0
description to SW1_G0/0/0
ip address 1.1.1.2 255.255.255.252
#
interface GigabitEthernet0/0/1
description to SW3_G0/0/1
ip address 1.1.1.5 255.255.255.252
#
interface LoopBack2
ip address 192.168.2.254 255.255.255.0
#
SW3接口配置
#
interface GigabitEthernet0/0/1
description to SW2_G0/0/1
ip address 1.1.1.6 255.255.255.252
#
interface GigabitEthernet0/0/2
description to SW4_G0/0/2
ip address 1.1.1.9 255.255.255.252
#
interface LoopBack3
ip address 192.168.3.254 255.255.255.0
#
SW4接口配置
#
interface Vlanif22
ip address 192.168.22.254 255.255.255.0
#
interface Ethernet0/0/0
portswitch
port link-type access
port default vlan 22
#
interface GigabitEthernet0/0/2
description to SW3_G0/0/2
ip address 1.1.1.10 255.255.255.252
#interface LoopBack4
ip address 192.168.4.254 255.255.255.0
#
interface GigabitEthernet0/0/3
description to SW1_G0/0/3
ip address 1.1.1.13 255.255.255.252
#
PC接口配置
分别测试连通性
ospf配置 创建ospf 进程1 router-id 为loopback接口地址,区域为1,宣告所有直连地址,引入import-route, SW1
#
ospf 1 router-id 192.168.1.254
import-route direct
area 0.0.0.1
network 1.1.1.0 0.0.0.3
network 1.1.1.12 0.0.0.3
#
return
SW2
#
ospf 1 router-id 192.168.2.254
import-route direct
area 0.0.0.1
network 1.1.1.4 0.0.0.3
network 1.1.1.0 0.0.0.3
#
return
SW3
#
ospf 1 router-id 192.168.3.254
import-route direct
area 0.0.0.1
network 1.1.1.4 0.0.0.3
network 1.1.1.8 0.0.0.3
#
return
SW4
#
ospf 1 router-id 192.168.4.254
import-route direct
area 0.0.0.1
network 1.1.1.8 0.0.0.3
network 1.1.1.12 0.0.0.3
#
return
通过利用路由引入,将直连路由引入,简化命令配置 利用PC1做ping测试 交换机配置脚本
<SW1>display current-configuration
#
sysname SW1
#
interface GigabitEthernet0/0/0
description to SW2_G0/0/0
ip address 1.1.1.1 255.255.255.252
#
interface GigabitEthernet0/0/3
description to SW4_G0/0/3
ip address 1.1.1.14 255.255.255.252
#
interface LoopBack1
ip address 192.168.1.254 255.255.255.0
#
ospf 1 router-id 192.168.1.254
import-route direct
area 0.0.0.1
network 1.1.1.0 0.0.0.3
network 1.1.1.12 0.0.0.3
#
return
<SW2>display current-configuration
#
sysname SW2
#
interface GigabitEthernet0/0/0
description to SW1_G0/0/0
ip address 1.1.1.2 255.255.255.252
#
interface GigabitEthernet0/0/1
description to SW3_G0/0/1
ip address 1.1.1.5 255.255.255.252
#
interface LoopBack2
ip address 192.168.2.254 255.255.255.0
#
ospf 1 router-id 192.168.2.254
import-route direct
area 0.0.0.1
network 1.1.1.4 0.0.0.3
network 1.1.1.0 0.0.0.3
#
return
<SW3>display current-configuration
#
sysname SW3
#
interface GigabitEthernet0/0/1
description to SW2_G0/0/1
ip address 1.1.1.6 255.255.255.252
#
interface GigabitEthernet0/0/2
description to SW4_G0/0/2
ip address 1.1.1.9 255.255.255.252
#
interface LoopBack3
ip address 192.168.3.254 255.255.255.0
#
ospf 1 router-id 192.168.3.254
import-route direct
area 0.0.0.1
network 1.1.1.4 0.0.0.3
network 1.1.1.8 0.0.0.3
#
return
<SW4>display current-configuration
#
sysname SW4
#
vlan batch 22
#
vlan 22
description 192.168.22.0/24
#
interface Vlanif22
ip address 192.168.22.254 255.255.255.0
#
interface Ethernet0/0/0
portswitch
port link-type access
port default vlan 22
#
interface GigabitEthernet0/0/2
description to SW3_G0/0/2
ip address 1.1.1.10 255.255.255.252
#
interface GigabitEthernet0/0/3
description to SW1_G0/0/3
ip address 1.1.1.13 255.255.255.252
interface LoopBack4
ip address 192.168.4.254 255.255.255.0
#
ospf 1 router-id 192.168.4.254
import-route direct
area 0.0.0.1
network 1.1.1.8 0.0.0.3
network 1.1.1.12 0.0.0.3
#
return