目录
🦐博客主页:大虾好吃吗的博客
🦐专栏地址:huawei专栏
VLAN:VLAN(虚拟局域网)是对连接到的第二层交换机端口的网络用户的逻辑分段,不受网络用户的物理位置限制而根据用户需求进行网络分段。一个VLAN可以在一个交换机或者跨交换机实现。基于交换机的虚拟局域网能够为局域网解决冲突域、广播域、带宽问题。
OSPF:OSPF(Open Shortest Path First开放式最短路径优先)是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。
单臂路由:单臂路由(router-on-a-stick)是指在路由器的一个接口上通过配置子接口(或“逻辑接口”,并不存在真正物理接口)的方式,实现原来相互隔离的不同VLAN(虚拟局域网)之间的互联互通。

1、5台PC先配置IP,配置接入层交换机VLAN,指定0/0/1为trunk链路,0/0/2和0/0/3配置为access链路。
2、两台路由配置单臂路由允许多个VLAN数据通过,封装dot1q协议,配置1/2/3/4网段网关地址,5/6网段配置IP。
3、三层交换配置VLAN、IP、接口类型为access。
4、最后对两台路由器、三层交换机配置OSPF,router_id分别为1.1.1.1、2.2.2.2、3.3.3.3 。
5、测试全网互通
自行配置PC机地址,网关统一配置为1。
sys - [Huawei]undo info-center enable
- [Huawei]vlan batch 10 20
- [Huawei]int e0/0/1
- [Huawei-Ethernet0/0/1]port link-type trunk
- [Huawei-Ethernet0/0/1]port trunk allow-pass vlan all #all表示允许所有VLAN通过
- [Huawei-Ethernet0/0/1]int e0/0/2
- [Huawei-Ethernet0/0/2]port link-type access
- [Huawei-Ethernet0/0/2]port default vlan 10
- [Huawei-Ethernet0/0/2]int e0/0/3
- [Huawei-Ethernet0/0/3]port link-type access
- [Huawei-Ethernet0/0/3]port default vlan 20
sys - [Huawei]vlan batch 30 40
- [Huawei]int e0/0/1
- [Huawei-Ethernet0/0/1]port link-type trunk
- [Huawei-Ethernet0/0/1]port trunk allow-pass vlan all #all表示允许所有VLAN通过
- [Huawei-Ethernet0/0/1]int e0/0/2
- [Huawei-Ethernet0/0/2]port link-type access
- [Huawei-Ethernet0/0/2]port default vlan 30
- [Huawei-Ethernet0/0/2]int e0/0/3
- [Huawei-Ethernet0/0/3]port link-type access
- [Huawei-Ethernet0/0/3]port default vlan 40
sys - # 单臂路由
- [Huawei]int e0/0/0.1
- [Huawei-Ethernet0/0/0.1]dot1q termination vid 10
- [Huawei-Ethernet0/0/0.1]ip add 1.0.0.1 8
- [Huawei-Ethernet0/0/0.1]arp broadcast enable
- [Huawei-Ethernet0/0/0.1]int e0/0/0.2
- [Huawei-Ethernet0/0/0.2]dot1q termination vid 20
- [Huawei-Ethernet0/0/0.2]ip add 2.0.0.1 8
- [Huawei-Ethernet0/0/0.2]arp broadcast enable
- # 6.0网段IP
- [Huawei-Ethernet0/0/0.2]int e0/0/1
- [Huawei-Ethernet0/0/1]ip add 6.0.0.1 8
- # OSPF
- [Huawei-Ethernet0/0/1]ospf 1 router-id 1.1.1.1
- [Huawei-ospf-1]area 1
- [Huawei-ospf-1-area-0.0.0.1]net 1.0.0.0 0.255.255.255
- [Huawei-ospf-1-area-0.0.0.1]net 2.0.0.0 0.255.255.255
- [Huawei-ospf-1-area-0.0.0.1]net 6.0.0.0 0.255.255.255
sys - # 单臂路由
- [Huawei]int e0/0/0.1
- [Huawei-Ethernet0/0/0.1]dot1q termination vid 30
- [Huawei-Ethernet0/0/0.1]ip add 3.0.0.1 8
- [Huawei-Ethernet0/0/0.1]arp broadcast enable
- [Huawei-Ethernet0/0/0.1]int e0/0/0.2
- [Huawei-Ethernet0/0/0.2]dot1q termination vid 40
- [Huawei-Ethernet0/0/0.2]ip add 4.0.0.1 8
- [Huawei-Ethernet0/0/0.2]arp broadcast enable
- # 5.0网段IP
- [Huawei-Ethernet0/0/0.2]int e0/0/1
- [Huawei-Ethernet0/0/1]ip add 5.0.0.2 8
- # OSPF
- [Huawei-Ethernet0/0/1]ospf 1 router-id 2.2.2.2
- [Huawei-ospf-1]area 1
- [Huawei-ospf-1-area-0.0.0.1]net 3.0.0.0 0.255.255.255
- [Huawei-ospf-1-area-0.0.0.1]net 4.0.0.0 0.255.255.255
- [Huawei-ospf-1-area-0.0.0.1]net 5.0.0.0 0.255.255.255
sys - # 配置VLAN
- [Huawei]vlan batch 50 60 100
- [Huawei]int vlan 50
- [Huawei-Vlanif50]ip add 5.0.0.1 8
- [Huawei-Vlanif50]int vlan 60
- [Huawei-Vlanif60]ip add 6.0.0.2 8
- [Huawei-Vlanif60]int vlan 100
- [Huawei-Vlanif100]ip add 100.0.0.1 8
- # 指定接口及VLAN
- [Huawei-Vlanif100]int g0/0/1
- [Huawei-GigabitEthernet0/0/1]port link-type access
- [Huawei-GigabitEthernet0/0/1]port default vlan 60
- [Huawei-GigabitEthernet0/0/1]int g0/0/2
- [Huawei-GigabitEthernet0/0/2]port link-type access
- [Huawei-GigabitEthernet0/0/2]port default vlan 50
- [Huawei-GigabitEthernet0/0/2]int g0/0/3
- [Huawei-GigabitEthernet0/0/3]port link-type access
- [Huawei-GigabitEthernet0/0/3]port default vlan 100
- # OSPF
- [Huawei-GigabitEthernet0/0/3]ospf 1 router-id 3.3.3.3
- [Huawei-ospf-1]area 1
- [Huawei-ospf-1-area-0.0.0.1]net 5.0.0.0 0.255.255.255
- [Huawei-ospf-1-area-0.0.0.1]net 6.0.0.0 0.255.255.255
- [Huawei-ospf-1-area-0.0.0.1]net 100.0.0.0 0.255.255.255
以LSW1为例,如下。
- # 查看VLAN
- [Huawei]display vlan
- ...省略部分内容...
- 50 common UT:GE0/0/2(U)
-
- 60 common UT:GE0/0/1(U)
-
- 100 common UT:GE0/0/3(U)
-
-
- VID Status Property MAC-LRN Statistics Description
- --------------------------------------------------------------------------------
-
- 1 enable default enable disable VLAN 0001
- 50 enable default enable disable VLAN 0050
- 60 enable default enable disable VLAN 0060
- 100 enable default enable disable VLAN 0100
-
- # 查看当前全部信息
- [Huawei]display current-configuration
- ...省略部分内容...
-
- # 查看路由表
- [Huawei]display ip routing-table
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Routing Tables: Public
- Destinations : 12 Routes : 12
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 1.0.0.0/8 OSPF 10 2 D 6.0.0.1 Vlanif60
- 2.0.0.0/8 OSPF 10 2 D 6.0.0.1 Vlanif60
- 3.0.0.0/8 OSPF 10 2 D 5.0.0.2 Vlanif50
- 4.0.0.0/8 OSPF 10 2 D 5.0.0.2 Vlanif50
- 5.0.0.0/8 Direct 0 0 D 5.0.0.1 Vlanif50
- 5.0.0.1/32 Direct 0 0 D 127.0.0.1 Vlanif50
- 6.0.0.0/8 Direct 0 0 D 6.0.0.2 Vlanif60
- 6.0.0.2/32 Direct 0 0 D 127.0.0.1 Vlanif60
- 100.0.0.0/8 Direct 0 0 D 100.0.0.1 Vlanif100
- 100.0.0.1/32 Direct 0 0 D 127.0.0.1 Vlanif100
- 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
- 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
-
- # 查看OSPF邻居表
- [Huawei]display ospf peer brief
-
- OSPF Process 1 with Router ID 3.3.3.3
- Peer Statistic Information
- ----------------------------------------------------------------------------
- Area Id Interface Neighbor id State
- 0.0.0.1 Vlanif50 2.2.2.2 Full
- 0.0.0.1 Vlanif60 1.1.1.1 Full
- ----------------------------------------------------------------------------
-
- # 保存配置
-
save
使用ping命令依次测试全网是否互通,例如下。
- PC>ping 1.0.0.10
-
- Ping 1.0.0.10: 32 data bytes, Press Ctrl_C to break
- From 1.0.0.10: bytes=32 seq=1 ttl=126 time=109 ms
- From 1.0.0.10: bytes=32 seq=2 ttl=126 time=125 ms
- From 1.0.0.10: bytes=32 seq=3 ttl=126 time=94 ms
- From 1.0.0.10: bytes=32 seq=4 ttl=126 time=109 ms
- From 1.0.0.10: bytes=32 seq=5 ttl=126 time=93 ms
-
- --- 1.0.0.10 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 93/106/125 ms