实验需求
1、内网ip地址 172.16.0.0/16合理分配
2、sw1/2之间互为备份
3、VRRP/STP/VLAN/TRUNK均使用
4、所有pc通过dhcp获取ip
实验拓扑
实验分析
配置思路:eth-trunk、创建vlan、划入vlan、trunk干道、svi、stp、vrrp、dhcp
三层通道:成为通道的所有物理链路必须先为三层接口;其意义在于将多个需要配置ip地址的接口逻辑为一个接口,配置一个ip地址即可
三层交换机:普通的二层交换机具有三层路由器设备的功能;标准的3层交换机不具有nat功能;只能作为汇聚层设备,无法成为核心层连接互联网的设备;
VRRP:虚拟路由冗余协议–公有协议,原理同HSRP一致
区别:1、多台设备 2、仅master发送hello 3、可以使用物理接口的ip地址来为网关地址 4、抢占默认开启 5、hold time 3s
配置内容
R1
[r1]int g0/0/0[r1-GigabitEthernet0/0/0]ip ad[r1-GigabitEthernet0/0/0]ip address 12.1.1.1 24[r1-GigabitEthernet0/0/0]int g0/0/1[r1-GigabitEthernet0/0/1]ip address 172.16.0.1 30[r1-GigabitEthernet0/0/1]int g0/0/2[r1-GigabitEthernet0/0/2]ip address172.16.0.5 30[r1]ospf 1 router-id 11.11.11.11[r1-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255[r1-ospf-1-area-0.0.0.0][r1-ospf-1]q[r1]ip route-static 0.0.0.0 0 12.1.1.2[r1]ospf 1[r1-ospf-1]default-route-advertise[r1-ospf-1]q[r1]acl 2000[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
R2
[R2]int Eth-Trunk 0[R2-Eth-Trunk0]int g0/0/2[R2-GigabitEthernet0/0/2]eth-trunk 0[R2]int g0/0/0[R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24[R2-GigabitEthernet0/0/0]int l0[R2-LoopBack0]ip address 1.1.1.1 24[R2-LoopBack0]q
SW1
测试的时候没保存,但是sw1和sw2的配置一样
SW2
[sw2]int Eth-Trunk 0[sw2-Eth-Trunk0]int g0/0/2[sw2-GigabitEthernet0/0/2]eth[sw2-GigabitEthernet0/0/2]eth-trunk 0[sw2-GigabitEthernet0/0/3]eth-trunk 0[sw2-GigabitEthernet0/0/3]q[sw2]vlan 2[sw2-vlan2]q[sw2]int g0/0/5[sw2-GigabitEthernet0/0/5]p l tr[sw2-GigabitEthernet0/0/5]p tr all vl 2[sw2]disp stp briefMSTIDPortRoleSTP State Protection 0GigabitEthernet0/0/1DESIFORWARDINGNONE 0GigabitEthernet0/0/4ROOTFORWARDINGNONE 0GigabitEthernet0/0/5DESIFORWARDINGNONE 0Eth-Trunk0DESIFORWARDINGNONE[sw2]vlan 2[sw2-vlan2]q[sw2]port-group group-member Eth-Trunk 0 g0/0/4 to g0/0/5[sw2-port-group]p l tr[sw2-Eth-Trunk0]p l tr[sw2-GigabitEthernet0/0/4]p l tr[sw2-GigabitEthernet0/0/5]p l tr[sw2-port-group]p tr all vl 2[sw2-Eth-Trunk0]p tr all vl 2[sw2-GigabitEthernet0/0/4]p tr all vl 2[sw2-GigabitEthernet0/0/5]p tr all vl 2[sw2-port-group]q[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 vlan2[sw2-mst-region]active region-configuration Info: This operation may take a few seconds. Please wait for a moment...done.[sw2-mst-region]q[sw2]disp stp briefMSTIDPortRoleSTP State Protection 0GigabitEthernet0/0/1DESIDISCARDINGNONE 0GigabitEthernet0/0/4ROOTFORWARDINGNONE 0GigabitEthernet0/0/5DESIFORWARDINGNONE 0Eth-Trunk0DESIFORWARDINGNONE 1GigabitEthernet0/0/1DESIDISCARDINGNONE 1GigabitEthernet0/0/4MASTFORWARDINGNONE 1GigabitEthernet0/0/5DESIFORWARDINGNONE 1Eth-Trunk0DESIFORWARDINGNONE 2GigabitEthernet0/0/4MASTFORWARDINGNONE 2GigabitEthernet0/0/5DESIFORWARDINGNONE 2Eth-Trunk0DESIFORWARDINGNONE[sw2][sw2]int Vlanif 1[sw2-Vlanif1]ip address 172.16.1.2 25[sw2-Vlanif1]q[sw2]int Vlanif 2[sw2-Vlanif2]ip address 172.16.1.130 25[sw2-Vlanif2]q[sw2]int vl 1[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126[sw2-Vlanif1]int vl 2[sw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254[sw2-Vlanif2]vrrp vrid 1 priority 105 [sw2-Vlanif2]vrrp vrid 1 track interface g0/0/1 reduced 10[sw2-Vlanif2]disp vrrp brief VRIDStateInterfaceType Virtual IP ----------------------------------------------------------------1 Backup Vlanif1Normal 172.16.1.126 1 Master Vlanif2Normal 172.16.1.254 ----------------------------------------------------------------Total:2 Master:1 Backup:1 Non-active:0 [sw2-Vlanif2]q[sw2]dhcp enable Info: The operation may take a few seconds. Please wait for a moment.done.[sw2]ip pool v1Info:It's successful to create an IP address pool.[sw2-ip-pool-v1]network 172.16.1.0 mask 25[sw2-ip-pool-v1]gateway-list 172.16.1.126[sw2-ip-pool-v1]dns-list 114.114.114.114 8.8.8.8[sw2-ip-pool-v1]q[sw2]interfaceVlanif 1[sw2-Vlanif1]dhcp select global [sw2-Vlanif1]q[sw2]ip pool v2Info:It's successful to create an IP address pool.[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.114 8.8.8.8[sw2-ip-pool-v2]q[sw2]int Vlanif 2[sw2-Vlanif2]dhcp select global [sw2-Vlanif2]q[sw2]vlan100[sw2-vlan100]q[sw2]int Vlanif 100[sw2-Vlanif100]ip add[sw2-Vlanif100]ip address 172.16.0.6 30[sw2-Vlanif100]q[sw2]int g0/0/1[sw2-GigabitEthernet0/0/1]p l a[sw2-GigabitEthernet0/0/1]p de vl 100[sw2-GigabitEthernet0/0/1]q[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.0 0.0.255.255[sw2-ospf-1-area-0.0.0.0]q[sw2-ospf-1]silent-interface all[sw2-ospf-1]undo silent-interface Vlanif 100[sw2-ospf-1]undo silent-interface Eth-Trunk 0[sw2-ospf-1]q
SW3
[sw3]vlan 2[sw3-vlan2]q[sw3][sw3][sw3][sw3][sw3]int e0/0/4[sw3-Ethernet0/0/4]p de vl 2[sw3-Ethernet0/0/4][sw3]qundo terundo terminal moundo terminal monitor Info: Current terminal monitor is off.[sw3]port-group group-member e0/0/1 to e0/0/2[sw3-port-group]p l tr[sw3-Ethernet0/0/1]p l tr[sw3-Ethernet0/0/2]p l tr[sw3-port-group]p tr all vl 2[sw3-Ethernet0/0/1]p tr all vl 2[sw3-Ethernet0/0/2]p tr all vl 2[sw3-port-group]q[sw3][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 Info: This operation may take a few seconds. Please wait for a moment...done.[sw3-mst-region]q[sw3]int e0/0/3[sw3-Ethernet0/0/3]stp edged-port enable [sw3-Ethernet0/0/3]int e0/0/4[sw3-Ethernet0/0/4]stp edged-port enable [sw3-Ethernet0/0/4]q
SW4
[sw4]vlan 2[sw4-vlan2]q[sw4]int e0/0/4[sw4-Ethernet0/0/4]p l a[sw4-Ethernet0/0/4]p de vl 2[sw4-Ethernet0/0/4]q[sw4]qundo terundo terminal moundo terminal monitor Info: Current terminal monitor is off.[sw4]port-g[sw4]port-group gr[sw4]port-group group-member e0/0/1 to e0/0/2[sw4-port-group]p l tr[sw4-Ethernet0/0/1]p l tr[sw4-Ethernet0/0/2]p l tr[sw4-port-group]p tr all vl 2[sw4-Ethernet0/0/1]p tr all vl 2[sw4-Ethernet0/0/2]p tr all vl 2[sw4-port-group]q[sw4][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 vla 3[sw4-mst-region]active reg[sw4-mst-region]active region-configuration Info: This operation may take a few seconds. Please wait for a moment...done.[sw4-mst-region]q[sw4]disp st b MSTIDPortRoleSTP State Protection 0Ethernet0/0/1 DESIFORWARDINGNONE 0Ethernet0/0/2 DESIDISCARDINGNONE 0Ethernet0/0/3 DESIDISCARDINGNONE 0Ethernet0/0/4 DESIDISCARDINGNONE 1Ethernet0/0/1 DESIFORWARDINGNONE 1Ethernet0/0/2 DESIDISCARDINGNONE 1Ethernet0/0/3 DESIDISCARDINGNONE[sw4]int e0/0/3[sw4-Ethernet0/0/3]stp edged-port enable [sw4-Ethernet0/0/3]int e0/0/4[sw4-Ethernet0/0/4]stp edged-port enable [sw4-Ethernet0/0/4]q
测试
pc1访问1.1.1.1
关闭一个三层设备