一.三层交换
实验目的:通过三层交换机实现不同vlan间的通信,然后实现全网互通!
1.拓扑图
2.配置
PC1 (其它同理)
SW1
<Huawei>
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys
[Huawei]sysname SW1
[SW1]vlan batch 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]int e0/0/1
[SW1-Ethernet0/0/1]p
[SW1-Ethernet0/0/1]p l a
[SW1-Ethernet0/0/1]p d v 10
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 20
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]p l a
[SW1-Ethernet0/0/3]p d v 30
[SW1-Ethernet0/0/3]int e0/0/4
[SW1-Ethernet0/0/4]p l t
[SW1-Ethernet0/0/4]p t a v a
[SW1-Ethernet0/0/4]
SW2
用到技术:vlan-interface 虚拟接口的技术 逻辑上划分的接口 子接口
<Huawei>
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys
[Huawei]sysname SW2
[SW2]vlan batch 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]p l t
[SW2-GigabitEthernet0/0/1]p t a v a
[SW2-GigabitEthernet0/0/1]q
[SW2]int vla
[SW2]int Vlanif 10
[SW2-Vlanif10]ip add 192.168.1.254 24
[SW2-Vlanif10]int vlanif 20
[SW2-Vlanif20]ip add 192.168.2.254 24
[SW2-Vlanif20]int vlanif 30
[SW2-Vlanif30]ip add 192.168.3.254 24
[SW2-Vlanif30]q
[SW2]
[SW2]vlan 100
[SW2-vlan100]int vlanif 100
[SW2-Vlanif100]ip add 192.168.4.1 24
[SW2-Vlanif100]q
[SW2]int g0/0/2
[SW2-GigabitEthernet0/0/2]p l a
[SW2-GigabitEthernet0/0/2]p d v 100
[SW2-GigabitEthernet0/0/2]
[SW2-GigabitEthernet0/0/2]
[SW2-GigabitEthernet0/0/2]q
[SW2]ip rou
[SW2]ip route-s
[SW2]ip route-static 192.168.5.0 24 192.168.4.2
[SW2]
R1
<Huawei>
<Huawei>
Dec 14 2023 16:10:04-08:00 Huawei %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEt
hernet0/0/0 has turned into UP state.
<Huawei>
Dec 14 2023 16:10:04-08:00 Huawei %%01IFPDT/4/IF_STATE(l)[1]:Interface GigabitEt
hernet0/0/1 has turned into UP state.
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.4.2 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.5.254 24
[R1-GigabitEthernet0/0/1]q
[R1]ip ro
[R1]ip route-s
[R1]ip route-static 0.0.0.0 0 192.168.4.1
3.测试
PC1--->PC4
PC1--->PC3
PC3---->PC4
二:DHCP
1.拓扑图
2.配置
PC1(其它同理)
R1
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys
[Huawei]sysname R1
[R1]dhcp e
[R1]dhcp enable //开启dhcp 功能
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[R1-GigabitEthernet0/0/0]dh
[R1-GigabitEthernet0/0/0]dhcp se
[R1-GigabitEthernet0/0/0]dhcp select in
[R1-GigabitEthernet0/0/0]dhcp select interface //选择接口模式
[R1-GigabitEthernet0/0/0]dh
[R1-GigabitEthernet0/0/0]dhcp se
[R1-GigabitEthernet0/0/0]dhcp ser
[R1-GigabitEthernet0/0/0]dhcp server l
[R1-GigabitEthernet0/0/0]dhcp server lease day 10
[R1-GigabitEthernet0/0/0]dhcp server lease day 10 h
[R1-GigabitEthernet0/0/0]dhcp server lease day 10 hour 3 m
[R1-GigabitEthernet0/0/0]dhcp server lease day 10 hour 3 minute 5 //设置租期
[R1-GigabitEthernet0/0/0]dh
[R1-GigabitEthernet0/0/0]dhcp serv
[R1-GigabitEthernet0/0/0]dhcp server dn
[R1-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8 //设置dns 固定的 记忆
[R1-GigabitEthernet0/0/0]
3.测试
地址池
拓扑图
配置
<Huawei>
Dec 14 2023 16:40:35-08:00 Huawei %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEt
hernet0/0/0 has turned into UP state.
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]ip po
[R2]ip pool xyl
Info: It's successful to create an IP address pool.
[R2-ip-pool-xyl]gat
[R2-ip-pool-xyl]gateway-list 192.168.1.254 //指定网关
[R2-ip-pool-xyl]ne
[R2-ip-pool-xyl]net
[R2-ip-pool-xyl]network 192.168.1.0 mask 24 //可以分配地址的范围是 192.168.1.0/24
[R2-ip-pool-xyl]l
[R2-ip-pool-xyl]leaseda
[R2-ip-pool-xyl]lease da
[R2-ip-pool-xyl]lease day 10 //租期
[R2-ip-pool-xyl]dns-
[R2-ip-pool-xyl]dns-list 114.114.114.114 //dns
[R2-ip-pool-xyl]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[R2-GigabitEthernet0/0/0]dhcp se
[R2-GigabitEthernet0/0/0]dhcp select gl
[R2-GigabitEthernet0/0/0]dhcp select global //选择全局的地址池给DHCP客户端使用
Error: Please enable DHCP in the global view first.
[R2-GigabitEthernet0/0/0]dhcp en
[R2-GigabitEthernet0/0/0]dhcp enable //开启!!!
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]dhcp select global
[R2-GigabitEthernet0/0/0]
[R2-GigabitEthernet0/0/0]
测试