-
配置各接口所属的VLAN
[LSW1]vlan batch 10
[LSW1-GigabitEthernet0/0/2]port link-type trunk
[LSW1-GigabitEthernet0/0/2]port trunk allow-pass vlan 10
[LSW2]vlan batch 10 20
[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10
[LSW2-GigabitEthernet0/0/3]port link-type trunk
[LSW2-GigabitEthernet0/0/3]port trunk allow-pass vlan 20
[LSW3]vlan batch 20
[LSW3-GigabitEthernet0/0/2]port link-type trunk
[LSW3-GigabitEthernet0/0/2]port trunk allow-pass vlan 20
-
配置各VLANIF接口的IP地址
[LSW1-Vlanif10]ip add 10.1.1.1 24
[LSW2-Vlanif10]ip add 10.1.1.2 24
[LSW2-Vlanif20]ip add 10.1.1.2 24
[LSW3-Vlanif20]ip add 10.1.2.3 24
-
配置OSPF基本功能
[LSW1]ospf 1
[LSW1-ospf-1]area 0
[LSW1-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[LSW2]ospf 1
[LSW2-ospf-1]area 0
[LSW2-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[LSW3]ospf 1
[LSW3-ospf-1]area 0
[LSW3-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
-
在LSW3配置5条静态路由,并在将这些静态路由引入到OSPF协议中
[LSW3]ip route-static 172.16.16.0 24 NULL 0
[LSW3]ip route-static 172.16.17.0 24 NULL 0
[LSW3]ip route-static 172.16.18.0 24 NULL 0
[LSW3]ip route-static 172.16.19.0 24 NULL 0
[LSW3]ip route-static 172.16.20.0 24 NULL 0
[LSW3]ospf 1
[LSW3-ospf-1]import-route static
-
配置路由发布策略
[LSW3]ip ip-prefix 3to2 index 10 permit 172.16.17.0 24
[LSW3]ip ip-prefix 3to2 index 20 permit 172.16.18.0 24
[LSW3]ip ip-prefix 3to2 index 30 permit 172.16.19.0 24
[LSW3]ospf 1
[LSW3-ospf-1]filter-policy ip-prefix 3to2 export static
-
配置路由接收策略
[LSW1]ip ip-prefix 2to1 index 10 permit 172.16.18.0 24
[LSW1]ospf
[LSW1-ospf-1]filter-policy ip-prefix 2to1 import