在三层交换机上配置路由实例
v 在三层交换机上配置路由接口
SW-3L(config)#inter f0/23
SW-3L(config-if)#no switchport
SW-3L(config-if)#ip address 10.1.1.1 255.255.255.252
SW-3L(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
v 在路由器上配置路由
Router(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.1
Router(config)#ip route 192.168.2.0 255.255.255.0 10.1.1.1
Router(config)#ip route 192.168.3.0 255.255.255.0 10.1.1.1
v 查看f0/23接口信息
SW-3L#show inter f0/23 switchport
Name: Fa0/23
Switchport: Disabled
v 显示交换机的路由表
SW-3L#show ip route
Codes: 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, su - IS-IS summary, 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 10.1.1.2 to network 0.0.0.0
10.0.0.0/30 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/23
C 192.168.1.0/24 is directly connected, Vlan1
C 192.168.2.0/24 is directly connected, Vlan2
C 192.168.3.0/24 is directly connected, Vlan3
S* 0.0.0.0/0 [1/0] via 10.1.1.2
v 在各VLAN互通的前提下,配置DHCP中继服务
SW-3L(config)#interface vlan 1
SW-3L(config-if)#ip helper-address 192.168.2.100
SW-3L(config)#interface vlan 3
SW-3L(config-if)#ip helper-address 192.168.2.100
v 路由
§ 跨越从源主机到目标主机的一个互联网络来转发数据包的过程
路由器--能够将数据包转发到正确的目的地,并在转发过程中选择最佳路径的设备.
静态与默认路由适用的环境
v 静态路由
§ 特点
• 路由表是手工设置的
• 除非网络管理员干预,否则静态路由不会发生变化
• 路由表的形成不需要占用网络资源
§ 适用环境
• 一般用于网络规模很小、拓扑结构固定的网络中
v 默认路由
§ 特点
• 在所有路由类型中,默认路由的优先级最低
§ 适用环境
• 一般应用在只有一个出口的末端网络中
• 或作为其他路由的补充
路由和交换对比
v 路由工作在网络层
§ 根据“路由表”转发数据
§ 路由选择
§ 路由转发
v 交换工作在数据链路层
§ 根据“MAC地址表”转发数据
§ 硬件转发
路由器的配置模式
v 用户模式:Router>
v 特权模式:Router#
v 全局配置模式:Router(config)#
v 接口配置模式:Router(config-if)#
v 子接口配置模式: Router(config)#interface fa0/0.1
Router(config-subif)#
v Line模式:Router(config-line)#
v 路由模式:Router(config-router)#
静态路由的配置
Router A>enable
Router A#config terminal
Router A(config) #interface f0/0
Router A(config-if) #ip address 192.168.2.2 255.255.255.0
Router A(config-if)#no shutdown
Router A(config-if)#exit
Router A(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
默认路由的配置
Router B>enable
Router B#config terminal
Router B(config) #interface f0/1
Router B(config-if) #ip address 192.168.2.1 255.255.255.0
Router B(config-if)#no shutdown
Router B(config-if)#exit
Router B(config) #interface f0/0
Router B(config-if) #ip address 192.168.1.1 255.255.255.0
Router B(config-if)#no shutdown
Router B(config-if)#exit
Router B(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
查看路由器配置
Router A#show running-config
!
interface Loopback0
no ip address
!
interface FastEthernet0/0
ip address 192.168.2.2 255.255.255.0
duplex auto
speed auto
!
ip classless
ip route 192.168.1.0 255.255.255.0 192.168.2.1
no ip http server
!
line con 0
line aux 0
line vty 0 4
查看路由表
RouterA#show ip route
Codes: 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
i - IS-IS, su - IS-IS summary, 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
S 192.168.1.0/24 [1/0] via 192.168.2.1
C 192.168.2.0/24 is directly connected, FastEthernet0/0
检查配置是否正确
v 在路由器A上,使用ping命令检查与192.168.1.0网段的主机是否连通:
Router A# ping 192.168.1.10
如果ping通,此时在路由器A上显示:Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.10, timeout is 2 seconds:
! ! ! ! !
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
如果不通,在路由器A上会显示:Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.10, timeout is 2 seconds:
. . . . .
Success rate is 0 percent (0/5)
为Cisco 2600路由器配置密码
v 配置控制台密码
teacher(config)#line console 0
teacher((config_line)#login
teacher((config_line)#password cisco
v 配置特权模式密码
teacher(config)#enable password cisco
v 配置加密保存的密码
teacher(config)#enable secret 1234
v 对所有密码加密
teacher(config)#service password-encryption
Cisco 2600路由器的描述信息
v 配置路由器的banner信息
teacher(config)#banner motd $This is Aptech
company’s Router! Please don’t change the
configuration without permission! $
v 配置路由器接口的描述信息
teacher(config)#interface fastethernet 0/0
teacher(config_if)#description This is a fast ethernet
port used to connecting the company’s intranet!
配置路由器的控制台会话
v 配置控制台会话时间
teacher(config)#line console 0
teacher(config_line)#exec-timeout 0 0
v 配置控制台输出日志同步
teacher(config)#line console 0
teacher(config_line)#logging synchronous
v 配置禁用DNS
teacher(config)#no ip domain-lookup
路由器密码恢复
v 进入ROM Monitor模式
v 修改配置寄存器的值,启动时绕过startup-config文件:
§ rommon1>confreg 0x2142
§ rommon2>reset
v 用startup-config覆盖running-config:
§ Router#copy startup-config running-config
v 修改密码:
§ Router(config)#enable password cisco
v 修改配置寄存器的值:
§ Router(config)#config-register 0x2102
查看路由器配置
teacher #show version
Cisco Internetwork Operating System Software
IOS (tm) 2600 Software (C2600-JS-L), Version 12.0(3), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Mon 08-Feb-99 18:18 by phanguye
Image text-base: 0x03050C84, data-base: 0x00001000
ROM: System Bootstrap, Version 11.0(10c), SOFTWARE
BOOTFLASH: 3000 Bootstrap Software (IGS-BOOT-R), Version 11.0(10c), RELEASE SOFTWARE(fc1)
wg_ro_a uptime is 20 minutes
System restarted by reload
System image file is "flash:c2600-js-l_120-3.bin"
(output omitted)
--More--
Configuration register is 0x2102
单臂路由的配置
Router(config)# interface f0/0.1
Router(config-subif)# encapsolution dot1q 1
Router(config-subif)# ip address 192.168.1.1 255.255.255.0
Router(config)# interface f0/0.2
Router(config-subif)# encapsolution dot1q 2
Router(config-subif)# ip address 192.168.2.1 255.255.255.0
DCE和DTE设置
router# show controllers serial0 查看串口0的物理层信息 主要是查看DTE/DCE
(config-if)# encapsulation ppp 封装ppp
(config-if)# clockrate
64000 如果是DCE使需要设置时钟速率
如果是DTE使不必设置
(config-if)#
bandwidth
64 设置端口带宽为64K
什么是动态路由
§ 网络中的路由器之间相互通信,传递路由信息,利用收到的路由信息更新和维护路由表的过程
§ 基于某种路由协议实现的
v 动态路由的特点
§ 减少管理任务
§ 占用网络带宽
动态路由协议
v 动态路由协议
§ 向其他路由器传递路由信息
§ 接收其他路由器的路由信息
§ 根据收到的路由信息计算出到每个目的网络的最优路径,并由此生成路由表
§ 根据网络拓朴变化及时调整路由表,同时向其他路由器宣告拓朴改变的信息
RIP v1路由协议的配置
v 启动RIP进程
Router(config)# router rip
v 宣告主网络号
Router(config-router)# network network-number
验证配置
v 查看路由表
Router# show ip route
v 查看路由协议配置
Router# show ip protocols
v 打开RIP协议调试命令
Rouetr# debug ip rip
RIP v1路由协议配置实例
RouterA(config)#interface f0/0
RouterA(config-if)#ip address 192.168.1.1 255.255.255.0
RouterA(config-if)#no shutdown
RouterA(config)#interface f0/1
RouterA(config-if)#ip address 10.0.0.2 255.0.0.0
RouterA(config-if)#no shutdown
RouterA(config)#router rip
RouterA(config-router)#network 10.0.0.0
RouterA(config-router)#network 192.168.1.0
RouterB(config)#interface f0/0
RouterB(config-if)#ip address 10.0.0.1 255.0.0.0
RouterB(config-if)#no shutdown
RouterB(config)#interface f0/1
RouterB(config-if)#ip address 20.0.0.2 255.0.0.0
RouterB(config-if)#no shutdown
RouterB(config)#router rip
RouterB(config-router)#network 10.0.0.0
RouterB(config-router)#network 20.0.0.0
查看路由表
RouetrA# show ip route
Codes: 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
i - IS-IS, su - IS-IS summary, 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
C 192.168.1.0 is directly connected, FastEthernet0/0
C 10.0.0.0 is directly connected, FastEthernet0/1
R 20.0.0.0 [120/1] via 10.0.0.1, 00:00:15, FastEthernet0/1
R 192.168.2.0 [120/2] via 10.0.0.1, 00:00:15, FastEthernet0/1
查看路由协议配置
RouterA# show ip protocol
Routing Protocol is "rip"
Sending updates every 30 seconds, next due in 25 seconds
Invalid after 180 seconds, hold down 180, flushed after 240
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version 1, receive any version
Interface Send Recv Triggered RIP Key-chain
FastEthernet0/0 1 1 2
FastEthernet0/1 1 1 2
Automatic network summarization is in effect
Maximum path: 4
Routing for Networks:
10.0.0.0
192.168.1.0
Routing Information Sources:
Gateway Distance Last Update
10.0.0.1 120 00:00:20
Distance: (default is 120)
打开RIP协议调试命令
RouterA# debug ip rip
RIP: sending v1 update to 255.255.255.255 via FastEthernet0/0 (192.168.1.1)
RIP: sending v1 update to 255.255.255.255 via FastEthernet0/1 (10.0.0.2)
RIP: received v1 update from 10.0.0.1 on FastEthernet0/1
20.0.0.0 in 1 hops
192.168.2.0 in 2 hops
RIP: build update entries
network 10.0.0.0 metric 1
network 192.168.2.0 metric 3
network 2.0.0.0 metric 2
RIP v2配置
v 配置RIP协议使用版本2
Router(config)# router rip
Router(config-router)# version 2
Router(config-router)# no auto-summary
查看路由协议配置
RouterA# show ip protocol
Routing Protocol is "rip"
Sending updates every 30 seconds, next due in 16 seconds
Invalid after 180 seconds, hold down 180, flushed after 240
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version 2, receive version 2
Interface Send Recv Triggered RIP Key-chain
FastEthernet0/0 2 2
FastEthernet0/1 2 2
Automatic network summarization is in effect
Maximum path: 4
Routing for Networks:
10.0.0.0
192.168.1.0
Routing Information Sources:
Gateway Distance Last Update
10.0.0.1 120 00:00:15
Distance: (default is 120)
打开RIP协议调试命令
RouterA# debug ip rip
RIP: received v2 update from 10.0.0.1 on FastEthernet0/1
20.0.0.0/8 via 0.0.0.0 in 1 hops
192.168.2.0/24 via 0.0.0.0 in 2 hops
RIP: sending v2 update to 224.0.0.9 via FastEthernet0/0 (192.168.1.1)
RIP: sending v2 update to 224.0.0.9 via FastEthernet0/1 (10.0.0.2)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9650775/viewspace-923200/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9650775/viewspace-923200/
本文详细介绍三层交换机上的路由接口配置、静态路由与默认路由的设置方法,并演示了如何在路由器上配置不同类型的路由,包括RIP v1/v2等动态路由协议的配置实例。
4874

被折叠的 条评论
为什么被折叠?



