博客
关于我
cisco思科交换机-常用命令及配置
阅读量:209 次
发布时间:2019-02-28

本文共 8423 字,大约阅读时间需要 28 分钟。

CISCO路由器和交换机配置指南

1. 基本配置

1.1 进入设备特权模式

Router> enable

1.2 进入全局配置模式

Router# configure terminal

1.3 设置设备名称

Router(config)# hostname RouterName

1.4 设置特权口令(可选加密)

Router(config)# enable secret PasswordRouter(config)# enable password Password

1.5 禁止域名解析

Router(config)# no ip domain lookup

1.6 设置Telnet口令

Router(config)# line vty 0 4Router(config-line)# password PasswordRouter(config-line)# login

1.7 设置控制口密码

Router(config)# line console 0Router(config-line)# password PasswordRouter(config-line)# login

2. 接口配置

2.1 添加IP地址

Router(config-if)# ip address 192.168.1.1 255.255.255.0

2.2 启用接口

Router(config-if)# no shutdown

2.3 设置环回口IP

Router(config-if)# ip address 172.16.1.1 255.255.255.0

3. 路由配置

3.1 静态路由

Router(config)# ip route 192.168.2.0 255.255.255.0 s0

3.2 动态路由(RIP)

Router(config)# router ripRouter(config-router)# network 192.168.1.0Router(config-router)# version 2Router(config-router)# noauto-summary

3.3 EIGRP配置

Router(config)# router eigrp 123Router(config-router)# network 192.168.1.0Router(config-router)# variance 1

3.4 OSPF配置

Router(config)# router ospf 123Router(config-router)# network 192.168.1.0 0.0.0.0 area 0

4. 保存配置

4.1 写入NVRAM

Router# write

4.2 复制运行配置到NVRAM

Router# copy running-config startup-config

5. 常用命令

5.1 查看路由表

Router# show ip route

5.2 查看动态路由协议状态

Router# show ip protocolRouter# show running-config

5.3 查看接口状态

Router# show ip int briefRouter# show interfaces

5.4 查看系统信息

Router# show versionRouter# show processes

6. 交换机配置示例

6.1 创建VLAN

Switch(config)# vlan databaseSwitch(vlan)# vlan 10 name VLAN10Switch(vlan)# exit

6.2 将端口划分到VLAN

Switch(config)# interface range fastethernet 0/1-24Switch(config-if-range)# switchport mode accessSwitch(config-if-range)# switchport access vlan 10

6.3 设置中继端口

Switch(config-if)# switchport mode trunkSwitch(config-if)# switchport trunk encapsulation dot1q

6.4 查看VLAN信息

Switch# show vlan brief

7. VLANIP配置

Switch(config-if)# ip address 192.168.1.1 255.255.255.0

8. VTP配置

8.1 设置VTP域名

Switch(config)# vtp domain DomainName

8.2 设置VTP密码

Switch(config)# vtp password Password

8.3 设置VTP模式

Switch(config)# vtp mode server/client

9. STP生成树配置

9.1 启用生成树

Switch(config)# spanning-tree vlan 10

9.2 设置根优先级

Switch(config-if)# spanning-tree vlan 10 priority 4096

9.3 设置端口成本

Switch(config-if)# spanning-tree vlan 10 cost 10

10. 交换机密码恢复

10.1 重启设备

Switch# reload

10.2 进入恢复模式

Switch: flash_initSwitch: rename flash:config.text flash:config.oldSwitch: boot

10.3 设置新密码

Switch(config)# enable secret NewPassword

11. SSH远程登录配置

11.1 设置SSH版本

Switch(config)# crypto key generate rsa modulus 1024Switch(config)# ssh 0 0 inside

11.2 配置VTY密码

Switch(config)# line vty 0 4Switch(config-line)# password PasswordSwitch(config-line)# loginSwitch(config-line)# transport input ssh

12. 交换机热备配置

12.1 设置热备组

Switch(config)# standby 1 ip 192.168.1.254Switch(config)# standby 1 priority 200Switch(config)# standby 1 track GigabitEthernet0/1 decrement 10

13. ACL配置

13.1 创建标准ACL

Switch(config)# ip access-list 1 permit 192.168.1.0 0.0.0.255

13.2 应用ACL到接口

Switch(config-if)# ip access-group 1 in/out

14. NAT配置

14.1 静态NAT映射

Switch(config)# ip nat inside source static 192.168.1.100 200.0.0.1

14.2 动态NAT

Switch(config)# ip nat inside source dynamic

15. 防火墙配置

15.1 设置默认网关

Router(config)# ip default-gateway 192.168.1.254

15.2 启用NAT

Router# nat controlRouter(config)# ip nat inside source static 192.168.1.100 200.0.0.1

16. 路由器密码恢复

16.1 进入ROM模式

Ctrl + Break

16.2 设置恢复密码

Router# confreg 0x2142Router# reset

17. 交换机安全访问

17.1 设置访问列表

Switch(config)# access-list 1 permit 192.168.2.5Switch(config)# line vty 0 4Switch(config-line)# access-class 1 in

18. 交换机SNMP配置

18.1 设置SNMP社区

Switch(config)# snmp-server community public roSwitch(config)# snmp-server community private rw

18.2 启用SNMP陷阱

Switch(config)# snmp-server enable traps

19. 交换机冗余配置

19.1 设置HSRP

Switch(config)# int vlan 20Switch(config-if)# ip address 172.29.197.33 255.255.255.248Switch(config-if)# standby 20 ip 172.29.197.53Switch(config-if)# standby 20 priority 105Switch(config-if)# standby 20 track GigabitEthernet0/25 decrement 10

20. 交换机端口镜像

20.1 配置镜像源端口

Switch(config)# monitor session 1 source interface GigabitEthernet0/2 - 5 rx

20.2 配置镜像目的端口

Switch(config)# monitor session 1 destination interface GigabitEthernet0/6

21. 交换机板卡和环境查看

21.1 查看板卡信息

Switch# show moduleSwitch# show diagbus

21.2 查看温度和风扇状态

Switch# show environment temperatureSwitch# show environment fans

22. 路由器日志查看

22.1 查看日志信息

Router# show loggingRouter# clear log

23. 交换机VLAN创建与管理

23.1 创建VLAN

Switch(vlan)# vlan 20 name VLAN20Switch(vlan)# exit

23.2 将端口分配到VLAN

Switch(config)# interface fastethernet 0/1Switch(config-if)# switchport mode accessSwitch(config-if)# switchport access vlan 20

24. 交换机生成树配置

24.1 启用生成树

Switch(config)# spanning-tree vlan 10

24.2 设置根优先级

Switch(config-if)# spanning-tree vlan 10 priority 4096

24.3 设置端口成本

Switch(config-if)# spanning-tree vlan 10 cost 10

25. 交换机链路聚合

25.1 配置链路聚合

Switch(config)# int range fastethernet 0/1 - 24Switch(config-if-range)# switchport aggregate-group 1

26. 交换机时间设置

26.1 设置时区

Switch(config)# clock timezone Asia/Shanghai

26.2 设置时间

Switch(config)# clock set 12:00:00 12 October 2023

27. 交换机防火墙配置

27.1 启用防火墙

Switch# firewall

27.2 设置安全级别

Switch(config)# security-level 50

28. 交换机IP地址配置

28.1 设置IP地址

Switch(config-if)# ip address 192.168.1.1 255.255.255.0

28.2 设置默认网关

Switch(config)# ip default-gateway 192.168.1.254

29. 交换机端口操作

29.1 设置端口描述

Switch(config-if)# description Port1连接到设备A

29.2 启用端口

Switch(config-if)# no shutdown

30. 交换机VLAN中继配置

30.1 中继VLAN

Switch(config-if)# switchport trunk encapsulation dot1q

30.2 设置中继VLAN列表

Switch(config-if)# switchport trunk allow vlan 1,2,3

31. 交换机冗余和热备

31.1 设置HSRP

Switch(config)# standby 1 ip 192.168.1.254Switch(config)# standby 1 priority 105

32. 交换机日志同步

32.1 启用日志同步

Switch(config-line)# logging synchronous

33. 交换机端口统计信息

33.1 查看端口统计

Switch# show int fastethernet 0/1

34. 交换机VLAN信息查看

34.1 查看VLAN列表

Switch# show vlan brief

35. 交换机路由查看

35.1 查看路由信息

Switch# show ip route

36. 交换机ACL配置

36.1 创建标准ACL

Switch(config)# ip access-list 1 permit 192.168.1.0 0.0.0.255

36.2 应用ACL到接口

Switch(config-if)# ip access-group 1 in/out

37. 交换机扩展ACL

37.1 创建扩展ACL

Switch(config)# ip access-list extended 1 permit ip 192.168.1.0 0.0.0.255 host 192.168.1.100 eq 80

38. 交换机NAT配置

38.1 静态NAT映射

Switch(config)# ip nat inside source static 192.168.1.100 200.0.0.1

38.2 动态NAT

Switch(config)# ip nat inside source dynamic

39. 交换机会话状态查看

39.1 查看会话状态

Switch# show sessions

40. 交换机板卡和模块查看

40.1 查看板卡信息

Switch# show module

40.2 查看板卡温度

Switch# show environment temperature

41. 交换机安全访问控制

41.1 设置访问列表

Switch(config)# access-list 1 permit 192.168.2.5Switch(config)# line vty 0 4Switch(config-line)# access-class 1 in

42. 交换机SNMP配置

42.1 配置SNMP社区

Switch(config)# snmp-server community public roSwitch(config)# snmp-server community private rw

42.2 启用SNMP陷阱

Switch(config)# snmp-server enable traps

43. 交换机生成树保护

43.1 启用BPDU保护

Switch(config)# spanning-tree bpduprotect

43.2 启用RootGuard

Switch(config)# spanning-tree rootguard

44. 交换机三层交换配置

44.1 设置默认网关

Switch(config)# ip default-gateway 192.168.1.254

44.2 启用IP路由

Switch(config)# ip routing

45. 交换机VLAN到接口映射

45.1 查看VLAN映射

Switch# show vlan-switchport

46. 交换机端口双工和速率配置

46.1 设置双工模式

Switch(config-if)# duplex full

46.2 设置速率

Switch(config-if)# speed 1000

47. 交换机热备命令

47.1 查看热备状态

Switch# show standby

47.2 查看热备拓扑

Switch# show standby brief

48. 交换机端口流量控制

48.1 设置端口限制

Switch(config-if)# port-security 0 100 max-security 100

49. 交换机防火墙扩展ACL

49.1 创建扩展ACL

Switch(config)# ip access-list extended 1 permit ip 192.168.1.0 0.0.0.255 host 192.168.1.100 eq 80

50. 交换机端口访问控制

50.1 设置端口访问控制

Switch(config-if)# switchport access vlan 10

51. 交换机VLAN中继允许指定VLAN

51.1 中继允许VLAN列表

Switch(config-if)# switchport trunk allow vlan {1,2,3}

52. 交换机VLAN封装类型

52.1 设置封装类型

Switch(config-if)# switchport trunk encapsulation dot1q

53. 交换机VLAN划分

53.1 划分端口

Switch(config-if-range)# switchport access vlan 10

54. 交换机VLAN管理

54.1 创建VLAN

Switch(vlan)# vlan 20 name VLAN20Switch(vlan)# exit

55. 交换机模块管理

55.1 查看模块信息

Switch# show module

55.2 重启模块

Switch# module 1 reload

56. 交换机环境监控

56.1 查看环境信息

Switch# show environment

56.2 查看温度和风扇状态

Switch# show environment temperatureSwitch# show environment fans

57. 交换机日志管理

57.1 查看日志

Switch# show logging

57.2 清除日志

Switch# clear log

58. 交换机会话管理

58.1 查看会话状态

Switch# show sessions

58.2 关闭会话

Switch# session 1 close

59. 交换机安全设置

59.1 设置登录超时

Switch(config-line)# exec-timeout 0 0

59.2 禁止非管理员登录

Switch(config)# enable secret cisco

60. 交换机网络统计信息

60.1 查看网络统计

Switch# show netstat

60.2 查看接口统计

Switch# show int brief

转载地址:http://sgti.baihongyu.com/

你可能感兴趣的文章
Objective-C实现scoring评分算法(附完整源码)
查看>>
Objective-C实现searching in sorted matrix在排序矩阵中搜索算法(附完整源码)
查看>>
Objective-C实现Secant method割线法算法(附完整源码)
查看>>
Objective-C实现segment tree段树算法(附完整源码)
查看>>
Objective-C实现segmented sieve分段筛算法(附完整源码)
查看>>
Objective-C实现selection sort选择排序算法(附完整源码)
查看>>
Objective-C实现sha1算法(附完整源码)
查看>>
Objective-C实现sha256算法(附完整源码)
查看>>
Objective-C实现shell sort希尔排序算法(附完整源码)
查看>>
Objective-C实现sherman morrison公式算法(附完整源码)
查看>>
Objective-C实现ShorAlgorithm肖尔算法 (附完整源码)
查看>>
Objective-C实现shortest job first短作业优先算法(附完整源码)
查看>>
Objective-C实现shortestCommonSupersequence最短公共超序列算法(附完整源码)
查看>>
Objective-C实现sierpinski triangle谢尔宾斯基三角形算法(附完整源码)
查看>>
Objective-C实现sieve of Eratosthenes埃拉托色尼筛法算法(附完整源码)
查看>>
Objective-C实现SieveOfEratosthenes埃拉托色尼筛法打印所有素数算法(附完整源码)
查看>>
Objective-C实现sieveOfEratosthenes埃拉托色尼筛法求素数算法 (附完整源码)
查看>>
Objective-C实现sieveOfEratosthenes埃拉托色尼筛选法算法(附完整源码)
查看>>
Objective-C实现sigmoid函数功能(附完整源码)
查看>>
Objective-C实现Sigmoid函数算法(附完整源码)
查看>>