静态路由的基本配置

  • 静态路由配置图如下

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通了

在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐