单臂路由实验
实验拓扑
实验需求
1、按照图示为PC配置IP地址和网关
2、在交换机上把连接PC的端口分别划分到不同vlan,连接路由器的接口配置为trunk,并允许相关vlan通过
3、在路由器上划分不同子接口并绑定到不同vlan
4、要求2台PC可以互通
实验步骤
1.PC配置IP地址和网关略
2.配置交换机的端口,分别划分不同的vlan,连接路由器的接口为trunk
[SW2]vlan 10
[SW2-vlan10]port g1/0/1
[SW2-vlan10]vlan 20
[SW2-vlan20]port g1/0/2
[SW2-vlan20]int g1/0/3
[SW2-GigabitEthernet1/0/3]port link-type trunk
[SW2-GigabitEthernet1/0/3]port trunk permit vlan 10 20
3.在路由器上划分子接口并绑定到不同的vlan
[R1]int g0/0.1
[R1-GigabitEthernet0/0.1]vlan-type dot1q vid 10
[R1-GigabitEthernet0/0.1]ip add 192.168.1.254 24
[R1-GigabitEthernet0/0.1]int g0/0.2
[R1-GigabitEthernet0/0.2]vlan-type dot1q vid 20
[R1-GigabitEthernet0/0.2]ip add 192.168.2.254 24
4.配置结束后,在R1上查看路由表,会发现以及产生1.0和2.0网段的直连路由
[R1]disp ip routing-table
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/24 Direct 0 0 192.168.1.254 GE0/0.1
192.168.1.254/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.255/32 Direct 0 0 192.168.1.254 GE0/0.1
192.168.2.0/24 Direct 0 0 192.168.2.254 GE0/0.2
192.168.2.254/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.255/32 Direct 0 0 192.168.2.254 GE0/0.2
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1
实验结果
三层交换机实验
实验拓扑
实验需求
1、按照图示为PC配置IP地址和网关
2、在三层交换上为创建虚接口并配置相应IP地址
3、测试PC2和PC3可以互通
实验步骤
1.如图PC配置IP地址和网关略
2.创建vlan并加入到对应端口
[SW1]vlan 10
[SW1-vlan10]port g1/0/1
[SW1-vlan10]vlan 20
[SW1-vlan20]port g1/0/2
[SW1-vlan20]int vlan 10
3、在三层交换上开启vlanif接口并配置相应IP地址
[SW1-vlan10]int vlan 10
[SW1-Vlan-interface10]ip addr 192.168.1.254 24
[SW1-vlan20]int vlan 20
[SW1-Vlan-interface20]ip addr 192.168.2.254 24
[SW1]display ip int brief
*down: administratively down
(s): spoofing (l): loopback
Interface Physical Protocol IP Address Description
MGE0/0/0 down down -- --
Vlan10 up up 192.168.1.254 --
Vlan20 up up 192.168.2.254 --
还有一种方法是改变交换机端口类型为route
[SW1]int g1/0/1
[SW1-GigabitEthernet1/0/1]port link-mode route
[SW1-GigabitEthernet1/0/1]ip add 192.168.1.254 24
[SW1-GigabitEthernet1/0/1]int g1/0/2
[SW1-GigabitEthernet1/0/2]port link-mode route
[SW1-GigabitEthernet1/0/2]ip add 192.168.2.254 24
实验结果
itEthernet1/0/2]port link-mode route
[SW1-GigabitEthernet1/0/2]ip add 192.168.2.254 24
<!--该方法实验结果一致-->
#### 实验结果
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/c7e3b6d5a4ea4f80a1c2905364e86465.png)