读文网>电脑>网络知识>路由器>路由器知识大全

路由器和交换机命令大全【精选17篇】

不论是路由器也好,还是交换机也好,终归都是要依靠命令进行设备控制,因此你是否知道全部的命令呢?何不抓紧时间补全自己所缺失的命令,以便更好的进行工作开展。

「帧中继」

无广播的多路访问网络(NBMA)

配置帧中继交换机关闭路由器路由功能(confignoip routing启用帧中继(configframe-relayswitching进入串行接口R8(configintsx/x封装frame-relay协议R8(config-ifencapsulationframe-relay指定lmi-type类型(config-ifframe-relaylmi-type cisco指定intf-type接口类型为DCE(config-ifframe-relayintf-type dce配置时钟频率(config-if)clockrate n配置DLCI(config-ifframe-relayroute <进DLCI号> int <出接口> <出DLCI号>

配置路由器,封装frame-relay协议(config-ifencapsulationframe-relay静态指定映射(config-ifframe-relaymap ip 清除动态学到的Frame Relayclearframe-relay-inarp查看映射showframe-relay map调debugframe-relay lmi

点到多点(解决水平分割问题,划分子接口)

适用于全互联和部分互联(configintsx/x(config-ifencapsulationframe-relay(configintsx/x.x multipoint关闭反向arp,禁止自学习DLCI号和IP对应,而采取静态Map(config-subifnoframe-relay inverse-arp静态映射DLCI号和IP(config-subifframe-relaymap ip broadcast如在R1上对R3 DLCI号103 IP地址192.168.1.3

点到点子接口(不存在水平分割问题)

子接口可以看作是专线,适用于星型(configintsx/x(config-ifencapsulationframe-relay(configintsx/x.x point-to-point(config-subifframe-relayinterface-dlci

以上就是读文网带给大家不一样的精彩。想要了解更多精彩的朋友可以持续关注读文网,我们将会为你奉上最全最新鲜的内容哦! 读文网,因你而精彩。

「端口聚合」

创建R1(configinterfaceport-channel 1(config-ifswitchporttrunk encapsulation dot1q(config-ifswitchportmode trunk将指定接口加入聚合组intrange f x/x-xchannel-group1 mode on查看聚合接口showetherchannel summary

「生成树协议」

基于vlan的生成树可防止环路开启生成树协议(STP默认是开启的,可省略)

(configSPAnning-treevlan n修改生成树协议优先级(根网桥:mac最小、优先级最小)

(configspanning-treevlan n priority m交换机和主机之间连接的端口开启portfast,可防止主机发送BPDU伪造数据(config-ifspanning-treeportfast查看生成树showspanning-tree [vlan n]

「广域网PPP协议」

在串行口上的两台路由器都封装ppp协议(configintsx/x(config-ifencapsulationppp(config-ifnoshut

启用PAP认证,未加密认证方(configusername<用户名> password <密码>(config-ifpppauthentication pap请求认证方(config-ifppppap sent-username <用户名> password <密码>

启用CHAP认证,安全加密认证方(configusername<请求认证方名> password <请求认证方密码>(config-ifpppauthentication chap请求认证方(configusername<认证方名> password <认证方密码>(config-ifpppauthentication chap

「交换机vlan」

查看vlanshowvlan-switch或是showvlan创建vlanvlandatabase(vlan)vlann将端口加入到vlan中(config-ifswitchportaccess vlan n给允许多个vlan的接口打trunk(config-ifswitchportmode trunk

「使用三层交换机交换虚拟接口」

交换机上配置虚拟交换接口实现不同vlan之间通信,先必须在交换机上添加对应vlan(configintvlan n(config-ifipaddr A.B.C.D 子网掩码(config-ifnoshut在删除时,务必先删除交换虚拟接口,再删对应vlan

「VTP」

配置VTP模式vlandatabase(vlanvtp{server|client|transparent}只有域名和密码完全一样的路由器之间才能同步vlan信息(vlanvtpdomain <域名>(vlanvtppassword <密码>打开VTP裁剪(vlanvtppruning退出激活(vlan)#exit

「静态路由」

查看协议showip protocols查看路由表showip route添加静态路由(以默认路由举例)

(configiproute 0.0.0.0 0.0.0.0 {出接口|下一跳ip}浮动静态路由(备份链路,在原链路失效后起作用)

(configiproute 0.0.0.0 0.0.0.0 出接口 AD管理距离静态黑洞路由(configiproute 192.168.0.0 255.255.0.0 null 0

「EIGRP链路状态路由,动态路由」

配置EIGRP宣告直连网路(config)routereigrp <系统编号>(config-router)network查看邻居表showip eigrp neighbors查看拓扑表showip eigrp topology

「访问控制列表ACL」

ACL无法控制自身发起的流量,对于已经建立的流量不起作用标准ACL(不能单独删除、添加一条访问列表)

(configaccess-list<1~99|1300~1999> {permit|deny} ip地址 反掩码扩展ACL(configaccess-list<100-199> {permit|deny} <协议> <源ip> <反掩码> <源端口> <目标ip> <反掩码> <目标端口>应用到指定ACL到某个接口(configint接口(config-ifipaccess-group <1~99|100-199|1300~1999> {in|out}

命名ACL(configipaccess-list standard <标准ACL名字>(config-std-nacl{permit|deny}ip地址 反掩码(configipaccess-list extended <扩展ACL名字>(config-ext-nacl{permit|deny}<协议> <源ip> <反掩码> <源端口> <目标ip> <反掩码> <目标端口>应用到指定ACL到某个接口(configint接口(config-ifipaccess-group <标准ACL名字|扩展ACL名字> {in|out}

自反ACL(RACL,可以只允许内网主动发起的流量通过)

(configipaccess-list extended OUTB(config-ext-nacl)permittcp any any reflect RACL(configipaccess-list extended INB(config-ext-nacl)evaluateRACL(config-ext-nacldenyip any any应用到指定ACL到某个接口(config-ifipaccess-group OUTB out(config-ifipaccess-group INB in

基于时间的ACL设置时区时间(config)clocktimezone GMT +8clockset hh:mm:ss <日> <月> <年>定义时间(configtime-range<时间名>(config-time-rangeperiodichh:mm to hh:mm(config-time-range)absolutestart hh:mm:ss <日> <月> <年> end hh:mm:ss <日> <月> <年>结合ACL(configipaccess-list extended <扩展ACL名字>(config-ext-nacldenytcp any any time-range <时间名>

「VRRP虚拟路由器路由协议」

提供网关冗余查看VRRP信息showvrrp VRRP配置(在提供备份的两台路由器上做以下配置)

端口跟踪(监视某个接口的状态)

(config)track1 interface 接口 line-protocol(config-ifvrrp<1~254> ip 额外配置优先级(IP和优先级越大Master)和抢占(config-ifvrrp<1~254> priority <1~254>(config-ifvrrp<1~254> preempt(config-ifvrrp1 track 1 decrement <1~255>

「RIP距离矢量路由,动态路由」

配置RIP宣告直连网段(config)routerrip(config-router)network网段更改为版本2(config-router)version{2|1}关闭自动汇总(如果被其他网路隔开时,最好关闭自动汇总)

(config-routernoauto-summary设置被动接口(只接受更新,不宣告自己)

(config-routerpassive-interface接口单播更新(只和指定的ip交换路由信息)

(config-router)neighborip地址清除路由表内容clearip route *

「基础配置」

进入console口进行本地配置用户模式 xx>enable n特权模式 xconfigureterminal全局配置模式 xx(configinterface[f|s] n/m进入接口配置模式xx(config-if)#

进入(子)接口模式后配置IP(config-ifipaddr A.B.C.D 子网掩码激活接口(config-ifnoshutdown配置速度(config-if)speed{auto|10|100}配置接口工作模式(config-ifduplex{auto|half|full}配置时钟(串行口DCE端)

(config-if)clockrate n反向操作(删除配置)

no + 命令在换回接口上配多个ip(config-ifipaddr A.B.C.D 子网掩码(config-ifipaddr A.B.C.D 子网掩码 secondary查看所有配置showrunning-config

路由器关闭路由功能充当主机(confignoip routing为路由器设置网关(configipdefault-gateway ip地址

改机器名字(confighostnameyy控制线路超时(config)linen(config-lineexec-timeout0 0关闭域名解析功能(confignoip domain-lookup开启路由器http功能(configiphttp server(configusernamexxx password yyy(configusernamexxx secret yyy(config)enablesecret yyy启用密码加密服务(config)servicepassword-encryption yyy开启路由器https功能(configiphttp secure-server开启路由器远程登录功能(config)linevty 0 4(configloginlocal或者(confignologin(config)enablen登录时使用命令 telnet A.B.C.D

「交换机」

查看mac地址表showmac-address-table绑定静态mac地址(configmac-address-tablestatic H.H.H vlan n interface fx/xshowarp在主机上使用arp -a查看arp信息开启交换机端口安全(防止连接主机恶意发送随机mac填满mac地址表)

(conifgswitchportport-security(conifgswitchport?

showport-security int fx/x恢复(configerrdisablerecovery

为交换机vlan1配置管理ip(conifgintvlan 1(config-ifipaddr A.B.C.D 子网掩码(config-ifnoshut

「单臂路由vlan」

路由器上配置子接口实现不同vlan之间通信,先必须激活其父接口,另外IP不允许重复(configinterfacefx/x.x(config-subifencapsulationdot1q vlan-id(config-subifipaddr A.C.D.E 子网掩码(config-subifnoshut

「NAT和PAT」

定义内外网接口(configint接口(config-ifipnat {inside|outside}静态NAT(configipnat inside source static ip地址 静态PAT(configipnat inside source static <协议> ip地址 <端口号>

使用ACL捕获流量(configaccess-listn permit ip地址 反掩码(configipnat pool <地址池名> <起始ip地址> <终止ip地址> netmask 掩码TCP负载均衡(轮询转换)

(configipnat pool <地址池名> <起始ip地址> <终止ip地址> netmask 掩码 type rotary动态NAT(configipnat inside source list n pool <地址池名>动态PAT(configipnat inside source list n pool <地址池名> overload

查看转换项showip nat translations

「OSPF链路状态路由,动态路由」

配置OSPF宣告直连网路(config)routerospf <进程号>(config-routerrouter-id<任意ip地址>(config-router)network<反掩码> area n重启OSPF进程clearip ospf process查看接口的OSPF信息showip ospf interface查看邻居表showip ospf neighbor查看链路数据表showip ospf database

相关热搜

相关文章

【路由器知识大全】热点

【路由器知识大全】最新