目录
实验要求图:
实验拓扑图:
实验要求:
- 内网IP地址使用172.16.0.0/16分配
- sw1和sw2之间互为备份
- VRRP/STP/VLAN/Eth-trunk均使用
- 所有PC均通过DHCP获取IP地址
- ISP只能配置IP地址
- 所有电脑可以正常访问ISP路由器环回
实验思路:
先配置eth-trunk,然后创建vlan,并划分,修改链路为trunk干道,再配置STP、启动SVI和VRRP最后配置DHCP
交换--eth-trank>vlan(创建、划分)>trunk>STP>SVI>VRRP>DHCP
实验配置:
地址规划:
172.16.1.0/24
172.16.1.0/25--vlanif1
172.16.1.128/25--vlanif2
172.16.0.0/30 --r2
172.16.0.4/30--r2
1.配置eth-turn
sw1、sw2操作类似:
[SW1]interface Eth-Trunk 0
[SW1-GigabitEthernet0/0/3]eth-trunk 0
[SW1-GigabitEthernet0/0/4]eth-trunk 0
2.创建并划分vlan,配置trunk
sw1、sw2配置类似:
[SW1]port-group group-member g0/0/5 g0/0/2 Eth-Trunk 0
[SW1-port-group]port link-type trunk
[SW1-port-group]port trunk allow-pass vlan all
Sw3、sw4操作类似:
[SW3]vlan 2
[SW3]int e0/0/4
[SW3-Ethernet0/0/4]port link-type access
[SW3-Ethernet0/0/4]port default vlan 2
[SW3]port-group group-member e0/0/2 e0/0/5
[SW3-port-group]port link-type trunk
[SW3-port-group]port trunk allow-pass vlan all
3.配置STP
sw1、sw2、sw3、sw4配置类似:
[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作为组1的主根,组2 的备份根
[SW1]stp instance 1 root primary
[SW1]stp instance 2 root secondary
Sw2作为组1的备份根,组2 的主根
[SW2]stp instance 2 root primary
[SW2]stp instance 1 root secondary
最好把组0也配置进去:
[SW1]stp instance 0 root primary
[sw2] stp instance 0 root secondary
最好把连接用户的接口边缘化一下:(优化)
不再往下发送BPDU
sw3、sw4操作类似
[sw3]port-group group-member e0/0/1 to e0/0/24
[sw3-port-group]stp edged-port enable
4.配置svi、vrrp
Sw1
[SW1]interface Vlanif 1
[SW1-Vlanif1]ip address 172.16.1.1 25
[SW1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[SW1-Vlanif1]vrrp vrid 1 priority 110
[SW1-Vlanif1]vrrp vrid 1 track interface g0/0/1 reduced 50
[SW1]interface Vlanif 2
[SW1-Vlanif2]ip add 172.16.1.129 25
[SW1-Vlanif2]vrrp vrid 2 virtual-ip 172.16.1.254
Sw2:
[sw2]interface Vlanif 1
[sw2-Vlanif1]ip address 172.16.1.2 25
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw2]interface Vlanif 2
[sw2-Vlanif2]ip address 172.16.1.130 25
[sw2-Vlanif2]vrrp vrid 2 virtual-ip 172.16.1.254
[sw2-Vlanif2]vrrp vrid 2 priority 110
[sw2-Vlanif2]vrrp vrid 2 track interface GigabitEthernet 0/0/2 reduced 50
5.配置DHCP:
sw1、sw2配置类似:
[sw1]dhcp enable
[sw1]ip pool 1
[sw1-ip-pool-1]network 172.16.1.0 mask 25
[sw1-ip-pool-1]gateway-list 172.16.1.126
[sw1-ip-pool-1]q
[sw1]ip pool 2
[sw1-ip-pool-2]network 172.16.1.128 mask 25
[sw1-ip-pool-2]gateway-list 172.16.1.254
[sw1]int Vlanif 1
[sw1-Vlanif1]dhcp select global
[sw1-Vlanif1]q
[sw1]int Vlanif 2
[sw1-Vlanif2]dhcp select global
6.配置路由:
r1:
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[r1-LoopBack0]ip add 1.1.1.1 24
R2:
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/1]ip add 172.16.0.1 30
[r2-GigabitEthernet0/0/2]ip add 172.16.0.5 30
Sw1、sw2类似:由于华为模拟器接口改为三层时配不了地址,所以用vlan99代替
[SW1]vlan 99
[SW1]int Vlanif 99
[SW1-Vlanif99]ip add 172.16.0.2 30
[SW1-GigabitEthernet0/0/1]port link-type access
[SW1-GigabitEthernet0/0/1]port default vlan 99
7.配置ospf:
容易忽略的地方:
把下面vlan部分的svi进行宣告,要不然ar2路由器学不到下面的路由表但是ospf在一个区域内是无法宣告的,所以需要做成两个区域。上面为区域0,即a0,下面为区域1即a1
[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]lip route-static 172.16.1.0 24 NULL
[sw2]ip route-static 172.16.1.0 24 NULL
优化(sv1和sv2会给所有trunk干道发hello包会造成洪泛流量,如果有更多的vlan,将有更多的hello包):
[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 99[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 Eth-Trunk 0
[sw2-ospf-1]undo silent-interface vlanif 1
[sw2-ospf-1]undo silent-interface vlanif 99
缺省路由
[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
配置nat:
[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
测试:(当sw1关了之后,pc1-pc4依旧可以上网,也可以把sw2关了)