1、配置交换机不输出信息
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]
2、VLAN技术应用
2.1、拓扑图如下
2.2、配置VLAN
①默认交换机所有的接口都是在VLAN1里面。
[Huawei]display vlan
The total number of vlans is : 1
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(U) Eth0/0/4(U)
Eth0/0/5(D) Eth0/0/6(D) Eth0/0/7(D) Eth0/0/8(D)
Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D)
Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D)
Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D)
Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D)
VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
1 enable default enable disable VLAN 0001
②按照2.1的拓扑图,创建VLAN
#单独创建VLAN
[Huawei]vlan 1
[Huawei-vlan1]quit
[Huawei]vlan 2
[Huawei-vlan2]
#批量创建VLAN
[Huawei]vlan batch 3 4 5 #创建VLAN3 VLAN4 VLAN5
[Huawei]vlan batch 6 to 10 #创建VLAN6到VLAN10共5个VLAN
#删除VLAN(生产环境慎用)
[Huawei]undo vlan 2 #删除VLAN2
[Huawei]undo vlan batch 3 to 10 #删除VLAN3到VLAN10
Warning: The configurations of the VLAN will be deleted. Continue?[Y/N]:y #输入y确认
Info: This operation may take a few seconds. Please wait for a moment...done.
2.3、把对应的接口加入到VLAN中
①分别把e0/0/1 e0/0/2加入到VLAN2中
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]port link-type access
[Huawei-Ethernet0/0/1]port default vlan 2
[Huawei-Ethernet0/0/1]quit
[Huawei]int e0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 2
[Huawei-Ethernet0/0/2]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:Eth0/0/3(U) Eth0/0/4(U) Eth0/0/5(D) Eth0/0/6(D)
Eth0/0/7(D) Eth0/0/8(D) Eth0/0/9(D) Eth0/0/10(D)
Eth0/0/11(D) Eth0/0/12(D) Eth0/0/13(D) Eth0/0/14(D)
Eth0/0/15(D) Eth0/0/16(D) Eth0/0/17(D) Eth0/0/18(D)
Eth0/0/19(D) Eth0/0/20(D) Eth0/0/21(D) Eth0/0/22(D)
GE0/0/1(D) GE0/0/2(D)
2 common UT:Eth0/0/1(U) Eth0/0/2(U) #这里看到已经成功加入到VLAN2了
3 common
VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
1 enable default enable disable VLAN 0001
2 enable default enable disable VLAN 0002
3 enable default enable disable VLAN 0003
②批量把e0/0/3 e0/0/4加入到VLAN3中
[Huawei]port-group 1
[Huawei-port-group-1]group-member e0/0/3 e0/0/4
[Huawei-port-group-1]port link-type access
[Huawei-Ethernet0/0/3]port link-type access #系统自动帮你敲的
[Huawei-Ethernet0/0/4]port link-type access #系统自动帮你敲的
[Huawei-port-group-1]port default vlan 3
[Huawei-Ethernet0/0/3]port default vlan 3 #系统自动帮你敲的
[Huawei-Ethernet0/0/4]port default vlan 3 #系统自动帮你敲的
[Huawei-port-group-1]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:Eth0/0/5(D) Eth0/0/6(D) Eth0/0/7(D) Eth0/0/8(D)
Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D)
Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D)
Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D)
Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D)
2 common UT:Eth0/0/1(U) Eth0/0/2(U)
3 common UT:Eth0/0/3(U) Eth0/0/4(U) #这里看到3号和4号口已经成功加入到VLAN3中了
VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
1 enable default enable disable VLAN 0001
2 enable default enable disable VLAN 0002
3 enable default enable disable VLAN 0003
3、还原交换机接口配置(如有做过配置)
<Huawei>system-view
[Huawei]clear configuration interface Ethernet 0/0/7 #清空7口的配置
Warning: All configurations of the interface will be cleared, and its state will be shutdown. Continue? [Y/N] :y Info: Total execute 0 command(s), 0 successful, 0 failed.
[Huawei-Ethernet0/0/7]undo shutdown #默认清空配置后接口会关闭,需要开启7口
4、创建trunk,使得所有链路都能通信
4.1拓扑图如下,需要使得VLAN2(2.0/24网段)和VLAN3(3.0/24)网段都能互通
4.2配置Trunk
[Huawei]int e0/0/7 #如上面的拓扑图,需要进入7号口配置
[Huawei-Ethernet0/0/7]port link-type trunk #配置为trunk口,可以通过多个vlan的数据
[Huawei-Ethernet0/0/7]port trunk allow-pass vlan all #激活配置
[Huawei-Ethernet0/0/7]display this
#
interface Ethernet0/0/7
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
return
5、路由器配置(基础)
5.1、拓扑图如下
5.2、分别给g0/0/0和g0/0/1配置IP地址
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.2.254 24
5.3、分别给pc1和pc2配置对应的IP地址和网关,然后再互ping
6、路由器工作原理
路由器依靠路由表工作,查看路由表
6.1、直连路由
<Huawei>dis ip routing-table | include /24 ##指定查看包括手动设置为24为掩码的路由
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet0/0/
0
192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet0/0/
1
6.2、静态路由
6.2.1拓扑图如下
6.2.2配置R1
<Huawei>sys
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[Huawei]ip route-static 192.168.3.0 24 192.168.2.2
[Huawei]ip route-static 192.168.4.0 24 192.168.2.2
#查看路由配置
[Huawei]dis ip routing-table | include /24
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet0/0/
0
192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet0/0/
1
192.168.3.0/24 Static 60 0 RD 192.168.2.2 GigabitEthernet0/0/
1
192.168.4.0/24 Static 60 0 RD 192.168.2.2 GigabitEthernet0/0/
1
6.2.3配置R2
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.3.254 24
[Huawei-GigabitEthernet0/0/1]quit
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 192.168.4.254 24
[Huawei-GigabitEthernet0/0/2]quit
##查看路由表配置
[Huawei]dis ip routing-table | include /24
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.0/24 Static 60 0 RD 192.168.2.1 GigabitEthernet0/0/
0
192.168.2.0/24 Direct 0 0 D 192.168.2.2 GigabitEthernet0/0/
0
192.168.3.0/24 Direct 0 0 D 192.168.3.254 GigabitEthernet0/0/
1
192.168.4.0/24 Direct 0 0 D 192.168.4.254 GigabitEthernet0/0/
2