当前位置:网站首页>路由与交换技术——静态路由
路由与交换技术——静态路由
2022-07-23 05:46:00 【賺钱娶甜甜】
静态路由
一、相关概念
1. 静态路由的优点 (1).不需要动态路由选择协议,减少路由器的日常开销; (2).在小型网络上很容易配置; (3).可以控制路由选择; (4).安全性比较高,允许网络管理员指定在有限的网络划分中哪些是可以公开,哪些可以隐藏起来。
二、简单的例子
1、拓扑结构:

2、设置主机IP地址

这是PC0的设置,其他主机也以此类推
34、配置路由
路由器1(R1):
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host
Router(config)#hostname R1(改名为:R1)
R1(config)#int
R1(config)#interface g0/1
R1(config-if)#iip add
R1(config-if)#ip addr
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no shut
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R1(config-if)#exit
R1(config)#int g
R1(config)#int gigabitEthernet 0/0
R1(config-if)#ip add
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no s
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
R1(config-if)#exit
路由器2(R1):
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host
Router(config)#hostname R2
R2(config)#int g
R2(config)#int gigabitEthernet 0/1
R2(config-if)#ip add
R2(config-if)#ip address 192.168.2.254 255.255.255.0
R2(config-if)#no shu
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R2(config-if)#ex
R2(config-if)#exit
R2(config)#int g
R2(config)#int gigabitEthernet 0/0
R2(config-if)#ip add
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R2(config-if)#ex
R2(config-if)#exit
4、配置静态路由(简单的拓扑结构)
R1(config)#ip route 192.168.2.0 255.255.255.0192.168.12.2
第一个ip地址是目的网段,第二个是掩码 第三个是下一跳
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.12.1
这样就算配好了,可以用命令:show ip route 查看路由信息
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, E - EGP
i - IS-IS, 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
Gateway of last resort is not set
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks6
C 192.168.1.0/24 is directly connected, GigabitEthernet0/1
L 192.168.1.254/32 is directly connected, GigabitEthernet0/1
S 192.168.2.0/24 [1/0] via 192.168.12.2 (via表示下一跳 [1/0] 1表示管理距离,0表示跳数)
192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.12.0/24 is directly connected, GigabitEthernet0/0
L 192.168.12.1/32 is directly connected, GigabitEthernet0/0
5、验证结果
ping不同网段的主机
如图 pc0(192.168.1.1) ping pc2 (192.168.2.1)
开始丢两个包是正常的

结果是:配置正确,ping通啦!!!
边栏推荐
猜你喜欢
随机推荐
APISIX的源码安装与使用
即时通讯WebSocket
C# 自定义栈(Stack)
剖析Redis集群
Common sort exchange sort
剑指 Offer做题总结
HCIP---BGP相关配置(联邦篇)
Analysis of UDP protocol and TCP protocol
hot 100深度优先
C语言也能写植物大战僵尸
Simply realize the function of stack
【读书笔记《凤凰架构》- 构架可靠的大型分布式系统.周志明】(一)
数组 LeetCode977. 有序数组的平方
详解TCP的流量控制机制与拥塞控制机制
剑指offer 05 两个栈实现队列
0最短路径问题 LeetCode743. 网络延迟时间
Unity在URP管线下使用TriLib插件加载模型材质不正确的问题
Analysis of Internet Protocol (II)
Analysis of Internet Protocol (I)
大白话说说synchronized关键词的三种用法








![[AUTOSAR DCM 1. module introduction (DSL, DSD, DSP)]](/img/99/55b3162ad061fbd00145d0b6810592.png)
