实验要求:
内网IP地址按172.16.0.0/16合理分配
SW1/2互相备份
VRRP/STP/VLAN/TRUNK均使用
PC通过DHCP获取地址
拓扑图
实验相关配置
R1
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip ad 172.16.0.1 30
[r1-GigabitEthernet0/0/1]q
[r1]int g0/0/2
[r1-GigabitEthernet0/0/2]ip ad 172.16.0.5 30
[r1-GigabitEthernet0/0/2]q
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]ip ad 12.1.1.1 24
[r1-GigabitEthernet0/0/0]q
[r1]ip route-static 0.0.0.0 0 12.1.1.2
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]nat outbound 2000
R2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip ad 12.1.1.2 24
[r2-GigabitEthernet0/0/0]q
[r2]int l0
[r2-LoopBack0]ip ad 1.1.1.1 24
channel创建
[sw1]interface Eth-Trunk 0
[sw1]interface GigabitEthernet 0/0/3
[sw1-GigabitEthernet0/0/23]eth-trunk 0
[sw1]interface GigabitEthernet 0/0/4
[sw1-GigabitEthernet0/0/23]eth-trunk 0
sw2同上
vlan创建
[sw1]vlan batch 1 to 2
[sw2]vlan batch 1 to 2
[sw3]vlan batch 1 to 2
[sw3]int e 0/0/1
[sw3-Ethernet0/0/1]port link-type access
[sw3-Ethernet0/0/1]port default vlan 1
[sw3]int e 0/0/2
[sw3-Ethernet0/0/2]port link-type access
[sw3-Ethernet0/0/2]port default vlan 2
[sw4]vlan batch 1 to 2
[sw4]int e 0/0/1
[sw4-Ethernet0/0/1]port link-type access
[sw4-Ethernet0/0/1]port default vlan 1
[sw4]int e 0/0/2
[sw4-Ethernet0/0/2]port link-type access
[sw4-Ethernet0/0/2]port default vlan 2
trunk创建
[sw1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port hybrid tagged vlan 2
[sw1]int g0/0/5
[sw1-GigabitEthernet0/0/5]port hybrid tagged vlan 2
[sw1]interface Eth-Trunk 0
[sw1-Eth-Trunk0]port hybrid tagged vlan 2
[sw2]int g0/0/5
[sw2-GigabitEthernet0/0/5]port hybrid tagged vlan 2
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port hybrid tagged vlan 2
[sw2]interface Eth-Trunk 0
[sw2-Eth-Trunk0]port hybrid tagged vlan 2
[sw3]int g0/0/2
[sw3-GigabitEthernet0/0/2]port hybrid tagged vlan 2
[sw3]int g0/0/1
[sw3-GigabitEthernet0/0/1]port hybrid tagged vlan 2
[sw4]int g0/0/2
[sw4-GigabitEthernet0/0/2]port hybrid tagged vlan 2
[sw4]int g0/0/1
[sw4-GigabitEthernet0/0/1]port hybrid tagged vlan 2
SVI配置
[sw1]interface Vlanif 1
[sw1-Vlanif2]ip ad 172.16.2.253 24
[sw1]interface Vlanif 2
[sw1-Vlanif2]ip ad 172.16.3.253 24
[sw1]vlan 99
[sw1]int Vlanif 99
[sw1-Vlanif99]ip ad 172.16.0.2 30
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 99
[sw2]interface Vlanif 1
[sw2-Vlanif2]ip ad 172.16.2.254 24
[sw2]interface Vlanif 2
[sw2-Vlanif2]ip ad 172.16.3.254 24
[sw2]vlan 100
[sw2]int Vlanif 100
[sw2-Vlanif99]ip ad 172.16.0.6 30
[sw2]int g0/0/2
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/2]port default vlan 100
VRRP配置
[sw1]int Vlanif 1
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.2.250
[sw1-Vlanif1]vrrp vrid 1 priority 101
[sw1-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/1
[sw1]int Vlanif 2
[sw1-Vlanif2]vrrp vrid 2 virtual-ip 172.16.3.250
[sw2]int Vlanif 2
[sw2-Vlanif1]vrrp vrid 2 virtual-ip 172.16.3.250
[sw2-Vlanif1]vrrp vrid 2 priority 101
[sw2-Vlanif1]vrrp vrid 2 track interface GigabitEthernet 0/0/2
[sw2]int Vlanif 1
[sw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.2.250
生成树相关配置
[sw1]stp mode mstp
[sw1]stp enable
[sw1]stp region-configuration
[sw1-mst-region]instance 1 vlan 1
[sw1-mst-region]instance 2 vlan2
[sw1-mst-region]active region-configuration
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
[sw2]stp mode mstp
[sw2]stp enable
[sw2]stp region-configuration
[sw2-mst-region]instance 1 vlan 1
[sw2-mst-region]instance 2 vlan2
[sw2-mst-region]active region-configuration
[sw2]stp instance 2 root primary
[sw2]stp instance 1 root secondary
[sw3]stp mode mstp
[sw3]stp enable
[sw4]stp mode mstp
[sw4]stp enable
DHCP配置
[sw1]dhcp enable
[sw1]ip pool a
Info:It’s successful to create an IP address pool.
[sw1-ip-pool-a]network 172.16.2.0 mask 24
[sw1-ip-pool-a]gateway-list 172.16.2.250
[sw1-ip-pool-a]dns-list 8.8.8.8
[sw1]ip pool b
Info:It’s successful to create an IP address pool.
[sw1-ip-pool-a]network 172.16.3.0 mask 24
[sw1-ip-pool-a]gateway-list 172.16.3.250
[sw1-ip-pool-a]dns-list 8.8.8.8
[sw1]int Vlanif 1
[sw1-Vlanif1]dhcp select global
[sw1]int Vlanif 2
[sw1-Vlanif1]dhcp select global
[sw2]dhcp enable
[sw2]ip pool a
Info:It’s successful to create an IP address pool.
[sw2-ip-pool-a]network 172.16.2.0 mask 24
[sw2-ip-pool-a]gateway-list 172.16.2.250
[sw2-ip-pool-a]dns-list 8.8.8.8
[sw2]ip pool b
Info:It’s successful to create an IP address pool.
[sw2-ip-pool-a]network 172.16.3.0 mask 24
[sw2-ip-pool-a]gateway-list 172.16.3.250
[sw2-ip-pool-a]dns-list 8.8.8.8
[sw2]int Vlanif 1
[sw2-Vlanif1]dhcp select global
[sw2]int Vlanif 2
[sw2-Vlanif1]dhcp select global
OSPF配置
[r1]ospf 1
[r1-ospf-1]default-route-advertise
[sw1]ospf 1 router-id 1.1.1.1
[sw1-ospf-1]area 0
[sw1-ospf-1-area-0.0.0.0]network 172.16.0.2 0.0.0.0
[sw1-ospf-1]area 1
[sw1-ospf-1-area-1.1.1.1]network 172.16.2.0 0.0.0.255
[sw1-ospf-1-area-1.1.1.1]network 172.16.3.0 0.0.0.255
[sw1-ospf-1]silent-interface GigabitEthernet 0/0/2
[sw1-ospf-1]silent-interface GigabitEthernet 0/0/5
[sw1-ospf-1]silent-interface Vlanif 2
[sw2]ospf 1 router-id 1.1.1.1
[sw2-ospf-1]area 0
[sw2-ospf-1-area-0.0.0.0]network 172.16.0.2 0.0.0.0
[sw2-ospf-1]area 1
[sw2-ospf-1-area-1.1.1.1]network 172.16.2.0 0.0.0.255
[sw2-ospf-1-area-1.1.1.1]network 172.16.3.0 0.0.0.255
[sw2-ospf-1]silent-interface GigabitEthernet 0/0/5
[sw2-ospf-1]silent-interface GigabitEthernet 0/0/1
[sw2-ospf-1]silent-interface Vlanif 2
测试