【网络】静态路由配置
2017-10-18 本文已影响285人
吾非言
作者:邹峰立,微博:zrunker,邮箱:zrunker@yahoo.com,微信公众号:书客创作,个人平台:www.ibooker.cc。
![](https://img.haomeiwen.com/i3480018/3d90bdf9c45945d2..jpg)
首先来看一下本次要实验的课程目标:
如下:要实现两台PC机(电脑)的通信、
![](https://img.haomeiwen.com/i3480018/c5157f32ae9d7303..jpg)
有两个路由器,R1和R2,两台PC机,他们的IP分别是(IP地址是任意取值):
PC1:192.168.1.10、PC2:192.168.3.10、
R1的f0/0端口IP地址为:192.168.1.1、R1的f0/1端口IP地址为:192.168.2.1、
R1的f0/0端口IP地址为:192.168.3.1、R1的f0/1端口IP地址为:192.168.2.2、
那么要实现PC1与PC2通信要实现下面几个步骤:
首先配置PC机的IP:
PC1:
![](https://img.haomeiwen.com/i3480018/02c7e031d49ff623..jpg)
PC2:
![](https://img.haomeiwen.com/i3480018/74c3f3e6e59106ea..jpg)
下面是对路由器的配置:
R1进行配置:分三步进行设置
Router>
Router>enable 进入全局模式
Router#configure terminal 进入特权模式
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1 重命名R1
R1(config)#int f0/0 进入端口f0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0 配置ip地址
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
// 下面是对f0/1端口进行配置
R1(config-if)#exit
R1(config)#int f0/1
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
R1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
**// 最后是对ip route进行配置**
**// 格式:ip route 目的网段 目的网段子网掩码 下一跳地址**
R1(config-if)#exit
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R1(config)#
同理R2路由器的配置也是一样的道理:
Router>en
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#int f0/0
R2(config-if)#ip address 192.168.3.1 255.255.255.0
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)#exit
R2(config)#interface f0/1
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#no shutdown
R2(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
R2(config-if)#exit
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
R2(config)#
进行到这儿就已经完成了本次案例的配置工作。
![](https://img.haomeiwen.com/i3480018/7caba7c0b4ebb962..jpg)
温馨提示:按TAB键可以自动扩充命令。
![](https://img.haomeiwen.com/i3480018/86ab03df951d24c9..jpg)