前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >收藏! 思科交换机路由器配置命令大全

收藏! 思科交换机路由器配置命令大全

作者头像
网络工程师笔记
发布2022-10-31 11:29:33
1.5K0
发布2022-10-31 11:29:33
举报

有部分朋友问到关于思科路由器交换机的配置,本期我们一起来了解下。

交换机基本状态:

switch:;ROM状态,路由器是rommon> hostname>;用户模式 hostname#;特权模式 hostname(config)#;全局配置模式 hostname(config-if)#;接口状态

交换机设置命令口令设置: switch>enable;进入特权模式 switch#configterminal;进入全局配置模式 switch(config)#hostname;设置交换机的主机名 switch(config)#enablesecretxxx;设置特权加密口令 switch(config)#enablepasswordxxa;设置特权非密口令 switch(config)#lineconsole0;进入控制台口 switch(config-line)#linevty04;进入虚拟终端 switch(config-line)#login;允许登录 switch(config-line)#passwordxx;设置登录口令xx switch#exit;返回命令

交换机设置命令VLAN设置: switch#vlandatabase;进入VLAN设置 switch(vlan)#vlan2;建VLAN2 switch(vlan)#novlan2;删vlan2 switch(config)#intf0/1;进入端口1 switch(config-if)#switchportaccessvlan2;当前端口加入vlan2 switch(config-if)#switchportmodetrunk;设置为干线 switch(config-if)#switchporttrunkallowedvlan1,2;设置允许的vlan switch(config-if)#switchporttrunkencapdot1q;设置vlan中继 switch(config)#vtpdomain;设置发vtp域名 switch(config)#vtppassword;设置发vtp密码 switch(config)#vtpmodeserver;设置发vtp模式 switch(config)#vtpmodeclient;设置发vtp模式

交换机设置命令设置IP地址: switch(config)#interfacevlan1;进入vlan1 switch(config-if)#ipaddress;设置IP地址 switch(config)#ipdefault-gateway;设置默认网关 switch#dirflash:;查看闪存

交换机设置命令显示命令: switch#write;保存配置信息 switch#showvtp;查看vtp配置信息 switch#showrun;查看当前配置信息 switch#showvlan;查看vlan配置信息 switch#showinterface;查看端口信息 switch#showintf0/0;查看指定端口信息

路由器显示命令:

router#show run;显示配置信息

router#show interface;显示接口信息

router#show ip route ;显示路由信息

router#show cdp nei;显示邻居信息

router#reload;重新起动

路由器口令设置:

router〉enable;进入特权模式

router#config terminal;进入全局配置模式

router(config)#hostname 〈hostname〉;设置交换机的主机名

router(config)#line console 0;进入控制台口

router(config-line)#line vty 0 4;进入虚拟终端

router(config-line)#login;要求口令验证

router(config-line)#password xx ;设置登录口令 xx

router(config)#(Ctrl+z) ; 返回特权模式

router#exit ;返回命令

路由器配置:

router(config)#int s0/0 ;进入 Serail 接口

router(config-if)#no shutdown ;激活当前接口

router(config-if)#clock rate 64000 ;设置同步时钟

router(config-if)#ip address 〈ip〉 〈netmask〉;设置 IP 地址

router(config-if)#int f0/0.1 ;进入子接口

router(config-subif.1)#ip address 〈ip〉〈netmask〉 ;设置子接口 IP

router(config-subif.1)#encapsulation dot1q 〈n〉 ;绑定 vlan 中继协议

router(config)#config-register 0x2142 ;跳过配置文件

router(config)#config-register 0x2102 ;正常使用配置文件

router#reload ;重新引导

静态路由:

ip route 〈ip-address〉 〈subnet-mask〉 〈gateway〉 ;命令格式

router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;静态路由举例

router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;默认路由举例

动态路由:

router(config)#ip routing ;启动路由转发

router(config)#router rip ;启动 RIP 路由协议。

router(config-router)#network 〈netid〉 ;设置发布路由

router(config-router)#negihbor 〈ip〉 ;点对点帧中继用。

基本访问控制列表:

router(config)#access-list 〈number〉 permit|deny 〈source ip〉 〈wild|any〉

router(config)#interface 〈interface〉 ;default:deny any

router(config-if)#ip access-group 〈number〉 in|out ;default:out

例 1:router(config)#access-list 4 permit 10.8.1.1

router(config)#access-list 4 deny 10.8.1.0 0.0.0.255

router(config)#access-list 4 permit 10.8.0.0 0.0.255.255

router(config)#access-list 4 deny 10.0.0.0 0.255.255.255

router(config)#access-list 4 permit any

router(config)#int f0/0

router(config-if)#ip access-group 4 in

删除访问控制例表:

router(config)#no access-list 102 router(config-if)#no ip access-group 101 in

外部网关协议配置:

routerA(config)#router bgp 100

routerA(config-router)#network 19.0.0.0

routerA(config-router)#neighbor 8.1.1.2 remote-as 200

配置 PPP 验证:

RouterA(config)#username 〈RouterB〉 password 〈word〉

RouterA(config)#int s0 RouterA(config-if)#ppp authentication {chap|pap}

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-08-09,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 网络工程师笔记 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档