针对一个路由与交换的实际内容进行相关的配置和说明

 
这个在用模拟器做的时候搭建的拓扑,说明,R1为单臂路由,R0为路由器模拟的交换机,R2和R3模拟的是连接到交换机的PC。分布接入不同的VLAN,R2接入VLAN10,R3接入VLAN20。
配置:
------------------------------
R1
en
conf  t
no ip do lo
line con 0
no exec-t
logg sync
exit
int fa0/0
no sh   //启动接口,否则子接口会起不来的
int fa0/0.10
encapsulation dot1q vlan 10 //映射到VLAN10
ip add 10.10.1.1 255.255.255.0
no sh  //配置的VLAN10的网关
 
int fa0/0.20
encapsulation dot1q vlan 10 //映射到VLAN20
ip add 10.20.1.1 255.255.255.0
no sh
 
ip route 10.10.1.0 255.255.255.0 fa0/0.10
ip route 10.20.1.0 255.255.255.0 fa0/0.20  //配置静态路由,将两个VLAN连接通信
-------------------------
R0 模拟的是交换机
en
conf  t
no ip do lo
line con 0
no exec-t
logg sync
exit
no ip routing //模拟成交换机
exit
vlan data
vlan 10
vlan 20
exit
conf  t
int fa0/0
swi mode trunk
exit
int fa0/1
swi mode access
swi access vlan 10
exit
int vlan 10
ip add 10.10.1.2 255.255.255.0
no sh
exit
int fa0/10
switch mode access
swi access vlan 20
exit
int vlan 20
ip add 10.20.1.2 255.255.255.0
no sh
exit
---------------------------
R2
en
conf  t
no ip do lo
line con 0
no exec-t
logg sync
exit
no ip routing //模拟成PC
int f0/0
ip add 10.10.1.10 255.255.255.0
exit
ip default-gateway 10.10.1.1
exit
------------------------
R3
en
conf  t
no ip do lo
line con 0
no exec-t
logg sync
exit
no ip routing //模拟成PC
int f0/0
ip add 10.20.1.20 255.255.255.0
exit
ip default-gateway 10.20.1.1
exit
---------------------------
此时全网ping 通