路由交换命令大全

进入console口进行本地配置用户模式 xx>enable n特权模式 xx#configure terminal全局配置模式 xx(config)#interface [f|s] n/m进入接口配置模式xx(config-if)#,下面是由本站小编为大家整理的路由交换命令大全,喜欢的可以收藏一下!了解更多详情资讯,请关注应届毕业生考试网!

路由交换命令大全

  「基础配置」

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

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

(config-if)#clock rate n反向操作(删除配置)

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

路由器关闭路由功能充当主机(config)#no ip routing为路由器设置网关(config)#ip default-gateway ip地址

改机器名字(config)#hostname yy控制线路超时(config)#line n(config-line)#exec-timeout 0 0关闭域名解析功能(config)#no ip domain-lookup开启路由器http功能(config)#ip http server(config)#username xxx password yyy(config)#username xxx secret yyy(config)#enable secret yyy启用密码加密服务(config)#service password-encryption yyy开启路由器https功能(config)#ip http secure-server开启路由器远程登录功能(config)#line vty 0 4(config)#login local或者(config)#no login(config)#enable n登录时使用命令 telnet A.B.C.D

  「交换机」

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

(conifg)#switchport port-security(conifg)#switchport ?

#show port-security int fx/x恢复(config)#errdisable recovery

为交换机vlan1配置管理ip(conifg)#int vlan 1(config-if)#ip addr A.B.C.D 子网掩码(config-if)#no shut

  「交换机vlan」

查看vlan #show vlan-switch或是#show vlan创建vlan #vlan database(vlan)#vlan n将端口加入到vlan中(config-if)#switchport access vlan n给允许多个vlan的接口打trunk(config-if)#switchport mode trunk

  「单臂路由vlan」

路由器上配置子接口实现不同vlan之间通信,先必须激活其父接口,另外IP不允许重复(config)#interface fx/x.x(config-subif)#encapsulation dot1q vlan-id(config-subif)#ip addr A.C.D.E 子网掩码(config-subif)#no shut

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

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

  「VTP」

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

  「端口聚合」

创建R1(config)#interface port-channel 1(config-if)#switchport trunk encapsulation dot1q(config-if)#switchport mode trunk将指定接口加入聚合组内#int range f x/x-x #channel-group 1 mode on查看聚合接口#show etherchannel summary

  「生成树协议

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

(config)#spanning-tree vlan n修改生成树协议优先级(根网桥:mac最小、优先级最小)

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

  「静态路由」

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

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

(config)#ip route 出接口 AD管理距离静态黑洞路由(config)#ip route null 0

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

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

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

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

(config-router)#neighbor ip地址清除路由表内容#clear ip route *

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

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