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 address 172.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 brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
0 GigabitEthernet0/0/4 ROOT FORWARDING NONE
0 GigabitEthernet0/0/5 DESI FORWARDING NONE
0 Eth-Trunk0 DESI FORWARDING NONE
[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 vlan 2
[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 brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI DISCARDING NONE
0 GigabitEthernet0/0/4 ROOT FORWARDING NONE
0 GigabitEthernet0/0/5 DESI FORWARDING NONE
0 Eth-Trunk0 DESI FORWARDING NONE
1 GigabitEthernet0/0/1 DESI DISCARDING NONE
1 GigabitEthernet0/0/4 MAST FORWARDING NONE
1 GigabitEthernet0/0/5 DESI FORWARDING NONE
1 Eth-Trunk0 DESI FORWARDING NONE
2 GigabitEthernet0/0/4 MAST FORWARDING NONE
2 GigabitEthernet0/0/5 DESI FORWARDING NONE
2 Eth-Trunk0 DESI FORWARDING NONE
[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
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Backup Vlanif1 Normal 172.16.1.126
1 Master Vlanif2 Normal 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 v1
Info: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]interface Vlanif 1
[sw2-Vlanif1]dhcp select global
[sw2-Vlanif1]q
[sw2]ip pool v2
Info: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]vlan 100
[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]q
undo ter
undo terminal mo
undo 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]q
undo ter
undo terminal mo
undo 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
MSTID Port Role STP State Protection
0 Ethernet0/0/1 DESI FORWARDING NONE
0 Ethernet0/0/2 DESI DISCARDING NONE
0 Ethernet0/0/3 DESI DISCARDING NONE
0 Ethernet0/0/4 DESI DISCARDING NONE
1 Ethernet0/0/1 DESI FORWARDING NONE
1 Ethernet0/0/2 DESI DISCARDING NONE
1 Ethernet0/0/3 DESI DISCARDING NONE
[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
关闭一个三层设备