拓扑搭建
第一步
[SW1]int Eth-Trunk 0
[SW1-GigabitEthernet0/0/23]eth-trunk 0
[SW1-GigabitEthernet0/0/24]eth-trunk 0
[SW2]int Eth-Trunk 0
[SW2-GigabitEthernet0/0/23]eth-trunk 0
[SW2-GigabitEthernet0/0/24]eth-trunk 0
第二步 确定TRUNK
[SW1]port-group group-member GigabitEthernet 0/0/2 to GigabitEthernet 0/0/3 Eth-
Trunk 0
[SW1-Eth-Trunk0]port trunk allow-pass vlan 2
[SW2]port-group group-member GigabitEthernet 0/0/2 to GigabitEthernet 0/0/3 Eth-
Trunk 0
[SW2-Eth-Trunk0]port link-type trunk
[SW2-Eth-Trunk0]port trunk allow-pass vlan 2
[sw3]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2
[sw3-port-group]port trunk allow-pass vlan 2
[sw4]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2
[sw4-port-group]port link-type trunk
[sw4-port-group]port trunk allow-pass vlan 2
第三步 创建VLAN
[SW1]vlan 2
[SW2]vlan 2
[sw3]vlan 2
[sw4]vlan 2
第四步 接口划入vlan
[sw3]int g 0/0/4
[sw3-GigabitEthernet0/0/4]port link-type access
[sw3-GigabitEthernet0/0/4]port default vlan 2
[sw4]int g 0/0/4
[sw4-GigabitEthernet0/0/4]port link-type access
[sw4-GigabitEthernet0/0/4]port default vlan 2
第五步 做生成树
[SW1]stp mode mstp
[SW1]stp enable
[SW1]stp region-configuration
[SW1-mst-region]region-name a
[SW1-mst-region]instance 1 vlan 2
[SW1-mst-region]instance 2 vlan 2
[SW1-mst-region]active region-configuration
[SW2]stp mode mstp
[SW2]stp enable
[SW2]stp region-configuration
[SW2-mst-region]region-name a
[SW2-mst-region]instance 1 vlan 2
[SW2-mst-region]instance 2 vlan 2
[SW2-mst-region]active region-configuration
[SW3]stp mode mstp
[SW3]stp enable
[SW3]stp region-configuration
[SW3-mst-region]region-name a
[SW3-mst-region]instance 1 vlan 2
[SW3-mst-region]instance 2 vlan 2
[SW3-mst-region]active region-configuration
[SW4]stp mode mstp
[SW4]stp enable
[SW4]stp region-configuration
[SW4-mst-region]region-name a
[SW4-mst-region]instance 1 vlan 2
[SW4-mst-region]instance 2 vlan 2
[SW4-mst-region]active region-configuration
[SW1]stp instance 1 root primary
[SW1]stp instance 2 root secondary
[SW2]stp instance 1 root secondary
[SW2]stp instance 2 root primary
[sw3]port-group group-member GigabitEthernet 0/0/3 to GigabitEthernet 0/0/4
[sw3-port-group]stp edged-port enable
[sw4]port-group group-member GigabitEthernet 0/0/3 to GigabitEthernet 0/0/4
[sw4-port-group]stp edged-port enable
第六步 SVI
[SW1]int vlan 1
[SW1-Vlanif1]ip address 172.16.1.1 25
[SW1]int vlan 2
[SW1-Vlanif2]ip address 172.16.1.129 25
[SW2]int vlan 1
[SW2-Vlanif1]ip address 172.16.1.2 25
[SW2]int vlan 2
[SW2-Vlanif2]ip address 172.16.1.130 25
[SW2-Vlanif2]ping 172.16.1.1
PING 172.16.1.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.1.1: bytes=56 Sequence=1 ttl=255 time=130 ms
Reply from 172.16.1.1: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 172.16.1.1: bytes=56 Sequence=3 ttl=255 time=60 ms
Reply from 172.16.1.1: bytes=56 Sequence=4 ttl=255 time=60 ms
Reply from 172.16.1.1: bytes=56 Sequence=5 ttl=255 time=80 ms
[SW1-Vlanif1]vrrp vrid 1
[SW1-Vlanif1]vrrp vrid 1 priority 120
[SW1-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 30
[SW1-Vlanif1]int vlan 2
[SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[SW2]int vlan 1
[SW2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[SW2]int vlan 2
[SW2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[SW2-Vlanif2]vrrp vrid 1 priority 120
[SW2-Vlanif2]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 30
[SW1]dis vrrp brief
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Master Vlanif1 Normal 172.16.1.126
1 Backup Vlanif2 Normal 172.16.1.254
----------------------------------------------------------------
[SW2]display vrrp brief
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Backup Vlanif1 Normal 172.16.1.126
1 Master Vlanif2 Normal 172.16.1.254
第七步 DHCP
[SW1]ip pool g1
[SW1-ip-pool-g1]network 172.16.1.0 mask 25
[SW1-ip-pool-g1]gateway-list 172.16.1.126
[SW1-ip-pool-g1]dns-list 114.114.114.114 8.8.8.8
[SW1]ip pool v2
[SW1-ip-pool-v2]network 172.16.1.128 mask 25
[SW1-ip-pool-v2]gateway-list 172.16.1.254
[SW1-ip-pool-v2]dns-list 114.114.114.144 8.8.8.8
[SW1]int vlan 1
[SW1-Vlanif1]dhcp select global
[SW1-Vlanif1]int vlan 2
[SW1-Vlanif2]dhcp select global
[SW2]ip pool g1
[SW2-ip-pool-g1]network 172.16.1.0 mask 25
[SW2-ip-pool-g1]gateway-list 172.16.1.126
[SW2-ip-pool-g1]dns-list 114.114.114.114 8.8.8.8
[SW2]ip pool v2
[SW2-ip-pool-v2]network 172.16.1.128 mask 25
[SW2-ip-pool-v2]gateway-list 172.16.1.254
[SW2-ip-pool-v2]dns-list 114.114.114.144 8.8.8.8
[SW2]int vlan 1
[SW2-Vlanif1]dhcp select global
[SW2-Vlanif1]int vlan 2
[SW2-Vlanif2]dhcp select global
第八步: 路由部分
[SW1]vlan 100
[SW1-GigabitEthernet0/0/1]port link-type access
[SW1-GigabitEthernet0/0/1]port default vlan 100
[SW1-Vlanif100]ip add 172.16.0.1 30
[SW2]vlan 100
[SW2-Vlanif100]ip address 172.16.0.5 30
[SW2-GigabitEthernet0/0/1]port link-type access
[SW2-GigabitEthernet0/0/1]port default vlan 100
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip add 172.16.0.2 30
[R1-GigabitEthernet0/0/0]int g 0/0/2
[R1-GigabitEthernet0/0/2]ip add 172.16.0.6 30
[R1]ping 172.16.0.1
PING 172.16.0.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.0.1: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from 172.16.0.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 172.16.0.1: bytes=56 Sequence=3 ttl=255 time=10 ms
Reply from 172.16.0.1: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 172.16.0.1: bytes=56 Sequence=5 ttl=255 time=20 ms
[R1]ping 172.16.0.5
PING 172.16.0.5: 56 data bytes, press CTRL_C to break
Reply from 172.16.0.5: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 172.16.0.5: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 172.16.0.5: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 172.16.0.5: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 172.16.0.5: bytes=56 Sequence=5 ttl=255 time=40 ms
[R1]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add 12.1.1.1 24
[R2]int LoopBack 0
[R2-LoopBack0]ip add 1.1.1.2 24
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[R2-GigabitEthernet0/0/0]ping 12.1.1.1
PING 12.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 12.1.1.1: bytes=56 Sequence=1 ttl=255 time=90 ms
Reply from 12.1.1.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 12.1.1.1: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 12.1.1.1: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 12.1.1.1: bytes=56 Sequence=5 ttl=255 time=10 ms
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 172.16.0.2 0.0.0.255
[SW1]ospf 1 router-id 1.1.1.2
[SW1-ospf-1]area 0
[SW1-ospf-1-area-0.0.0.0]network 172.16.0.1 0.0.0.0
[SW1-ospf-1-area-0.0.0.0]area 1
[SW1-ospf-1-area-0.0.0.1]network 172.16.1.1 0.0.0.0
[SW2]ospf 1 router-id 2.2.2.2
[SW2-ospf-1-area-0.0.0.0]network 172.16.0.5 0.0.0.0
[SW2-ospf-1-area-0.0.0.0]area 1
[SW2-ospf-1-area-0.0.0.1]network 172.16.1.2 0.0.0.0
[SW2-ospf-1-area-0.0.0.1]network 172.16.1.130 0.0.0.0
[R1]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 2 Routes : 4
OSPF routing table status : <Active>
Destinations : 2 Routes : 4
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.1.0/25 OSPF 10 2 D 172.16.0.1 GigabitEthernet
0/0/0
OSPF 10 2 D 172.16.0.5 GigabitEthernet
0/0/2
172.16.1.128/25 OSPF 10 2 D 172.16.0.1 GigabitEthernet
0/0/0
OSPF 10 2 D 172.16.0.5 GigabitEthernet
0/0/2
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
网段汇总
[SW1-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0
[SW2-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0
[SW1]display ospf peer brief
OSPF Process 1 with Router ID 1.1.1.2
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 Vlanif100 1.1.1.1 Full
0.0.0.1 Vlanif1 172.16.1.2 Full
0.0.0.1 Vlanif2 172.16.1.2 Full
----------------------------------------------------------------------------
(这里可以做做静态路由,且在sw1和sw2上配置两个缺省路由指向R1)
动态路由会产生大量洪泛流量
沉默所有接口
[SW1-ospf-1]silent-interface all
[SW2-ospf-1]silent-interface all
打开指定接口
[SW1-ospf-1]undo silent-interface GigabitEthernet 0/0/1
[SW1-ospf-1]undo silent-interface Eth-Trunk 0
[SW1-ospf-1]undo silent-interface vlanif 1
[SW2-ospf-1]undo silent-interface GigabitEthernet 0/0/1
[SW2-ospf-1]undo silent-interface Eth-Trunk 0
[SW1-ospf-1]undo silent-interface vlanif 1
[SW1-ospf-1]undo silent-interface Vlanif 100
[SW2-ospf-1]undo silent-interface Vlanif 100
[R1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
[R1-ospf-1]default-route-advertise
[R1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R1-GigabitEthernet0/0/1]nat outbound 2000
到这里算是完成所有配置,保存save
*结果测试
关闭sw1
实验成功结束