静态路由的基本配置

静态路由的基本配置

  • 静态路由配置图如下

PC1 IP地址:192.168.1.2
PC2 IP地址:192.168.2.2
PC3 IP地址:192.168.3.2
PC4 IP地址:192.168.4.2

R1 IP地址:
f1/0 192.168.3.1
f0/2 192.168.4.1
s2/0 1.1.1.1
R2 IP地址:
f0/0 192.168.1.1
f1/0 192.168.2.1
s2/0 1.1.1.2

在这里插入图片描述
注:图中的端口号写错了f0/1应该是f1/0

  1. 配置好四台电脑的IP,不懂得可以去主页看上一篇文章
  2. 配置R1ip
Router>enable 
Router#conf
Router#configure 
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname R1
R1(config)#int f0/0
R1(config-if)#ip address 192.168.4.1 255.255.255.0
R1(config-if)#no shutdown 

R1(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

R1(config)#int f1/0
R1(config-if)#ip address 192.168.3.1 255.255.255.0
R1(config-if)#no shutdown 

R1(config-if)#
%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)#int s2/0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#clock rate 64000
R1(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Serial2/0, changed state to down
R1(config-if)#
  1. 配置R2的ip
 R2(config)#int f0/0
R2(config-if)#ip add 192.168.1.1 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown 

R2(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

R2(config-if)#int f1/0
R2(config-if)#ip add 192.168.2.1 255.255.255.0 
R2(config-if)#no sh

R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up

R2(config-if)#int s2/0 
R2(config-if)#ip add 1.1.1.2 255.255.255.0
R2(config-if)#no sh

R2(config-if)#
%LINK-5-CHANGED: Interface Serial2/0, changed state to up

R2(config-if)#

4.配置完ip后配置静态路由

注:ip routte的配置命令解释

ip route [network] [mask ] [address]
ip route :创建静态路由
network:目标网络号
mask:目标子网掩码
address:下一跳的IP地址

  • R1的静态路由配置
    如下 R1的静态路由,因为R1的数据要去访问R2上的目标,使用得告诉R1,R2上有多少个网络号,并且指向从S2/0口的1.1.1.2出去访问R2
R1(config)#ip route 192.168.1.0 255.255.255.0 1.1.1.2
R1(config)#ip route 192.168.2.0 255.255.255.0 1.1.1.2
  • R2的静态路由配置
R2(config)#ip route 192.168.3.0 255.255.255.0 1.1.1.1
R2(config)#ip route 192.168.4.0 255.255.255.0 1.1.1.1

5.配置完静态路由后,四台PC就可以相互ping通了

在这里插入图片描述

  • 53
    点赞
  • 404
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

啊醒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值