网络技术 百文网手机站

路由交换命令

时间:2022-12-14 16:01:27 网络技术 我要投稿

路由交换命令大全

  路由器相信大家都很熟悉,我们日常在家上网就需要用到它,下面是小编给大家整理的关于路由交换命令,欢迎阅读!

  路由交换命令 1

  「基础配置」

  进入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 0.0.0.0 0.0.0.0 {出接口|下一跳ip}浮动静态路由(备份链路,在原链路失效后起作用)

  (config)#ip route 0.0.0.0 0.0.0.0 出接口 AD管理距离静态黑洞路由(config)#ip route 192.168.0.0 255.255.0.0 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<反掩码> area n重启OSPF进程#clear ip ospf process查看接口的OSPF信息#show ip ospf interface查看邻居表#show ip ospf neighbor查看链路数据表#show ip ospf database <?>

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

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

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

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

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

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

  「访问控制列表ACL」

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

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

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

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

  (config)#ip access-list extended OUTB(config-ext-nacl)#permit tcp any any reflect RACL(config)#ip access-list extended INB(config-ext-nacl)#evaluate RACL(config-ext-nacl)#deny ip any any应用到指定ACL到某个接口(config-if)#ip access-group OUTB out(config-if)#ip access-group INB in

  基于时间的ACL设置时区时间(config)#clock timezone GMT +8 #clock set hh:mm:ss <日> <月> <年>定义时间(config)#time-range <时间名>(config-time-range)#periodic <?> hh:mm to hh:mm(config-time-range)#absolute start hh:mm:ss <日> <月> <年> end hh:mm:ss <日> <月> <年>结合ACL(config)#ip access-list extended <扩展acl名字>(config-ext-nacl)#deny tcp any any time-range <时间名>

  「NAT和PAT」

  定义内外网接口(config)#int 接口(config-if)#ip nat {inside|outside}静态NAT(config)#ip nat inside source static ip地址 <?>静态PAT(config)#ip nat inside source static <协议> ip地址 <端口号> <?>

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

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

  查看转换项#show ip nat translations

  「广域网PPP协议」

  在串行口上的两台路由器都封装ppp协议(config)#int sx/x(config-if)#encapsulation ppp(config-if)#no shut

  启用PAP认证,未加密认证方(config)#username <用户名> password <密码>(config-if)#ppp authentication pap请求认证方(config-if)#ppp pap sent-username <用户名> password <密码>

  启用CHAP认证,安全加密认证方(config)#username <请求认证方名> password <请求认证方密码>(config-if)#ppp authentication chap请求认证方(config)#username <认证方名> password <认证方密码>(config-if)#ppp authentication chap

  「帧中继」

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

  配置帧中继交换机关闭路由器路由功能(config)#no ip routing启用帧中继(config)#frame-relay switching进入串行接口R8(config)#int sx/x封装frame-relay协议R8(config-if)#encapsulation frame-relay指定lmi-type类型(config-if)#frame-relay lmi-type cisco指定intf-type接口类型为DCE(config-if)#frame-relay intf-type dce配置时钟频率(config-if)#clock rate n配置DLCI(config-if)#frame-relay route <进dlci号> int <出接口> <出dlci号>

  配置路由器,封装frame-relay协议(config-if)#encapsulation frame-relay静态指定映射(config-if)#frame-relay map ip

  清除动态学到的.Frame Relay #clear frame-relay-inarp查看映射#show frame-relay map调试#debug frame-relay lmi

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

  适用于全互联和部分互联(config)#int sx/x(config-if)#encapsulation frame-relay(config)#int sx/x.x multipoint关闭反向arp,禁止自学习DLCI号和IP对应,而采取静态Map(config-subif)#no frame-relay inverse-arp静态映射DLCI号和IP(config-subif)#frame-relay map ip

  broadcast如在R1上对R3 DLCI号103 IP地址192.168.1.3

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

  子接口可以看作是专线,适用于星型(config)#int sx/x(config-if)#encapsulation frame-relay(config)#int sx/x.x point-to-point(config-subif)#frame-relay interface-dlci

  路由交换命令 2

  《1》配置设备

  交换机、路由器、防火墙、服务器

  1、协议功能

  2、协议原理(工作过程)

  3、协议配置

  4、协议报文分析

  《2》ensp安装

  寻找数通学习文档:support.huawei.com

  交流群:华为企业互动社区。

  软件安装视频:

  https://www.bilibili.com/video/BV1gV411Z7ke

  安装之前需要把防火墙以及杀毒软件关掉。

  安装ensp:第60分钟左右,安装管理员运行,

  Virtualbox安装:45分钟开始。

  注意:需要在vbox把全局工具网卡更改以及dhcp关掉。安装完成ensp后进入vbox当中选择AR-box-》设置-》系统

  如果是灰色进入bios开启虚拟功能

  《3》ensp常见cLl配置

  进入命令行接口 CLI (Command LineInterface) 。

  1、帮助命令

  任意命令视图下,输入"? "获取该命令视图下所有的命令及其简单描述。

  快捷键:当用户输入不完整的关键字后按下键,系统自动执行部分帮助,将命令补全,按两下tab可显示下个命令。

  下光标键<↑>、<↓>表示显示历史命令;

  2、使用用户视图检查基本参数

  用户视图下只能使用参观和监控级命令,如使用 display version 命令显示系统软件版

  本及硬件等信息

  display version

  3、视图间的切换(两种模式:用户模式,系统模式(进行配置相关协议))

  <Huawei>system-view进入系统模式

  [Huawei]quit退出系统模式:quit、Ctrl+z

  4、接口配置

  使用 display 查看路由器基本信息

  [Huawei]display interface GigabitEthernet 0/0/0 显示接口信息

  [Huawei]interface GigabitEthernet 0/0/0 interfaceGigabitEthernet 进入千兆以太网接口

  [Huawei]shutdown 关闭接口

  [Huawei]undo shutdown 激活接口

  [Huawei-g0/0/0] ip add 192.168.1.1 24 配置ip地址192.168.1.1 子网掩码/24

  在华为当中在命令前面加上undo是对命令行的撤销

  [Huawei]display current-configuration 查看路由器当前配置 current:现在的 configuration:配置

  [Huawei]display ip interface brief 显示IP接口简述

  [Huawei]display ip routing-table 显示ip路由表

  [Huawei]display this 显示当前配置

  5、用户界面配置

  [Huawei]sysname R1 修改路由器名

  [R1]undo info-center enable 关闭改名后发送推送消息

  [Huawei]user-interface console 0 由系统视图进入到控制台视图

  [Huawei]idel-timeout 0 0 设置超时时间 ;0 0 为永不超时

  [Huawei]screen-length 屏幕显示行数

  [Huawei]history-command max-size 设置命令显示长度

【路由交换命令】相关文章:

路由器和交换机的基本命令11-28

Cisco交换机命令大全10-03

思科交换机配置命令大全09-24

华为交换机配置命令详解10-03

路由器route add命令详解01-20

交换机与路由器的区别08-06

cisco路由器常用命令10-07

二层交换机基本配置命令09-25

路由器和交换机的区别03-24