标签:路由器 二层交换机 三层交换机
实验:
LW1:
<LW1>sys
[LW1]vlan batch 7 to 9 建立7--9valn
[LW1]interface eth0/0/1
[LW1-Ethernet0/0/1]port link-type access 将端口加入vlan
[LW1-Ethernet0/0/1]port default vlan 7
[LW1-Ethernet0/0/1]q
[LW1]interface eth 0/0/2
[LW1-Ethernet0/0/2]port link-type access
[LW1-Ethernet0/0/2]port default vlan 8
LW1-Ethernet0/0/2]q
[LW1]interface eth 0/0/3
[LW1-Ethernet0/0/3]port link-type access
[LW1-Ethernet0/0/3]port default vlan 9
LW3:
[Huawei]sysname LW3
[LW3]vlan batch 10 11 建立10 11vlan
[LW3]interface eth0/0/3
[LW3-Ethernet0/0/3]port link-type access 将端口加入vlan
[LW3-Ethernet0/0/3]port default vlan 10
[LW3-Ethernet0/0/3]q
[LW3]interface eth0/0/1
[LW3-Ethernet0/0/1]port link-type access
[LW3-Ethernet0/0/1]port default vlan 11
LW1:
[LW1]interface eth0/0/4
[LW1-Ethernet0/0/4]port link-type trunk 进入端口设置连接类型为trunk模式
[LW1-Ethernet0/0/4]port trunk allow-pass vlan all
LW3:
[LW3]interface eth0/0/4
[LW3-Ethernet0/0/4]port link-type trunk
[LW3-Ethernet0/0/4]port trunk allow-pass vlan all
LW2:
[Huawei]sysname LW2
[LW2]interface gi0/0/1
[LW2-GigabitEthernet0/0/1]port link-type trunk
[LW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[LW2-GigabitEthernet0/0/1]q
[LW2]interface gi0/0/2
[LW2-GigabitEthernet0/0/2]port link-type trunk
[LW2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[LW2-GigabitEthernet0/0/2]q
[LW2]vlan batch 7 to 11 在交换机上新增7--11vlan
[LW2]interface vlanif 7
[LW2-Vlanif7]ip address 192.168.7.254 24 给vlan配置对应的ip 即pc的网关
[LW2-Vlanif7]q
[LW2]int vlanif 8
[LW2-Vlanif8]ip add 192.168.8.254 24
[LW2-Vlanif8]q
[LW2]interface vlanif 9
[LW2-Vlanif9]ip add 192.168.9.254 24
[LW2-Vlanif9]q
[LW2]interface vlanif 10
[LW2-Vlanif10]ip add 192.168.10.254 24
[LW2-Vlanif10]q
[LW2]interface vlanif 11
[LW2-Vlanif11]ip add 192.168.11.254 24
LW2:
[LW2]vlan 12 将三层交换机新增一个vlan12
[LW2]interface vlanif 12
[LW2-Vlanif12]ip add 192.168.13.1 24 给vlan配置ip也是这个端口的ip
[LW2]interface gi0/0/3
[LW2-GigabitEthernet0/0/3]port link-type access 将此端口加入vlan12
[LW2-GigabitEthernet0/0/3]port default vlan 12
[LW2]interface gi0/0/3
[LW2-GigabitEthernet0/0/3]ip route-static 192.168.12.0 255.255.255.0 192.168.13.2 在此端口设置静态路由
AR1:
[AR1]interface gi0/0/0
[AR1-GigabitEthernet0/0/0]ip add 192.168.13.2 24 路由器两个端口都设置ip地址
[AR1-GigabitEthernet0/0/0]q
[AR1]interface gi 0/0/1
[AR1-GigabitEthernet0/0/1]ip add 192.168.12.254 24
[AR1]interface gi0/0/0
[AR1-GigabitEthernet0/0/0]ip route-static 0.0.0.0 0.0.0.0 192.168.13.1 在此端口设置静态路由,因为要连接下面所有pc的路径只有这一条,一定要经过这个端口,所以将目的ip设置为0.0.0.0即默认所有ip 网关同理0.0.0.0
验证:PC1拼网关->pc1ping其他pc-->如果全都拼通代表内部网络没问题-->ping外网13.1-->ping13.2-->ping192.168.12.254-->ping pc12ip
注意:三层交换机充当了交换机和路由器两个角色,但给交换机的端口配置ip只能通过虚拟vlan配置,并且一定要将端口加入到vlan中,此时交换机还是本身交换机的角色,所以要用access模式,而不是路由器中直接配置ip。并且只有交换机与交换机之间用trunk连接
标签:路由器 二层交换机 三层交换机
原文地址:http://blog.51cto.com/13721786/2113056