一、单臂路由的配置
、配置环境
实验软件:EVE-NG
思科ios版本:
R1路由器:version 15.7
S1交换机:version 15.2
拓扑图(有点简陋):
1、在路由器上配置单臂路由
- 首先在S1交换机上创建vlan10(192.168.1.0/24)、vlan20(192.168.2.0/24)并将接口与vlan绑定
- 在路由器上进行配置
配置步骤为:
开启e0/0接口
进入子接口
以太网帧封装为dot1q
配置子接口ip
配置命令为:
R1(config)#interface ethernet 0/0
R1(config-if)#no shutdown
R1(config-if)#interface ethernet 0/0.1
R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#ip address 192.168.1.254 255.255.255.0
R1(config-subif)#interface ethernet 0/0.2
R1(config-subif)#encapsulation dot1q 20
R1(config-subif)#ip address 192.168.2.254 255.255.255.0
在路由器上检验一下是否有路由表
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, Ethernet0/0.1
L 192.168.1.254/32 is directly connected, Ethernet0/0.1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, Ethernet0/0.2
L 192.168.2.254/32 is directly connected, Ethernet0/0.2
R1#
路由表存在,接下来尝试用pc机进行ping测试
可以ping通。
2、在三层交换机上配置单臂路由
- 首先在S2交换机上创建vlan10(192.168.3.0/24)、vlan20(192.168.4.0/24)并将接口与vlan绑定
- 在三层交换机上进行配置
配置步骤为:
启用路由功能
创建vlan10、vlan20
配置ip地址
配置命令为
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
Switch(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
Switch(vlan)#exi
APPLY completed.
Exiting....
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
S3(config)#interface vlan 10
S3(config-if)#ip add 192.168.4.254 255.255.255.0
S3(config-if)#no shut
S3(config-if)#interface vlan 20
S3(config-if)#ip add 192.168.5.254 255.255.255.0
S3(config-if)#no shut
S3(config-if)#interface ethernet 0/1
S3(config-if)#switch mode trunk