思科路由器接口
接口配置是最重要的路由器配置之一,因为若没有接口,路由器几乎就毫无用处。另外,要与其
他设备通信,接口配置必须绝对精确。
配置接口时,我们需要指定网络层地址、介质类型和带宽,还需使用其他管理命令。
不同路由器在选择要配置的接口时有不同的方法。例如,下面的命令表明,路由器有 10 个串行
接口,编号为 0-9:
Router(config)#int serial ?
<0-9> Serial interface number
#选择要配置的接口后,你就进入了接口配置模式
#对5号串口进行配置
Router(config)#int serial 5
Router(config)-if)
选择内置的快速以太网接口
Todd(config)#int fastEthernet O/?
<0-1> FastEthernet interface number
Todd(config)#int fastEthernet 0/0
Todd(config-if)#
#注意,我们不能只使用命令 int fastethernet 0 ,而必须指定类型和插槽号/端口号
#即使用命令 type slot/port 或 int fastethernet % (或 int fa 0/0)
有些路由器需要使用 3 个编号,而不是2个。第一个 0 表示路由器本身,第二个编号为插槽号,第三个为端口号。
Todd(config-if)#do show run
Building configuration...
[output cut]
interface FastEthernetOjO
no ip address
shutdown
duplex auto
speed auto
interface FastEthernetOjl
no ip address
shutdown
duplex auto
speed auto
interface SerialOjOjO
no ip address
shutdown
no fair-queue
interface SerialOjOjl
no ;p address
shutdown
interface Ser;alOjljO
no ip address
shutdown
;nterface SerialOj2jO
no ;p address
shutdown
clock rate 2000000
[output cut]
启用接口
如果接口被禁用,则在命令 show i nterfaces (简写为 sh i nt) 的输出中,该接口显示为管理性关闭 (down):
Todd#sh int fO/l
FastEthernetO/l is administratively down , line protocol is down
[output cut]
Todd#config t
Todd(config)#int fO/l
Todd(config-if)#no shutdown
Todd(config-if)#
*Feb 28 22:45:08.455: %LINK-3-UPDOWN: Interface FastEthernetO/l ,
changed state to up
Todd(config-if)#do show int fO/l
FastEthernetO/l is up , line protocol is up
[output cut]
- 给接口配置ip地址
Todd(config)#int fO/l
Todd(config-if)#ip address 172.16.10.2 255.255.255.0
如果要给接口配置第二个地址,我们必须使用参数 secondary。如果配置另一个 IP 地址并按回
车键,它将取代原来的主 IP 地址和子网掩码。
Todd(config-if)#;p address 172.16.20.2 255.255.255.0 ?
secondary Make this IP address a secondary address
Todd(config-if)#ip address 172.16.20.2 255.255.255.0 secondary
Todd(config-if)#^Z
Todd(config-if)#do sh run
Building configuration...
[output cut]
interface FastEthernetOj1
ip address 172.16.20.2 255.255.255.0 secondary
ip address 172.16.10.2 255.255.255.0
duplex auto
speed auto
不建议给接口配置多个 E 地址,因为这种做法糟糕而低效。
- 使用管道
管道( I )让你能够在配置或其他冗长输出中迅速找到目标
Todd#sh run | ?
append Append redirected output to URL (URLs supporting append operation
only)
begin Begin with the line that matches
exclude Exclude lines that match
include lnclude lines that match
redirect Redirect output to URL
section Filter a section of output
tee Copy output to URL
Todd#sh run | begin interface
interface FastEthernetOjO
description Sales VLAN
ip address 10.10.10.1 255.255.255.248
duplex auto
speed auto
interface FastEthernetOj1
ip address 172.16.20.2 255.255.255.0 secondary
ip address 172.16.10.2 255.255.255.0
duplex auto
speed auto
interface SerialO/O/O
description Wan to SF circuit number 6fdda 12345678
no ip address
管道符号(输出限定符)可帮助你快速找到目标。比如确定大型路由选择表里是否包含特定路由。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!