先进行ip地址规划,将pc1与pc3置为vlan2中,pc2与pc4置于vlan3中;sw3与sw4为接入层,只需将连接的终端接口划分到相应的vlan中,然后在其他接口中允许相应流量通过即可;sw1与sw2为汇聚层,先配置二层:先进行链路聚合,然后设置接口类型,配置mstp防止出环,vlan2划分到实例1中,vlan3划分到实例2中,而sw1作为vlan2的主根,作为vlan3的备份根,反之sw2作为vlan2的从根,vlan3的主根;交换机上创建地址池,在对应接口中开启DHCP服务。
[sw1]int Eth-Trunk 0
[sw1-Eth-Trunk0]q
[sw1]int g0/0/23
[sw1-GigabitEthernet0/0/23]eth-trunk 0
[sw1-GigabitEthernet0/0/23]int g0/0/24
[sw1-GigabitEthernet0/0/24]eth-trunk 0
[sw2]int Eth-Trunk 0
[sw2-Eth-Trunk0]q
[sw2]int g0/0/23
[sw2-GigabitEthernet0/0/23]eth-trunk 0
[sw2-GigabitEthernet0/0/23]int g0/0/24
[sw2-GigabitEthernet0/0/24]eth-trunk 0
[sw1]port-group group-member GigabitEthernet 0/0/2 to GigabitEthernet 0/0/3 Eth-Trunk 0
这样方便一次性把三个接口做成trunk干道
[sw1-port-group]port link-type trunk
[sw1-port-group]port trunk allow-pass vlan 1 to 2
[sw2]port-group group-member GigabitEthernet 0/0/2 to GigabitEthernet 0/0/3 Eth-Trunk 0
[sw2-port-group]port link-type trunk
[sw2-port-group]port trunk allow-pass vlan 1 to 2
[sw3]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2
[sw3-port-group]port link-type trunk
[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
创建
[sw1]vlan 2
[sw2]vlan 2
[sw3]vlan 2
[sw4]vlan 2
划分
[sw3]int Eth0/0/2
[sw3-Ethernet0/0/2]port link-type access
[sw3-Ethernet0/0/2]port default vlan 2
[sw4]int e0/0/2
[sw4-Ethernet0/0/2]port link-type access
[sw4-Ethernet0/0/2]port default vlan 2
配置STP,指令是相同的
[sw1]stp mode mstp
[sw1]stp enable
[sw1]stp region-configuration
[sw1-mst-region]region-name a
[sw1-mst-region]instance 1 vlan 1
[sw1-mst-region]instance 2 vlan 2
[sw1-mst-region]active region-configuration
sw1和sw2之间互相备份
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
[sw2]stp instance 1 root secondary
[sw2]stp instance 2 root primary
调stp的边缘接口
[sw3]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[sw3-port-group]stp edged-port enable
[sw4]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[sw4-port-group]stp edged-port enable
[sw1]interface vlan 1
[sw1-Vlanif1]ip ad 172.16.1.1 25
[sw1]interface vlan 2
[sw1-Vlanif2]ip ad 172.16.1.129 25
[sw2]interface vlan 1
[sw2-Vlanif1]ip ad 172.16.1.2 25
[sw2]interface vlan 2
[sw2-Vlanif2]ip ad 172.16.1.130 25
[sw1]interface vlan 1
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw1-Vlanif1]vrrp vrid 1 priority 120
[sw1-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 30
[sw1]interface vlan 2
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[sw2]interface vlan 1
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw2]interface vlan 2
[sw2-Vlanif2]vrrp vrid 1 vir
[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]dhcp enable
[sw1]ip pool v1
[sw1-ip-pool-v1]network 172.16.1.0 mask 25
[sw1-ip-pool-v1]gateway-list 172.16.1.126
[sw1-ip-pool-v1]dns-list 114.114.114.114 8.8.8.8
[sw1]ip pool v2
[sw1-ip-pool-v1]network 172.16.1.128 mask 25
[sw1-ip-pool-v1]gateway-list 172.16.1.254
[sw1-ip-pool-v1]dns-list 114.114.114.114 8.8.8.8
[sw1]int vlan 1
[sw1-Vlanif1]dhcp select global
[sw1-Vlanif1]int vlan 2
[sw1-Vlanif2]dhcp select global
[sw1]vlan 100
[sw1-vlan100]q
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]p d vlan 100
[sw1-GigabitEthernet0/0/1]int vlan 100
[sw1-Vlanif100]ip ad 172.16.0.1 30
[sw2]vlan 100
[sw2-vlan100]int vlan 100
[sw2-Vlanif100]ip ad 172.16.0.5 30
[sw2-Vlanif100]int g0/0/1
[sw2-GigabitEthernet0/0/1]p l a
[sw2-GigabitEthernet0/0/1]p d vlan 100
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip ad 172.16.0.2 30
[r2-GigabitEthernet0/0/0]int g0/0/2
[r2-GigabitEthernet0/0/2]ip ad 172.16.0.6 30
[r2-GigabitEthernet0/0/2]int g0/0/1
[r2-GigabitEthernet0/0/1]ip ad 12.1.1.1 24
[r1]int lo0
[r1-LoopBack0]ip ad 1.1.1.1 24
[r1-LoopBack0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip ad 12.1.1.2 24
ospf
[r2]ospf 1 router-id 1.1.1.1
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 172.16.0.0 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]q
[sw1-ospf-1]area 1
[sw1-ospf-1-area-0.0.0.1]network 172.16.1.1 0.0.0.0
[sw1-ospf-1-area-0.0.0.1]network 172.16.1.129 0.0.0.0
[sw2]ospf 1 router-id 2.2.2.2
[sw2-ospf-1]area 0
[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]q
[sw2-ospf-1]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
汇总
汇总:
[sw1]ospf 1
[sw1-ospf-1]area 1
[sw1-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0
[sw2]ospf 1
[sw2-ospf-1]area 1
[sw2-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0
[sw1]ospf 1
[sw1-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
[sw1-ospf-1]undo silent-interface vlanif 100
[sw2]ospf 1
[sw2-ospf-1]silent-interface all
[sw2-ospf-1]undo silent-interface GigabitEthernet 0/0/1
[sw2-ospf-1]undo silent-interface Eth-Trunk 0
[sw2-ospf-1]undo silent-interface vlanif 1
[sw2-ospf-1]undo silent-interface vlanif 100
[r2]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
[r2]ospf 1
[r2-ospf-1]default-route-advertise
[r2]acl 2000
[r2-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r2-acl-basic-2000]int g0/0/1
[r2-GigabitEthernet0/0/1]nat outbound 2000