虚拟局域网
PC0配置
PC1配置
PC2配置
Switch0配置
switch1配置
最终结果
PC0和PC2同属vlan2,PC1属于vlan1,所以PC0和2可以互相ping通,而PC0和PC1ping不通
静态路由配置
PC1
PC2
PC1 Fa0/0 接口 → \to → router1 Fa1/0 接口
PC2 Fa0/0 接口 → \to → router2 Fa1/0 接口
Router1 serial 2/0 → \to → router2 serial 2/0
Router1
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]: no # 选择no
Press RETURN to get started!
r1>enable # 进入admin模式
r1#
r1#configure terminal # 进入管理终端
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#interface FastEthernet1/0 # 进入端口1/0
r1(config-if)#ip address 192.168.1.1 255.255.255.0 # 配置端口的ip地址
r1(config-if)#no shutdown # 开启此端口,使它转发数据
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r1(config-if)#exit # 退出
r1(config)#interface serial 2/0 # 进入S2/0端口模式
r1(config-if)#no shutdown # 开启此端口
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
r1(config-if)#ip address 192.168.2.1 255.255.255.0 # 配置此端口的ip地址
r1(config-if)#clock rate 9600 # 配置此端口的时钟速率
r1(config-if)#exit # 退出
r1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2 # 配置静态路由
router2
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]: no # 选择no
Press RETURN to get started!
r1>enable # 进入admin模式
r1#
r1#configure terminal # 进入管理终端
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#interface FastEthernet1/0 # 进入端口1/0
r1(config-if)#ip address 192.168.3.1 255.255.255.0 # 配置端口的ip地址
r1(config-if)#no shutdown # 开启此端口,使它转发数据
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r1(config-if)#exit # 退出
r1(config)#interface serial 2/0 # 进入S2/0端口模式
r1(config-if)#no shutdown # 开启此端口
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
r1(config-if)#ip address 192.168.2.2 255.255.255.0 # 配置此端口的ip地址
r1(config-if)#exit # 退出
r1(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1 # 配置静态路由
结果
特别注意:
- 真机实验一定要关闭防火墙
- DTE线不用调节时钟频率(clock rate) ,DCE线需要
静态路由配置实验参考博客:
https://blog.csdn.net/Muyunuu/article/details/117045655
rip配置
- 只需删除静态路由实验中创建的路由表,再将其修改成RIP协议即可