交换的配置实验

三层架构

​        核心层:nat、高速路由转发。

​        汇聚层(分布层):流量的集合,DHCP/VLAN/STP/HSRP/VRRP/channel…QOS/ACL

​        接入层:提供端口的密度,用于用户终端的接入—二层交换机,AP。

冗余:备份    4类:线路备份,设备备份,网关备份,UPS(电源)备份。

实验需求

1.内网ip地址为172.16.0.0/16合理分配。

2.SW1/SW2之间互为备份。

3.VRRP/STP/TRUNK均使用。

4.所有PC通过DHCP获取ip地址。

实验步骤

一、分配ip

172.16.0.0/30       172.16.0.4/30

172.16.1.0/24       SVI

              172.16.1.0/25

              172.16.1.128/25

二、配置eth-trunk

[sw1]interface Eth-Trunk 0        #逻辑整合为一个接口
[sw1-Eth-Trunk0]q
[sw1]interface GigabitEthernet 0/0/4		
[sw1-GigabitEthernet0/0/4]eth-trunk 0
[sw1-GigabitEthernet0/0/4]int g0/0/5
[sw1-GigabitEthernet0/0/5]eth-trunk 0

[sw2]interface Eth-Trunk 0
[sw2-Eth-Trunk0]q
[sw2]interface GigabitEthernet 0/0/4		
[sw2-GigabitEthernet0/0/4]eth-trunk 0
[sw2-GigabitEthernet0/0/4]int g0/0/5
[sw2-GigabitEthernet0/0/5]eth-trunk 0

三、接口划入vlan

[SW1]vlan 2
[SW1-vlan2]q
[SW1]port-group group-member Eth-Trunk 0 g0/0/3 g0/0/6
[SW1-port-group]port link-type trunk
[SW1-Eth-Trunk0]port link-type trunk 
[SW1-GigabitEthernet0/0/3]port link-type trunk 
[SW1-GigabitEthernet0/0/6]port link-type trunk 
[SW1-port-group]port trunk allow-pass vlan 2
[SW1-Eth-Trunk0]port trunk allow-pass vlan 2
[SW1-GigabitEthernet0/0/3]port trunk allow-pass vlan 2
[SW1-GigabitEthernet0/0/6]port trunk allow-pass vlan 2

[SW2]vlan 2
[SW2-vlan2]q
[SW2]port-group group-member Eth-Trunk 0 g0/0/3 g0/0/7
[SW2-port-group]port link-type trunk
[SW2-Eth-Trunk0]port link-type trunk 
[SW2-GigabitEthernet0/0/3]port link-type trunk 
[SW2-GigabitEthernet0/0/7]port link-type trunk 
[SW2-port-group]port trunk allow-pass vlan 2
[SW2-Eth-Trunk0]port trunk allow-pass vlan 2
[SW2-GigabitEthernet0/0/3]port trunk allow-pass vlan 2
[SW2-GigabitEthernet0/0/7]port trunk allow-pass vlan 2

[SW3]vlan 2
[SW3-vlan2]q
[SW3]port-group group-member g0/0/1 g0/0/2
[SW3-port-group]port link-type trunk 
[SW3-GigabitEthernet0/0/1]port link-type trunk 
[SW3-GigabitEthernet0/0/2]port link-type trunk 
[SW3-port-group]port trunk allow-pass vlan 2
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2
[SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan 2
[SW3]int e0/0/2
[SW3-Ethernet0/0/2]port link-type access 
[SW3-Ethernet0/0/2]port default vlan 2
[SW3-Ethernet0/0/2]stp edged-port enable        #交换机与PC的接口设置为边缘接口
[SW3-Ethernet0/0/2]int e0/0/1
[SW3-Ethernet0/0/1]stp edged-port enable

[SW4]vlan 2
[SW4-vlan2]q
[SW4]port-group group-member g0/0/1 g0/0/2
[SW4-port-group]port link-type trunk 
[SW4-GigabitEthernet0/0/1]port link-type trunk 
[SW4-GigabitEthernet0/0/2]port link-type trunk 
[SW4-port-group]port trunk allow-pass vlan 2
[SW4-GigabitEthernet0/0/1]port trunk allow-pass vlan 2
[SW4-GigabitEthernet0/0/2]port trunk allow-pass vlan 2
[SW4-port-group]q
[SW4]int e0/0/2
[SW4-Ethernet0/0/2]port link-type access 
[SW4-Ethernet0/0/2]port default vlan 2  
[SW4-Ethernet0/0/2]stp edged-port enable
[SW4-Ethernet0/0/2]int e0/0/1
[SW4-Ethernet0/0/1]stp edged-port enable 

 四、配置mstp

[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-mst-region]q
[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]region-name a
[SW2-mst-region]instance 1 vlan 1
[SW2-mst-region]instance 2 vlan 2
[SW2-mst-region]active region-configuration 
[SW2-mst-region]q
[SW2]stp instance 1 root secondary
[SW2]stp instance 2 root primary

[SW3]stp mode mstp
[SW3]stp enable 
[SW3]stp region-configuration 
[SW3-mst-region]region-name a
[SW3-mst-region]instance 1 vlan 1
[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 1
[SW4-mst-region]instance 2 vlan 2 
[SW4-mst-region]active region-configuration 

五、配置网关冗余

[SW1]int vlan 1
[SW1-Vlanif1]ip a 172.16.1.1 25
[SW1-Vlanif1]int vlan 2
[SW1-Vlanif2]ip a 172.16.1.129 25
[SW1-Vlanif2]q
[SW1]int vlan 1        #Master
[SW1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126 
[SW1-Vlanif1]vrrp vrid 1 priority 101
[SW1-Vlanif1]vrrp vrid 1 track int g0/0/1 reduced 2
[SW1-Vlanif1]int vlan 2        #Backup
[SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254

[SW2]int vlan 1
[SW2-Vlanif1]ip a 172.16.1.2 25
[SW2-Vlanif1]int vlan 2
[SW2-Vlanif2]ip a 172.16.1.130 25
[SW2-Vlanif2]q
[SW1]int vlan 1        #Backup
[SW1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[SW1-Vlanif1]int vlan 2       #Master
[SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[SW1-Vlanif2]vrrp vrid 1 priority 101
[SW1-Vlanif2]vrrp vrid 1 track int g0/0/1 reduced 2

六、配置DHCP

[SW1]dhcp enable
[SW1]ip pool v1
[SW1-ip-pool-v1]network 172.16.1.0 ma 25
[SW1-ip-pool-v1]gateway-list 172.16.1.126
[SW1-ip-pool-v1]dns 114.114.114.114 8.8.8.8
[SW1-ip-pool-v1]q
[SW1]ip pool v2
[SW1-ip-pool-v2]network 172.16.1.128 ma 25
[SW1-ip-pool-v2]gateway-list 172.16.1.254
[SW1-ip-pool-v2]dns 114.114.114.114 8.8
[SW1-ip-pool-v2]q                                                           
[SW1]int vlan 1
[SW1-Vlanif1]dhcp select global 
[SW1-Vlanif1]int vlan 2
[SW1-Vlanif2]dhcp select global 
[SW1-Vlanif2]q

[SW2]dhcp enable
[SW2]ip pool v1
[SW2-ip-pool-v1]network 172.16.1.0 ma 25
[SW2-ip-pool-v1]gateway-list 172.16.1.126
[SW2-ip-pool-v1]dns 114.114.114.114 8.8.8.8
[SW2-ip-pool-v1]q
[SW2]ip pool v2
[SW2-ip-pool-v2]network 172.16.1.128 ma 25
[SW2-ip-pool-v2]gateway-list 172.16.1.254
[SW2-ip-pool-v2]dns 114.114.114.114 8.8
[SW2-ip-pool-v2]q                                                           
[SW2]int vlan 1
[SW2-Vlanif1]dhcp select global 
[SW2-Vlanif1]int vlan 2
[SW2-Vlanif2]dhcp select global 
[SW2-Vlanif2]q

 七、配置核心层

[SW1]vlan 100
[SW1-vlan100]q                 
[SW1]int vlan 100
[SW1-Vlanif100]ip a 172.16.0.1 30
[SW1-Vlanif100]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access 
[SW1-GigabitEthernet0/0/1]port default vlan 100 
[SW1-GigabitEthernet0/0/1]stp edged-port enable        #与路由之间不发送BPDU
[SW1]ospf 1 router-id 2.2.2.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.0 0.0.0.255
[SW1-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0        #汇总a1区域ip

[SW2]vlan 100
[SW2-vlan100]q                 
[SW2]int vlan 100
[SW2-Vlanif100]ip a 172.16.0.5 30
[SW2-Vlanif100]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access 
[SW2-GigabitEthernet0/0/2]port default vlan 100
[SW2-GigabitEthernet0/0/2]stp edged-port enable
[SW2]ospf 1 router-id 3.3.3.3
[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]area 1
[SW2-ospf-1-area-0.0.0.1]network 172.16.1.0 0.0.0.255
[SW2-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0

[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip a 172.16.0.2 30
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip a 172.16.0.6 30
[R1-GigabitEthernet0/0/1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip a 12.1.1.1 24
[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.0 0.0.0.255
[R1]ip route-static 0.0.0.0 0 12.1.1.2        #静态到ISP
[R1]ospf 1
[R1-ospf-1]default-route-advertise        #向区域传缺省路由 
[R1-ospf-1]q
[R1]acl 2000        #公网NAT
[R1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R1-acl-basic-2000]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat outbound 2000

 八、沉默接口

[SW1]ospf 1        #沉默其他接口,减少不必要的hello包
[SW1-ospf-1]silent-interface all  
[SW1-ospf-1]undo silent-interface GigabitEthernet 0/0/1
[SW1-ospf-1]undo silent-interface vlanif 100
[SW1-ospf-1]undo silent-interface vlanif 1
[SW1-ospf-1]undo silent-interface Eth-Trunk 0 

[SW2]ospf 1
[SW2-ospf-1]silent-interface all  
[SW2-ospf-1]undo silent-interface GigabitEthernet 0/0/2
[SW2-ospf-1]undo silent-interface vlanif 100
[SW2-ospf-1]undo silent-interface vlanif 1
[SW2-ospf-1]undo silent-interface Eth-Trunk 0

实验测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值