文章目录
前言:
两个实验,第一个实验是简单的实现vlan的互通:同vlan通,不同vlan不通,第二个实验是通过配置ospf实现全网互通。
实验1:
实验环境
![捕获.PNG](https://www.icode9.com/i/ll/?i=img_convert/86d997599cb02e5ff0ae8cccb6ba4bc8.png#clientId=u42331768-cdc6-4&crop=0&crop=0&crop=1&crop=1&from=ui&id=uf6314797&margin=[object Object]&name=捕获.PNG&originHeight=321&originWidth=580&originalType=binary&ratio=1&rotation=0&showTitle=false&size=20698&status=done&style=none&taskId=u599146c2-d183-418f-ba46-fdeb33c7e67&title=)
实验需求
- 同vlan互通,不同vlan不通
实验步骤
1.配置交换机1
sy
[switch1]sysname SW1
[SW1]interface e0/0/2
[SW1-Ethernet0/0/2]vlan 10
[SW1]interface e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 10
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]vlan 20
[SW1-vlan20]int e0/0/3
[SW1-Ethernet0/0/3]p l a
[SW1-Ethernet0/0/3]p d v 20
[SW1-Ethernet0/0/3]int e0/0/1
[SW1-Ethernet0/0/1]p l t
[SW1-Ethernet0/0/1]port trunk allow-pass vlan 10 20
2.配置交换机2
sy
[Huawei]sysname SW2
[SW2]interface e0/0/2
[SW2-Ethernet0/0/2]vlan 10
[SW2]interface e0/0/2
[SW2-Ethernet0/0/2]p l a
[SW2-Ethernet0/0/2]p d v 10
[SW2-Ethernet0/0/2]int e0/0/3
[SW2-Ethernet0/0/3]vlan 20
[SW2-vlan20]int e0/0/3
[SW2-Ethernet0/0/3]p l a
[SW2-Ethernet0/0/3]p d v 20
[SW2-Ethernet0/0/3]int e0/0/1
[SW2-Ethernet0/0/1]p l t
[SW2-Ethernet0/0/1]port trunk allow-pass vlan 10 20
3.同vlan主机ping通
PC1 ping PC3:
4.不同vlan主机无法ping通
PC1 ping PC4:
实验2
实验环境
实验需求
- 配置 vlan 和 IP,配置 OSPF 实现全网互通
实验步骤
1.配置LSW1 vlan ip:
[LSW2]vlan batch 10 20
[LSW2]int Vlanif 10
[LSW2-Vlanif10]ip add 192.168.1.254 24
[LSW2]int Vlanif 20
[LSW2-Vlanif20]ip add 10.1.11.1 24
[LSW2-Vlanif20]int g0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type access
[LSW1-GigabitEthernet0/0/1]port default vlan 10
[LSW1-GigabitEthernet0/0/1]int g0/0/2
[LSW1-GigabitEthernet0/0/2]port link-type access
[LSW1-GigabitEthernet0/0/2]port default vlan 20
2.配置AR1 ip:
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 10.1.11.2 24
[AR1-GigabitEthernet0/0/0]int g0/0/1
[AR1-GigabitEthernet0/0/1]ip add 10.1.12.1 24
3.配置LSW2 vlan ip:
[LSW2]vlan batch 30 40
[LSW2]int Vlanif 30
[LSW2-Vlanif30]ip add 10.1.12.2 24
[LSW2-Vlanif30]int Vlanif 40
[LSW2-Vlanif40]ip add 192.168.2.254 24
[LSW2-Vlanif40]int g0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type access
[LSW2-GigabitEthernet0/0/1]port default vlan 30
[LSW2-GigabitEthernet0/0/1]int g0/0/2
[LSW2-GigabitEthernet0/0/2]port link-type access
[LSW2-GigabitEthernet0/0/2]port default vlan 40
4.配置LSW2 ospf:
[LSW2]ospf router-id 1.1.1.1
[LSW2-ospf-1]a 1
[LSW2-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.1]network 10.1.11.0 0.0.0.255
5.配置AR1 ospf:
[AR1]ospf router-id 2.2.2.2
[AR1-ospf-1]a 1
[AR1-ospf-1-area-0.0.0.1]network 10.1.11.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.1]a 2
[AR1-ospf-1-area-0.0.0.2]network 10.1.12.0 0.0.0.255
6.配置LSW2 ospf:
[LSW2]ospf router-id 3.3.3.3
[LSW2-ospf-1]a 2
[LSW2-ospf-1-area-0.0.0.2]network 10.1.12.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.2]network 192.168.2.0 0.0.0.255
PC1 ping PC2