静态路由配置和使用

路由下一跳配置
实验总览

实验,通过两台路由器分别来连接两台不同vlan 、 网段的PC实现通信

  • 知识点 1 ——下一跳的配置

第一步 配置 PC的 ip

本实验左侧PC配置192.168.1.2网段 / 网关192.168.1.1 右侧PC配置192.168.2.2网段 /网关是192.168.2.1

【这里选择的网段可以自定义,不一定相同】

这里的接口不要弄混了,否则下面教程不适用 分别是 0-0 1-1 0-0,

【注意】路由器是普通的路由器1841不是【2911】

配置完成PC的ip地址后接下来就是配置路由器

第二步 配置 路由器端口的 Ip 地址

可以看到,端口未打开所以是红色的

【注意】接下来不在赘述,过程复杂,认真揣摩

进入到左侧 路由器 1

Continue with configuration dialog? [yes/no]: no

Press RETURN to get started!
Router>en                  //进入特权模式
Router#configure           //进入全局配置模式
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface f0/0     //进入端口 f0/0 这个端口与主机 1相连接
 【注意】这里使用的是两口普通路由 不用 使用 gi
Router(config-if)#ip address 192.168.1.1 255.255.255.0   //端口0/0 添加 ip为192.168.1.1
Router(config-if)#no shutdown                            //打开端口
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit                    //退出操作 
//进入到0/1端口 【注意】这是与另一台路由器相连的端口
Router(config)#interface f0/1   
//给这个端口或者说这一路线添加2.0网段的ip  👇//
Router(config-if)#ip address 192.168.2.1 255.255.255.0  
Router(config-if)#no shutdown            //打开端口
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
Router(config-if)#exit
Router(config)#
好了,到这里左侧的路由器 端口 ip 部分已经全部完成了

左配置完成但是还是显示红色,别急,右边路由器还没配置呢。

接下来配置右侧路由器的端口 ip

进入路由器 2

Continue with configuration dialog? [yes/no]: no
Press RETURN to get started!
Router>en                    //进入特权模式
Router#conf                //进入全局配置模式
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface f0/0    //进入端口 f0/0 这个端口与主机 2相连接
Router(config-if)#ip address 192.168.3.1 255.255.255.0   //添加 ip 为主机2的网关接口
Router(config-if)#no shutdown        //打开端口
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit             //退出操作
//进入到0/1端口 【注意】这是与另一台路由器相连的端口
Router(config)#interface f0/1           //进入端口 f0/1
Router(config-if)#ip address 192.168.2.2 255.255.255.0  //给这个链路添加3.0网段ip
Router(config-if)#no shutdown           //打开端口
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#exit               //退出操作
Router(config)#

好了,到这里路由器端口的配置已经全部完成了,接下来配置下一跳

下一跳解释 百度百科https://baike.baidu.com/item/%E4%B8%8B%E4%B8%80%E8%B7%B3/3715698

路由的下一个点。如果路由器没有直接连接到目的网络,它会有一个提供下一跳路由的邻居路由器,用来传递数据到目的地。
在路由静态配置中使用。完整语法为ip route network-address subnet-mask ip-address 。network-address:要加入路由表的远程网络的目的网络地址subnet-mask:要加入的路由表的远程网络的子网掩码ip-address:一般指下一跳路由器IP地址

配置开始 进入到左侧的路由器的全局配置模式

Router>en                 //进入特权模式
Router#conf               //进入特权模式
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
    //使用 ip route指令 目标主机的ip 掩码进行广播   下一跳为右侧路由器f0/1的端口ip
Router(config)#ip route 192.168.3.2 255.255.255.255 192.168.2.2
Router(config)#exit   //退出操作
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#

左侧路由已经配置完成,接下来是右侧的路由器配置

Router>en                 //进入特权模式
Router#conf               //进入特权模式
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
    //使用 ip route指令 目标主机的ip 掩码进行广播   下一跳为左侧路由器f0/1的端口ip
Router(config)#ip route 192.168.1.2 255.255.255.255 192.168.2.1
Router(config)#exit
Router#
%SYS-5-CONFIG_I: Configured from console by console

Router#

到这里下一跳已经完全配置完成了。

验证实验是否成功

成功ping通

ping 右侧 PC 192.168.3.2 ping通入上图所示则表示实验成功,本实验结束。

实验结束,感谢你的阅读观看!

点击数:83

默认图片
JiHua article
文章: 17

留下评论