静态路由配置1
设置PC机ip,网关,开启接口,设置静态路由(目标网段+子网掩码+下一跳地址)
以Router1为例
Router>
Router>enable
Router#configure terminal
Router(config)#int f0/0
Router(config-if)#ip address 192.168.1.3 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#int f0/1
Router(config-if)#ip address 192.168.2.1 255.255.255.0 (设置两个接口的ip地址)
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
Router(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2(下一跳到达3.0与4.0网段)
Router(config)#
其他两个路由器同理
此拓扑图中,将三个路由器全部设置为静态路由或者两边两个设置为默认路由,中间位置设置为静态路由。
设置默认路由方法
Router(config)#ip route0.0.0.0 0.0.0.0 下一跳地址
Router#show ip route
静态路由配置2
设置PC机ip,网关,设置router的ip并开启其接口,设置静态路由(目标网段+子网掩码+下一跳地址)以及默认路由(0.0.0.0 0.0.0.0 下一跳地址)
1、4号router 设置为default route (默认路由)
2、3号router 设置为 static route (静态路由)
1号router设置过程
Router>
Router>enable
Router#configure terminal
Router(config)#int f0/0
Router(config-if)#ip address 192.168.1.3 255.255.255.0
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/1, changed state to up
Router(config-if)#exit
Router(config)#int f0/1
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/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#exit
Router(config)#ip route 0.0.0.0.0 0.0.0.0 192.168.2.2
Router(config)#
4号router类比1号
3号router设置如下
Router>en
Router#configure terminal
Router(config)#int f0/0
Router(config-if)#ip address 192.168.3.2 255.255.255.0
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
Router(config)#int f0/1
Router(config-if)#ip address 192.168.4.1 255.255.255.0
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)#ip route 192.168.5.0 255.255.255.0 192.168.4.2
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1
Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1
Router(config)#exit
Router#
Router#show ip route
Gateway of last resort is not set
S 192.168.1.0/24 [1/0] via 192.168.3.1
S 192.168.2.0/24 [1/0] via 192.168.3.1
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.4.0/24 is directly connected, FastEthernet0/1 (直连)
S 192.168.5.0/24 [1/0] via 192.168.4.2 (静态)
2号router设置类比3号