Experiência de arquitetura de três camadas
1. Construção de topologia
2. Planejamento de IP
公网地址设为12.1.1.0/24 网段环回设为1.1.1.1
使用172.16.1.0/24给交换机划分网段
在sw1中使用172.16.1.1/25和172.1.129/25
在sw2中使用172.16.1.2/25和172.1.130/25
使用172.16.0.0/30给上方左侧路由干道划分网段
使用172.16.0.4/30给上方右侧侧路由干道划分网段
3. Etapas experimentais
3.1 Configurar Eth-Trunk
Configure os troncos Eth-Trunk em sw1 e sw2
Primeiro crie os troncos no modo de administrador
e depois entre na interface para definir os troncos
[sw1]interface Eth-Trunk 0
[sw1]interface g0/0/1
[sw1]-GigabitEthernet0/0/1]eth-trunk 0
[sw1]-GigabitEthernet0/0/1]int g0/0/2
[sw1]-GigabitEthernet0/0/2]eth-trunk 0
[sw2]interface Eth-Trunk 0
[sw2]interface g0/0/1
[sw2]-GigabitEthernet0/0/1]eth-trunk 0
[sw2]-GigabitEthernet0/0/1]int g0/0/2
[sw2]-GigabitEthernet0/0/2]eth-trunk 0
3.2 Definir a estrada principal
No switch de camada 3 sw1
[sw1]port-group group-member Ethernet0/0/4 to Ethernet 0/0/5 Eth-Trunk 0
[sw1]-port-group]port link-type trunk
[sw1]-Ethernet0/0/4]port link-type trunk //系统提示
[sw1]-Ethernet0/0/5]port link-type trunk //系统提示
[sw1]-port-group]port trunk allow-pass vlan 2 to 3
[sw1-Ethernet0/0/4]port trunk allow-pass vlan 2 to 3
[sw1-Ethernet0/0/5]port trunk allow-pass vlan 2 to 3//系统提示说明配置成功
No switch de camada 3 sw2
[sw2]port-group group-member Ethernet0/0/4 to Ethernet 0/0/5 Eth-Trunk 0
[sw2]-port-group]port link-type trunk
[sw2]-Ethernet0/0/4]port link-type trunk //系统提示
[sw2]-Ethernet0/0/5]port link-type trunk //系统提示
[sw2]-port-group]port trunk allow-pass vlan 2 to 3
[sw2-Ethernet0/0/4]port trunk allow-pass vlan 2 to 3
[sw2-Ethernet0/0/5]port trunk allow-pass vlan 2 to 3//系统提示说明配置成功
Na camada 2, alterne sw3
[sw3]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[sw3]-port-group]port link-type trunk
[sw3]-Ethernet0/0/1]port link-type trunk //系统提示
[sw3]-Ethernet0/0/2]port link-type trunk //系统提示说明配置成功
[sw3]-port-group]port trunk allow-pass vlan 2
[sw3-Ethernet0/0/1]port trunk allow-pass vlan 2
[sw3-Ethernet0/0/2]port trunk allow-pass vlan 2//系统提示说明配置成功
Na camada 2, alterne sw4
[sw4]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[sw4]-port-group]port link-type trunk
[sw4]-Ethernet0/0/1]port link-type trunk //系统提示
[sw4]-Ethernet0/0/2]port link-type trunk //系统提示说明配置成功
[sw4]-port-group]port trunk allow-pass vlan 2
[sw4-Ethernet0/0/1]port trunk allow-pass vlan 2
[sw4-Ethernet0/0/2]port trunk allow-pass vlan 2//系统提示说明配置成功
Após a configuração, você pode display port vlan active
consultar o conjunto Trunk trunk . Conforme mostrado na
figura, como a vlan não foi criada, a exibição é toda 1.
3.3 Criação e divisão de vlan
[sw1]vlan 2//因为sw1上默认有vlan1所以只用创建一个vlan2就行
[sw1-vlan2]
[sw2]vlan 2
[sw2-vlan2]
[sw3]vlan 2
[sw3-vlan2]
[sw4]vlan 2
[sw4-vlan2]
Como pc2 e pc4 estão em vlan2, eles precisam ser divididos em vlan2
[sw3]int Ethernet0/0/4
[sw3-Ethernet0/0/4]port link-type access
[sw3-Ethernet0/0/4]port default vlan 2
[sw4]int Ethernet0/0/4
[sw4-Ethernet0/0/4]port link-type access
[sw4-Ethernet0/0/4]port default vlan 2
3.4 Árvore geradora STP
Tome sw1 como exemplo
[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
Após a configuração, você pode display stp brief
verificar o status do STP passando a imagem conforme mostrado na
figura
.Melhore de acordo com a regra do três em um.
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
[sw2]stp instance 1 root secondary
[sw2]stp instance 2 root primary
Melhore a eficiência da conexão do PC
[sw3]port-group group-member Ethernet 0/0/3 to e0/0/4
[sw3-port-group]stp edged-port enable
[sw4]port-group group-member Ethernet 0/0/3 to e0/0/4
[sw4-port-group]stp edged-port enable
3.5 Configurando SVI e VRRP
Primeiro configure o endereço IP para a vlan
[sw1]interface Vlan 1
[sw1-Vlanif1]ip address 172.16.1.1 25
[sw1]interface Vlanif 2
[sw1-Vlanif2]ip address 172.16.1.129 25
[sw2]interface Vlanif 1
[sw2-Vlanif1]ip address 172.16.1.2 25
[sw2]int Vlanif 2
[sw2-Vlanif2]ip address 172.16.1.130 25
Em sw1, vlan1 é a raiz e vlan2 é o backup
. Em sw2, vlan1 é o backup e vlan2 é a raiz.
[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 Ethernet 0/0/1 reduced 30
[sw1]interface Vlanif 2
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[sw2]interface Vlanif 1
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw2]interface Vlanif 2
[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 Ethernet0/0/1 reduced 30
Após a configuração, podemos display vrrp brief
visualizá-lo através do comando conforme mostrado na
figura
3.5 Defina o DHCP para obter o endereço IP
[sw2]dhcp enable
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw2]ip pool g1
Info:It's successful to create an IP address pool.
[sw2-ip-pool-g1] gateway-list 172.16.1.126
[sw2-ip-pool-g1] network 172.16.1.0 mask 255.255.255.128
[sw2-ip-pool-g1] dns-list 114.114.114.114
[sw2-ip-pool-g1]ip pool v2
Info:It's successful to create an IP address pool.
[sw2-ip-pool-v2] gateway-list 172.16.1.254
[sw2-ip-pool-v2] network 172.16.1.128 mask 255.255.255.128
[sw2-ip-pool-v2] dns-list 114.114.114.114 8.8.8.8
[sw2-ip-pool-v2]int vl1
[sw2-Vlanif1]dhcp select global
[sw2-Vlanif1]int vl2
[sw2-Vlanif2]dhcp select global
ipconfig
Após obtê-lo, podemos visualizar o IP através do comando no PC conforme mostrado na
figura
4. Configuração de roteamento
Como não há porta real no equipamento Huawei, configure duas interfaces lógicas
sw1 para sw1 e sw2
[sw1]vlan 100
[sw1-vlan100]q
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]port link-type access
[sw1-Ethernet0/0/1]p d vlan 100
[sw1]int Vlanif 100
[sw1-Vlanif100]ip address 172.16.0.1 30
[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 1
[sw1-ospf-1-area-0.0.0.1]network 172.16.1.129 0.0.0.0
em sw2
[sw2]vlan 100
[sw2-vlan100]q
[sw2]int e0/0/1
[sw2-Ethernet0/0/1]port link-type access
[sw2-Ethernet0/0/1]p d vlan 100
[sw2]int Vlanif 100
[sw2-Vlanif100]ip address 172.16.0.5 30
[sw2]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.5 0.0.0.0
[sw1-ospf-1]area 1
[sw1-ospf-1-area-0.0.0.1]network 172.16.1.130 0.0.0.0
no roteador
[r1]interface g0/0/1
[r1-GigabitEthernet0/0/1]ip address 172.16.0.2 30
[r1]interface g0/0/2
[r1-GigabitEthernet0/0/2]ip address 172.16.0.6 30
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.0.255
Então display ip routing-table protocol ospf
podemos descobrir que a rota mostrada na figura pode ser resumida
, então o ospf em sw1 e sw2 é passado para abr-summary 172.16.1.0 255.255.255.0
sumarização
. Após o resumo, descobrimos que cada svi estabelecerá um vizinho, o que fará com que muitos pacotes hello sejam enviados ser enviado, resultando na quantidade de atualizações É muito grande, então você deve usar a interface silenciosa . Como existem muitas interfaces para serem silenciosas, silenciamos diretamente todas as interfaces e, em seguida, usamos o comando desfazer para fazer o que queremos .
display ospf peer brief
[sw1-ospf-1]silent-interface all
[sw1-ospf-1]undo silent-interface Ethernet0/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]silent-interface all
[sw2-ospf-1]undo silent-interface Ethernet0/0/1
[sw1-ospf-1]undo silent-interface Eth-Trunk 0
[sw2-ospf-1]undo silent-interface Vlanif 1
[sw2-ospf-1]undo silent-interface Vlanif 100
5. Use NAT para se conectar à rede externa
[r1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
[r1-ospf-1]default-route-advertise
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r1-acl-basic-2000]int g0/0/0
[r1-GigabitEthernet0/0/0]nat outbound 2000
Em seguida, teste a conectividade no PC