使用交换机搭建一个简单的局域网(路由器交换机如何组建局域网)

2022-08-05 18:34:48

扫码,关注我的公众号


一、写在文章前面


首先跟大家声明,本实验是一个局域网。即是局域网,那就无法与局域网外的设备交换信息。

其次跟大家说清楚:局域网是一个非常灵活的网络,可以很小也可以很大。小到两台电脑可以搭建成一个局域网,大到几十甚至上百的设备构成局域网,所以希望大家在看文章前面能明白本实验的目的。

最后跟大家分享本实验的目的:主要是在模拟一个可大可小的网络,功能相对齐全,数据交换相对顺畅的网络,很多不足也希望大家指正,交流。

二、模拟及地址划分


设计一个单位的网络,分为三个部门,地址如下:

部门名

IP地址

子网掩码

网关

部门A

19.20.20.*

255.255.255.0

19.29.20.1

部门B

19.20.21.*

255.255.255.0

19.29.21.1

部门C

19.20.22.*

255.255.255.0

19.29.22.1

设计一个单位的服务器网络,分为2个服务器,地址如下:

服务器名

IP地址

子网掩码

网关

服务A

18.20.19.2

255.255.255.0

19.29.19.1

服务B

18.20.19.3

255.255.255.0

19.29.19.1

规划不同部门及服务器在不同的网段,将其分在不同的vlan下面,主要是为了隔离广播风暴,提高网速。然后通过核心交换机进行数据交换。

三、拓扑结构图


拓扑结构图如上,地址分配也已经在图上展现,接下来就是配置了。

四、各个设备配置


01

PART

配置核心交换机

先分VLAN,如下图:

再配置各个接口类型,如下图:

然后配置各个vlan的网关。如下图:

[Huawei]clear configuration int g0/0/1 //由于之前配置失误,这里清除一下配置

Warning: All configurations of the interface will be cleared, and its state will

be shutdown. Continue? [Y/N] :y

Info: Total execute 2 command(s), 2 successful, 0 failed.

[Huawei]int g0/0/1

[Huawei-GigabitEthernet0/0/1]

[Huawei-GigabitEthernet0/0/1]port link-type trunk

[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all

[Huawei-GigabitEthernet0/0/1]q

[Huawei]int vlanif 10

[Huawei-Vlanif10]ip add

[Huawei-Vlanif10]ip address 18.29.20.1 25

[Huawei-Vlanif10]ip address 18.29.20.1 24

[Huawei-Vlanif10]q

[Huawei]int Vlanif 20

[Huawei-Vlanif20]ip add

[Huawei-Vlanif20]ip address 18.29.21.1 24

[Huawei-Vlanif20]q

[Huawei]int vlanif 30

[Huawei-Vlanif30]

[Huawei-Vlanif30]ip add

[Huawei-Vlanif30]ip address 18.29.22.1 24

[Huawei-Vlanif30]

[Huawei-Vlanif30]q

[Huawei]

[Huawei]int g0/0/1

[Huawei-GigabitEthernet0/0/1]undo shu

[Huawei-GigabitEthernet0/0/1]undo shutdown //由于清理了配置,所以需要重启端口1

[Huawei-GigabitEthernet0/0/1]q

[Huawei]vlan 40

[Huawei-vlan40]q

[Huawei]int vlanif 40

[Huawei-Vlanif40]ip add

[Huawei-Vlanif40]ip address 18.29.19.1 24


02

PART

配置服务器的交换机

sys

[Huawei]int e0/0/1

[Huawei-Ethernet0/0/1]port link-type trunk

[Huawei-Ethernet0/0/1]port trunk allow-pass vlan all

[Huawei-Ethernet0/0/1]q

[Huawei]int e0/0/2

[Huawei-Ethernet0/0/2]port link-type trunk

[Huawei-Ethernet0/0/2]port trunk allow-pass vlan all

[Huawei-Ethernet0/0/2]q

[Huawei]int e0/0/3

[Huawei-Ethernet0/0/3]port link-type access

[Huawei-Ethernet0/0/3]port default vlan 40

Error: The VLAN does not exist.

[Huawei-Ethernet0/0/3]q

[Huawei]vlan 40

[Huawei-vlan40]int e0/0/2

[Huawei-Ethernet0/0/2]port link-type access

Error: Please renew the default configurations.

[Huawei-Ethernet0/0/2]q

[Huawei]cle

[Huawei]clear configuration interface e0/0/2

Warning: All configurations of the interface will be cleared, and its state will

be shutdown. Continue? [Y/N] :y

Info: Total execute 2 command(s), 2 successful, 0 failed.

[Huawei]int e0/0/2

[Huawei-Ethernet0/0/2]port link-type a

[Huawei-Ethernet0/0/2]

[Huawei-Ethernet0/0/2]port default vlan 40

[Huawei-Ethernet0/0/2]undo shutdown

[Huawei-Ethernet0/0/2]

[Huawei-Ethernet0/0/2]q

[Huawei]int e0/0/3

[Huawei-Ethernet0/0/3]port link-type access

[Huawei-Ethernet0/0/3]port default vlan 40

[Huawei-Ethernet0/0/3]q

[Huawei]

[Huawei]


五、测试联通性


01


PC1 PING PC2


01


PC1 PING PC3


01


PC1 PING 核心网关


01


PC1 PING 服务器


六、结语


通过以上配置,就可以完成一个较为高级的局域网配置了,大部分中等局域网都是这么配置的,这样的配置也适用大多网络。你们看懂了吗?

扫码关注我吧


点击在看,了解更多精彩内容