switch命令大全
--------------------------------------------------------------------------------
1.switch(config)# hostname hostname
在基于CLI的交换机上设置主机名/系统名:
switch(enable) set system name name-string
2.在基于IOS的交换机上设置登录口令:
switch(config)# enable password level 1 password
在基于CLI的交换机上设置登录口令:
switch(enable) set password
switch(enable) set enalbepass
3.在基于IOS的交换机上设置远程访问:
switch(config)# interface vlan 1
switch(config-if)# ip address ip-address netmask
switch(config-if)# ip default-gateway ip-address
在基于CLI的交换机上设置远程访问:
switch(enable) set interface sc0 ip-address netmask broadcast-address
switch(enable) set interface sc0 vlan
switch(enable) set ip route default gateway
4.在基于IOS的交换机上启用和浏览CDP信息:
switch(config-if)# cdp enable
switch(config-if)# no cdp enable
为了查看Cisco邻接设备的CDP通告信息:
switch# show cdp interface [type modle/port]
switch# show cdp neighbors [type module/port] [detail]
在基于CLI的交换机上启用和浏览CDP信息:
switch(enable) set cdp {enable|disable} module/port
为了查看Cisco邻接设备的CDP通告信息:
switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilities|detail]
5.基于IOS的交换机的端口描述:
switch(config-if)# description description-string
基于CLI的交换机的端口描述:
switch(enable)set port name module/number description-string
6.在基于IOS的交换机上设置端口速度:
switch(config-if)# speed{10|100|auto}
在基于CLI的交换机上设置端口速度:
switch(enable) set port speed moudle/number {10|100|auto}
switch(enable) set port speed moudle/number {4|16|auto}
7.在基于IOS的交换机上设置以太网的链路模式:
switch(config-if)# duplex {auto|full|half}
在基于CLI的交换机上设置以太网的链路模式:
switch(enable) set port duplex module/number {full|half}
8.在基于IOS的交换机上配置静态VLAN:
switch# vlan database
switch(vlan)# vlan vlan-num name vlan
switch(vlan)# exit
switch# configure teriminal
switch(config)# interface interface module/number
switch(config-if)# switchport mode access
switch(config-if)# switchport access vlan vlan-num
switch(config-if)# end
在基于CLI的交换机上配置静态VLAN:
switch(enable) set vlan vlan-num [name name]
switch(enable) set vlan vlan-num mod-num/port-list
9. 在基于IOS的交换机上配置VLAN中继线:
switch(config)# interface interface mod/port
switch(config-if)# switchport mode trunk
switch(config-if)# switchport trunk encapsulation {isl|dotlq}
switch(config-if)# switchport trunk allowed vlan remove vlan-list
switch(config-if)# switchport trunk allowed vlan add vlan-list
在基于CLI的交换机上配置VLAN中继线:
switch(enable) set trunk module/port [on|off|desirable|auto|nonegotiate]
Vlan-range [isl|dotlq|dotl0|lane|negotiate]
10.在基于IOS的交换机上配置VTP管理域:
switch# vlan database
switch(vlan)# vtp domain domain-name
在基于CLI的交换机上配置VTP管理域:
switch(enable) set vtp [domain domain-name]
11.在基于IOS的交换机上配置VTP 模式:
switch# vlan database
switch(vlan)# vtp domain domain-name
switch(vlan)# vtp {sever|cilent|transparent}
switch(vlan)# vtp password password
在基于CLI的交换机上配置VTP 模式:
switch(enable) set vtp [domain domain-name] [mode{ sever|cilent|transparent }][password password]
12. 在基于IOS的交换机上配置VTP版本:
switch# vlan database
switch(vlan)# vtp v2-mode
在基于CLI的交换机上配置VTP版本:
switch(enable) set vtp v2 enable
13. 在基于IOS的交换机上启动VTP剪裁:
switch# vlan database
switch(vlan)# vtp pruning
在基于CL I 的交换机上启动VTP剪裁:
switch(enable) set vtp pruning enable
14.在基于IOS的交换机上配置以太信道:
switch(config-if)# port group group-number [distribution {source|destination}]
在基于CLI的交换机上配置以太信道:
switch(enable) set port channel moudle/port-range mode{on|off|desirable|auto}
15.在基于IOS的交换机上调整根路径成本:
switch(config-if)# spanning-tree [vlan vlan-list] cost cost
在基于CLI的交换机上调整根路径成本:
switch(enable) set spantree portcost moudle/port cost
switch(enable) set spantree portvlancost moudle/port [cost cost][vlan-list]
16.在基于IOS的交换机上调整端口ID:
switch(config-if)# spanning-tree[vlan vlan-list]port-priority port-priority
在基于CLI的交换机上调整端口ID:
switch(enable) set spantree portpri {mldule/port}priority
switch(enable) set spantree portvlanpri {module/port}priority [vlans]
17. 在基于IOS的交换机上修改STP时钟:
switch(config)# spanning-tree [vlan vlan-list] hello-time seconds
switch(config)# spanning-tree [vlan vlan-list] forward-time seconds
` switch(config)# spanning-tree [vlan vlan-list] max-age seconds
在基于CLI的交换机上修改STP时钟:
switch(enable) set spantree hello interval[vlan]
switch(enable) set spantree fwddelay delay [vlan]
switch(enable) set spantree maxage agingtiame[vlan]
18. 在基于IOS的交换机端口上启用或禁用Port Fast 特征:
switch(config-if)#spanning-tree portfast
在基于CLI的交换机端口上启用或禁用Port Fast 特征:
switch(enable) set spantree portfast {module/port}{enable|disable}
19. 在基于IOS的交换机端口上启用或禁用UplinkFast 特征:
switch(config)# spanning-tree uplinkfast [max-update-rate pkts-per-second]
在基于CLI的交换机端口上启用或禁用UplinkFast 特征:
switch(enable) set spantree uplinkfast {enable|disable}[rate update-rate] [all-protocols off|on]
20. 为了将交换机配置成一个集群的命令交换机,首先要给管理接口分配一个IP地址,然后使用下列命令: switch(config)# cluster enable cluster-name
21. 为了从一条中继链路上删除VLAN,可使用下列命令:
switch(enable) clear trunk module/port vlan-range
22. 用show vtp domain 显示管理域的VTP参数.
23. 用show vtp statistics显示管理域的VTP参数.
24. 在Catalyst交换机上定义TrBRF的命令如下:
switch(enable) set vlan vlan-name [name name] type trbrf bridge bridge-num[stp {ieee|ibm}]
25. 在Catalyst交换机上定义TrCRF的命令如下:
switch (enable) set vlan vlan-num [name name] type trcrf
{ring hex-ring-num|decring decimal-ring-num} parent vlan-num
26. 在创建好TrBRF VLAN之后,就可以给它分配交换机端口.对于以太网交换,可以采用如下命令给VLAN分配端口:
switch(enable) set vlan vlan-num mod-num/port-num
27. 命令show spantree显示一个交换机端口的STP状态.
28. 配置一个ELAN的LES和BUS,可以使用下列命令:
ATM (config)# interface atm number.subint multioint
ATM(config-subif)# lane serber-bus ethernet elan-name
29. 配置LECS:
ATM(config)# lane database database-name
ATM(lane-config-databade)# name elan1-name server-atm-address les1-nsap-address
ATM(lane-config-databade)# name elan2-name server-atm-address les2-nsap-address
ATM(lane-config-databade)# name …
30. 创建完数据库后,必须在主接口上启动LECS.命令如下:
ATM(config)# interface atm number
ATM(config-if)# lane config database database-name
ATM(config-if)# lane config auto-config-atm-address
31. 将每个LEC配置到一个不同的ATM子接口上.命令如下:
ATM(config)# interface atm number.subint multipoint
ATM(config)# lane client ethernet vlan-num elan-num
32. 用show lane server 显示LES的状态.
33. 用show lane bus显示bus的状态.
34. 用show lane database显示LECS数据库可内容.
35. 用show lane client显示LEC的状态.
36. 用show module显示已安装的模块列表.
37. 用物理接口建立与VLAN的连接:
router# configure terminal
router(config)# interface media module/port
router(config-if)# description description-string
router(config-if)# ip address ip-addr subnet-mask
router(config-if)# no shutdown
38. 用中继链路来建立与VLAN的连接:
router(config)# interface module/port.subinterface
router(config-ig)# encapsulation[isl|dotlq] vlan-number
router(config-if)# ip address ip-address subnet-mask
39. 用LANE 来建立与VLAN的连接:
router(config)# interface atm module/port
router(config-if)# no ip address
router(config-if)# atm pvc 1 0 5 qsaal
router(config-if)# atm pvc 2 0 16 ilni
router(config-if)# interface atm module/port.subinterface multipoint
router(config-if)# ip address ip-address subnet-mask
router(config-if)# lane client ethernet elan-num
router(config-if)# interface atm module/port.subinterface multipoint
router(config-if)# ip address ip-address subnet-name
router(config-if)# lane client ethernet elan-name
router(config-if)# …
40. 为了在路由处理器上进行动态路由配置,可以用下列IOS命令来进行:
router(config)# ip routing
router(config)# router ip-routing-protocol
router(config-router)# network ip-network-number
router(config-router)# network ip-network-number
41. 配置默认路由:
switch(enable) set ip route default gateway
42. 为一个路由处理器分配VLANID,可在接口模式下使用下列命令:
router(config)# interface interface number
router(config-if)# mls rp vlan-id vlan-id-num
43. 在路由处理器启用MLSP:
router(config)# mls rp ip
44. 为了把一个外置的路由处理器接口和交换机安置在同一个VTP域中:
router(config)# interface interface number
router(config-if)# mls rp vtp-domain domain-name
45. 查看指定的VTP域的信息:
router# show mls rp vtp-domain vtp domain name
46. 要确定RSM或路由器上的管理接口,可以在接口模式下输入下列命令:
router(config-if)#mls rp management-interface
47. 要检验MLS-RP的配置情况:
router# show mls rp
48. 检验特定接口上的MLS配置:
router# show mls rp interface interface number
49. 为了在MLS-SE上设置流掩码而又不想在任一个路由处理器接口上设置访问列表:
set mls flow [destination|destination-source|full]
50. 为使MLS和输入访问列表可以兼容,可以在全局模式下使用下列命令:
router(config)# mls rp ip input-acl
51. 当某个交换机的第3层交换失效时,可在交换机的特权模式下输入下列命令:
switch(enable) set mls enable
52. 若想改变老化时间的值,可在特权模式下输入以下命令:
switch(enable) set mls agingtime agingtime
53. 设置快速老化:
switch(enable) set mls agingtime fast fastagingtime pkt_threshold
54. 确定那些MLS-RP和MLS-SE参与了MLS,可先显示交换机引用列表中的内容再确定:
switch(enable) show mls include
55. 显示MLS高速缓存记录:
switch(enable) show mls entry
56. 用命令show in arp显示ARP高速缓存区的内容。
57. 要把路由器配置为HSRP备份组的成员,可以在接口配置模式下使用下面的命令:
router(config-if)# standby group-number ip ip-address
58. 为了使一个路由器重新恢复转发路由器的角色,在接口配置模式下:
router(config-if)# standy group-number preempt
59. 访问时间和保持时间参数是可配置的:
router(config-if)# standy group-number timers hellotime holdtime
60. 配置HSRP跟踪:
router(config-if)# standy group-number track type-number interface-priority
61. 要显示HSRP路由器的状态:
router# show standby type-number group brief
62. 用命令show ip igmp确定当选的查询器。
63. 启动IP组播路由选择:
router(config)# ip muticast-routing
64. 启动接口上的PIM:
dalllasr1>(config-if)# ip pim {dense-mode|sparse-mode|sparse-dense-mode}
65. 启动稀疏-稠密模式下的PIM:
router# ip multicast-routing
router# interface type number
router# ip pim sparse-dense-mode
66. 核实PIM的配置:
dallasr1># show ip pim interface[type number] [count]
67. 显示PIM邻居:
dallasr1># show ip neighbor type number
68. 为了配置RP的地址,命令如下:
dallasr1># ip pim rp-address ip-address [group-access-list-number][override]
69. 选择一个默认的RP:
dallasr1># ip pim rp-address
通告RP和它所服务的组范围:
dallasr1># ip pim send-rp-announce type number scope ttl group-list access-list-number
为管理范围组通告RP的地址:
dallasr1># ip pim send-rp-announce ethernet0 scope 16 group-list1
dallasr1># access-list 1 permit 266.0.0.0 0.255.255.255
设定一个RP映像代理:
dallasr1># ip pim send-rp-discovery scope ttl
核实组到RP的映像:
dallasr1># show ip pim rp mapping
dallasr1># show ip pim rp [group-name|group-address] [mapping]
70. 在路由器接口上用命令ip multicast ttl-threshold ttl-value设定TTL阀值:
dallasr1>(config-if)# ip multicast ttl-threshold ttl-value
71. 用show ip pim neighbor显示PIM邻居表。
72. 显示组播通信路由表中的各条记录:
dallasr1>show ip mroute [group-name|group-address][scoure][summary][count][active kbps]
73. 要记录一个路由器接受和发送的全部IP组播包:
dallasr1> #debug ip mpacket [detail] [access-list][group]
74. 要在CISCO路由器上配置CGMP:
dallasr1>(config-if)# ip cgmp
75.配置一个组播路由器,使之加入某一个特定的组播组:
dallasr1>(config-if)# ip igmp join-group group-address
76. 关闭 CGMP:
dallasr1>(config-if)# no ip cgmp
77. 启动交换机上的CGMP:
dallasr1>(enable) set cgmp enable
78. 核实Catalyst交换机上CGMP的配置情况:
catalystla1>(enable) show config
set prompt catalystla1>
set interface sc0 192.168.1.1 255.255.255.0
set cgmp enable
79. CGMP离开的设置:
Dallas_SW(enable) set cgmp leave
80. 在Cisco设备上修改控制端口密码:
R1(config)# line console 0
R1(config-line)# login
R1(config-line)# password Lisbon
R1(config)# enable password Lilbao
R1(config)# login local
R1(config)# username student password cisco
81. 在Cisco设备上设置控制台及vty端口的会话超时:
R1(config)# line console 0
R1(config-line)# exec-timeout 5 10
R1(config)# line vty 0 4
R1(config-line)# exec-timeout 5 2
82. 在Cisco设备上设定特权级:
R1(config)# privilege configure level 3 username
R1(config)# privilege configure level 3 copy run start
R1(config)# privilege configure level 3 ping
R1(config)# privilege configure level 3 show run
R1(config)# enable secret level 3 cisco
83. 使用命令privilege 可定义在该特权级下使用的命令:
router(config)# privilege mode level level command
84. 设定用户特权级:
router(config)# enable secret level 3 dallas
router(config)# enable secret san-fran
router(config)# username student password cisco
85. 标志设置与显示:
R1(config)# banner motd ‘unauthorized access will be prosecuted!’
86. 设置vty访问:
R1(config)# access-list 1 permit 192.168.2.5
R1(config)# line vty 0 4
R1(config)# access-class 1 in
87. 配置HTTP访问:
Router3(config)# access-list 1 permit 192.168.10.7
Router3(config)# ip http sever
Router3(config)# ip http access-class 1
Router3(config)# ip http authentication local
Router3(config)# username student password cisco
88. 要启用HTTP访问,请键入以下命令:
switch(config)# ip http sever
89. 在基于set命令的交换机上用setCL1启动和核实端口安全:
switch(enable) set port security mod_num/port_num…enable mac address
switch(enable) show port mod_num/port_num
在基于CiscoIOS命令的交换机上启动和核实端口安全:
switch(config-if)# port secure [mac-mac-count maximum-MAC-count]
switch# show mac-address-table security [type module/port]
90. 用命令access-list在标准通信量过滤表中创建一条记录:
Router(config)# access-list access-list-number {permit|deny} source-address [source-address]
91. 用命令access-list在扩展通信量过滤表中创建一条记录:
Router(config)# access-list access-list-number {permit|deny{protocol|protocol-keyword}}{source source-wildcard|any}{destination destination-wildcard|any}[protocol-specific options][log]
92. 对于带内路由更新,配置路由更新的最基本的命令格式是:
R1(config-router)#distribute-list access-list-number|name in [type number]
93. 对于带外路由更新,配置路由更新的最基本的命令格式是:
R1(config-router)#distribute-list access-list-number|name out [interface-name] routing-process| autonomous-system-number
94. set snmp命令选项:
set snmp community {read-only|ready-write|read-write-all}[community_string]
95. set snmp trap 命令格式如下:
set snmp trap {enable|disable}
[all|moudle|classis|bridge|repeater| auth|vtp|ippermit|vmps|config|entity|stpx]
set snmp trap rvcr_addr rcvr_community
96. 启用SNMP chassis 陷阱:
Console>(enable) set snmp trap enable chassis
97. 启用所有SNMP chassis 陷阱:
Console>(enable) set snmp trap enable
98. 禁用SNMP chassis 陷阱:
Console>(enable) set snmp trap disable chassis
99. 给SNMP陷阱接收表加一条记录:
Console>(enable) set snmp trap 192.122.173.42 public
100. show snmp 输出结果。
101. 命令set snmp rmon enable 的输出结果。
102. 显示SPAN信息:
Consile> show span

一、交换机部分
1.创立、删除VLAN
注意:在配置状态(config)下进行配置。
创建vlan:
switch(config)#vlan vlan-id
命名vlan:
switch(config-vlan)#name vlan-name
或者在database状态下创建并且命名vlan:
switch#vlan database
switch(vlan)#vlan vlan-id name vlan-name
删除vlan:
switch(config-vlan):no vlan vlan-id
switch(vlan)#no vlan vlan-id
查看vlan:
switch#show vlan
switch#show vlan brief
保存设置:
switch#copy running-config startup-config
2.在VLAN中添加、删除端口
注意:进入要分配的端口,在端口状态下。
定义二层端口:
switch(config-if)#swtichport mode access
把端口分配给VLAN:
switch(config-if)#switchport access vlan vlan-id
查看端口的VLAN配置情况:
switch#show interface interface-id switchport
3.在交换机上配置Trunk
注意:在接口状态下进行配置。
自动协商是否成为中继端口:
switch(config-if)#switchport mode dynamic auto
把端口设置为中继端口并进行主动协商:
switch(config-if)#switchport mode dynamic desirable
把端口设置为强制中继端口:
switch(config-if)#switchport mode dynamic trunk
将端口设定为永久中继模式,但关闭协商机制:
switch(config-if)#switchport nonegotiate
查看有关switchport的设置:
switch#show interface interface-id switchport
4.从Trunk中添加、删除VLAN
注意:在端口配置状态下进行配置,并且端口是中继状态。
将端口配置为中继端口:
switch(config-if)#switchport mode trunk
在Trunk中删除一个VLAN:
switch(config-if)#switchport trunk allowed vlan remove vlan-id
在Trunk中添加一个VLAN:
switch(config-if)#switchport trunk allowed vlan add vlan-id
5.在交换机上配置Channel(以太通道):
注意:在接口模式下配置,并且配置Channel的接口必须是相连的,通道两边要在同一个组中。
如果使用PAgP协议:
选择需要配置Channel的端口,进入虚拟接口配置:
switch(config)#interface range fasternet0/1 - 2
被动协商配置channel:
switch(config-if)#channel-group channel-group-number mode auto
主动协商配置Channel:
switch(config-if)#channel-group channel-group-number mode desirable
将端口总是捆绑为一个以太通道,不发生协商:
switch(config-if)#channel-group channel-group-number mode on
如果使用LACP协议,配置如下:
被动协商配置channel:
switch(config-if)#channel-group channel-group-number mode passive
主动协商配置Channel:
switch(config-if)#channel-group channel-group-number mode active
查看Channel配置:
switch#show etherchannel channel-group-number summary
6.指定在组成Channel的链路之间实现负载均衡技术:
注意:dst-mac、src-mac参数用来指定基于目的mac还是源mac实现负载均衡。
在已经组成的Channel中实现基于目的地址的负载均衡:
switch(config-if)#port-channel load-balance dst-mac
在已经组成的Channel中实现基于源地址的负载均衡:
switch(config-if)#port-channel load-balance src-mac
查看负载均衡的配置:
switch#show etherchannel load-balance
查看PAgP的状态信息:
switch#show pagp channelgroup-number counters
7.创建VTP域和配置命令:
注意:在配置状态下。
创建一个VTP域:
swtich(config)#vtp domain domain-name
配置VTP服务器模式:
switch(config)#vtp mode server
配置VTP客户端模式:
switch(config)#vtp mode client
配置VTP透明模式:
switch(config)#vtp mode transparent
配置VTP域口令:
switch(config)#vtp password mypassword
在整个域内启动VTP修剪:
switch(config)#vtp pruning
从可修剪列表中去除VLAN:
switch(config)#switchport trunk pruning vlan remove vlan-id
查看VTP的修剪配置:
switch#show vtp status
switch#show interface interface-id switchport
VTP版本的配置(默认情况下使用的是version 1):
switch(config)#vtp version 2
8.Spanning-tree的配置:
注意:在配置模式下操作。
在VLAN上启用生成树:
switch(config)#spanning-tree vlan vlan-id
查看Spanning-tree配置:
switch#show spanning-tree summary
查看Spanning-tree的详细状态信息:
switch#show spanning-tree vlan vlan-id detail
使用命令建立根网桥:
switch(config)#spanning-tree vlan vlan-id root primary
使用命令建立备用根网桥(当根桥故障的时候,自动成为根桥):
switch(config)#spanning-tree vlan vlan-id root secondary
使用命令修改优先级配置根网桥(取值范围0-65535):
switch(config)#spanning-tree vlan vlan-id priority bridge-priority
在接口模式下使用命令修改端口成本(取值范围0-200000000,如果不指定VLAN则修改所有VLAN的端口成本):
switch(config-if)#spanning-tree vlan vlan-id cost cost
在接口模式下使用命令修改端口优先级(取值范围0-255):
switch(config-if)#spanning-tree vlan vlan-id port-priority priority
查看配置:
switch#show spanning-tree interface interface-id detail
9.修改Spanning-tree计时器:
注意:在配置模式下修改。
修改HELLO时间(缺省2秒,最大10秒):
switch(config)#spanning-tree vlan vlan-id hello-time seconds
修改转发延迟计时器(缺省15秒,取值范围4-30):
switch(config)#spanning-tree vlan vlan-id forward-time seconds
修改最大老化时间(缺省20秒,取值范围6-40):
switch(config)#spanning-tree vlan vlan-id max-age seconds
查看配置:
switch#show spanning-tree vlan vlan-id
10.速端口和上行速链路的配置:
注意:速端口在接口模式下配置,上行速链路在配置模式下配置。
启用速端口(配置在连接到终端PC机的接口):
switch(config-if)#spanning-tree portfast
上行速链路的配置(已经配置了网桥优先级的VLAN不能配置上行速链路):
恢复VLAN的缺省值:
switch(config)#no spanning-tree vlan vlan-id priority
配置上行速链路(pkts-per-second缺省150,取值范围0-32000):
switch(config)#spanning-tree uplinkfast max-updata-rate pkts-seconds
查看上行速链路的配置:
switch#show spanning-tree summary
二、路由器部分
1.静态路由的配置:
注意:在配置模式下。
普通静态路由的配置:
router(config)#ip route 目的地址 目的地址的掩码 下一条地址
浮动静态路由的配置(在普通静态路由命令的最后加上管理距离,通常与普通静态路由的配置一起使用,当普通静态路由出现故障,浮动静态路由便开始工作):
router(config)#ip route 目的地址 目的地址的掩码 下一条地址 50
等价路由(不写管理距离,写两条普通静态路由,当其中一条通静态路由出现故障,另一条静态路由便开始工作):
router(config)#ip route 目的地址 目的地址的掩码 下一条地址
2.动态路由RIP-v1的配置:
注意:在配置模式下配置,RIP-v1是有类路由,不能携带子网掩码,因此如果被打断,需要使用辅助地址。
启动RIP进程:
router(config)#router rip
指定每一个需要运行rip协议的主网络:
router(config-router)#network 每一条直连地址
3.配置Passive端口(指定一条链路不启用RIP协议):
router(config-router)#passive-interface-id
4.单播更新的配置(对相连的一条串行链路进行有选择的RIP协议配置):
首先将端口配置为Passive:
router(config-router)#passive-interface-id
然后选择要进行rip协议的邻居设备:
router(config-router)#neighbor 与邻居的直连地址
5.不连续的子网:
注意:不连续的子网,指以最两边的地址为正常IP段被中间的另一IP段打断,需要在中间的另一IP段配置与原IP段相符的辅助地址,并且network也要做辅助地址的rip。
在接口模式中配置辅助地址(要与被打断的IP段相符):
router(config-if)#ip address IP地址 子网掩码 secondary
6.RIP不同版本的配置:
注意:RIP-v2是无类路由,在传送过程中携带子网掩码,不存在被打断的问题,也不需要辅助地址,并且使用组播方式通告消息到目的地址224.0.0.9。
RIP-v1的配置(缺省version 1):
router(config-)#router rip
RIP-v2的配置:
router(config-)#router rip
router(config-router)#version 2
7.RIP-v2与RIP-v1相结合(使用send version和receive version命令指定发送和接受的时候所使用的版本):
注意:在接口模式下配置,并且两端相连的端口收发标准要相符。
使用version 1收发:
router(config-if)#ip rip send version 1
router(config-if)#ip rip receive version 1
使用version 2收发:
router(config-if)#ip rip send version 2
router(config-if)#ip rip receive version 2
同时使用version 1 2收发:
router(config-if)#ip rip send version 1 2
router(config-if)#ip rip receive version 1 2
8.关闭水平分割:
注意:在接口模式下操作,水平分隔在RIP协议用来防止路由环。
router(config-if)#no ip split-horizon
9.不连续的子网和无类路由如何使被通告的子网通过主网络边界(RIP-v1与RIP-v2一样,缺省行为要在主网络边界上进行路由汇总,因此要关闭路由汇总功能以便允许被通告的子网通过主网络边界):
router(config-router)#no auto-summary
10.OSPF的配置:
注意:在配置模式下,注意配置的直连主网络段所在的area(区域)。
启动OSPF进程:
router(config)#router ospf 进程号
配置主网络和区域:
router(config)#network 主机地址 0.0.0.0 area area-id
router(config)#network 网段 反子网掩码 area area-id
查看OSPF配置DNS实现routerID到名称的映射:
router#show ip ospf neighbor
11.OSPF的辅助地址:
12.特殊的OSPF配置:
注意:由于各种特殊情况的出现,需要及时调整所受到影响的区域设备或者是边界设备配置。
配置STUB区域(一个区域内都要做配置):
router(config)#area area-id stub
修改ABR的代价值(只有当不止一个ABR并且一台ABR故障的时候才有意义):
router(config)#area area-id default-cost cost
配置TOTALLY STUB(直在ABR做配置,其他同区域设备只做STUB):
router(config)#area area-id stub no-summary
13.配置NSSA区域:
注意:连接外部AS的时候才会用到,也就是说连接一个不是OSPF的区域,那么需要配置静态路由或者RIP。
重注入(在ASBR上操作):
router(config)#redistribute rip metric 10
配置NSSA区域(区域内都要配置):
router(config)#area area-id nssa
配置TOTALLY NSSA区域(只当一个设备同时成为ABR与ASBR的时候,才需要做这样的配置,只在该设备所配置即可,其它同区域设备为普通NSSA):
router(config)#area area-id nssa no-summary
14.解决去除了no-summary之后,ABR不在发送LSA类型3的缺省路由,因此外部网络无法从NSS区域内部到达的问题:
注意:其中(no-redistribution表示没有重注入),(default-information-originate表示通告一条缺省路由到NSSA区域,此时LSA3457类型都NO掉)。
router(config)#area area-id nssa no-redistribution default-information-originate
15.地址汇总:
注意:在OSPF上配置地址汇总时,最好在ABR上增加一条指向null0口的默认路由,防止路由回环。
router(config)#area area-id range 汇总的地址段和掩码
router(config)#ip route 汇总的地址段和掩码 Null0
16.虚链路:
注意:虚链路总是建立在ABR路由器之间的,至少它们之中有一个ABR路尤其是必须和区域0相连的,并且虚链路的两端,都必须做指向对方的虚链路配置。
routerA(config)#area area-id virtual-link B地址
routerB(config)#area area-id virtual-link A地址
17.HSRP(热备份路由)的配置:
注意:在接口模式下配置,HSRP需要产生一个虚拟路由,并且一个组内,只能产生一个虚拟路由。
将路由器配置为HSRP的成员(一个组内的路由要指定同一个虚拟路由地址):
router(config-if)#standby group-number 虚拟路由地址
配置HSRP的优先级(缺省100,取值范围:0-255):
router(config-if)#standby group-number priority 优先级
配置HSRP的占先权(当路由恢复工作的时候,依靠占先权重新得到活跃路由的身份):
router(config-if)#standby group-number preempt
配置HSRP中HELLO消息的计时器(缺省3秒,取值范围1-255,hello-interval表示保持时间,holdtime表示老化时间):
router(config-if)#standby group-number times hello-interval holdtime
配置HSRP的端口跟踪(在入口跟踪出口,并需要配置一旦发现出口故障时需要降低的优先级,缺省降低10):
router(config-if)#standby group-number track 要跟踪的端口 interface-priority
关闭端口跟踪:
router(config-if)#no standby group-number track
查看HSRP的详细信息:
router#show standby
查看HSRP的状态(type-number指要显示的端口类型或者端口号,group指配置的HSRP组):
router#show standby type-number group brief
18.标准ACL(访问控制列表)的配置(越是要求严谨的越要放在前面,命令从上到下执行):
注意:在配置模式下操作,配置结束后,一定要在出口或者入口执行ACL,标准访问控制列表的表号为1-99,只能根据源地址进行控制。
配置允许的标准ACL(source为源地址,可以是主机地址,也可以是一个网段):
router(config)#access-list access-list-number permit source
配置拒绝的标准ACL:
router(config)#access-list access-list-number deny source
查看ACL中的内容:
router#show access-list
在入口应用ACL(在接口模式):
router(config-if)#ip access-group group-number in
在出口应用ACL(在接口模式):
router(config-if)#ip access-group group-number out
19.扩展ACL的应用(扩展访问列表的表号为100-199,扩展访问列表可以根据源和目标以及协议和端口进行配置):
注意:在配置模式下操作(source & destination指源地址和目的地址,operator port指大于或小于或等于或不等于一个端口号,log指生成日志)。
router(config)#access-list access-list-number [permit/deny] protocol [source source-wildcard destination destination-wildcard] [operator port] [established] [log]
应用扩展ACL:
在入口应用ACL(在接口模式):
router(config-if)#ip access-group group-number in
在出口应用ACL(在接口模式):
router(config-if)#ip access-group group-number out
命名ACL(standard标准;extended扩展):
router(config)#ip access-list [standard/extended] name
举例:创建拒绝来自172.16.4.0去往172.16.3.0的FTP流量的ACL,并且应用到街口的出方向。
router(config)#access-list 101 deny tcp 172.16.4.0 0.0.0.255 172.16.3.0 0.0.0.255 eq 21
router(config)#access-list 101 permit ip any any
router(config)#ip access-group 101 out
20.NAT/PAT(网络地址转换)的配置:
静态NAT的配置(在配置模式下操作,在内部局部地址内部全局地址之间建立静态地址转换):
router(config)#ip nat inside source static 内部局部地址 内部全局地址
在内部和外部端口上启用NAT(依据实际情况选择入口和出口):
router(config-if)#ip nat outside
router(config-if)#ip nat inside
查看NAT配置:
router#show ip nat translations
21.动态NAT配置(需要结合使用ACL,允许一个段访问地址池):
定义合法IP地址池:
router(config)#ip nat pool 地址池名称 起始地址 中止地址 netmask 子网掩码
实现网络地址转换(在配置模式中,将由access-list制定的内部局部地址与指定的内部全局地址池进行地址转换):
router(config)#ip nat inside source list 访问列表标号 pool 内部全局地址池名字
在内部和外部端口上启用NAT(依据实际情况选择入口和出口):
router(config-if)#ip nat outside
router(config-if)#ip nat inside
22.PAT的配置(需要结合使用ACL,允许一个段访问地址):
设置复用动态IP地址转换:
router(config)#ip nat inside source list 访问列表标号 pool 内部全局地址池名字 overload
以端口复用方式,将访问控制列表1中的局部地址转换为onlyone地址池中定义的全局IP地址:
router(config)#ip nat inside source list 1 pool onlyone overload
在全局配置模式中,设置在内部的本地地址与内部合法地址IP地址之间建立动态地址转换:
router(config)#ip nat inside source list 1 interface interface-id overload
23.TCP负载均衡配置:
举例:
假定有3个服务器10.1.1.1、10.1.1.2和10.1.1.3,使用一个虚拟主机10.1.1.127来代表这个服务器组。要求利用NAT技术在三个服务器之间实现负载平衡。
设置外部端口的IP地址:
router(config-if)#ip address 172.20.7.1 255.255.255.224
设置内部端口:
router(config-if)#ip address 10.1.1.254 255.255.255.0
为虚拟主机定义一个标准的IP访问列表:
router(config)#access-list 2 permit 10.1.1.127
给真实主机定义一个NAT地址集:
router(config)#ip nat pool real-host 10.1.1.1 10.1.1.3 prefix-length 24 type rotary
此命令表示:真实主机地址从10.1.1.1到10.1.1.3,网络前缀长度为24,且该地址集为循环型。
设置访问控制列表与NAT地址集之间的映射:
router(config)#ip nat inside destination list 2 pool real-host
在内部和外部端口上启用NAT:
router(config-if)#ip nat outside
router(config-if)#ip nat inside
该步骤完成后,对要求与虚拟主机连接的请求,NAT将让真实主机组中的主机轮流响应。
24.用NAT解决地址交叉的问题
使用DNS+动态NAT处理地址交叉的配置
举例:
假设内部和外部局域网使用的IP地址范围同为10.1.1.1-10.1.1.254,路由器内部局域网端口(默认网关)的IP地址是10.1.1.254,子网掩码为255.255.255.0。网络分配的内部全局IP地址范围为192.2.2.1-192.2.2.254,外部局部IP地址范围为193.3.3.1到193.3.3.254。路由器在广域网的地址是172.69.232.182,子网掩码是255.255.255.240。
要配置交叉地址空间转换,需要完成下列步骤:
设置外部端口的IP地址:
router(config-if)#ip address 172.69.232.182 255.255.255.240
设置内部端口的IP地址:
router(config-if)#ip address 10.1.1.254 255.255.255.0
定义网络中允许访问外部网络的地址段:
router(config)#access-list 1 permit 10.1.1.0 0.0.0.255
这个命令定义了需要进行地址转换的网段。
若想允许多个地址段访问外部网络,只需反复使用上面命令定义即可。
定义合法IP地址池:
router(config)#ip nat pool net-2 192.2.2.1 192.2.2.254 prefix-length 24
router(config)#ip nat pool net-10 192.3.3.1 192.3.3.254 prefix-length 24
第一条命令定义了内部全局地址集,第二条命令定义了外部局部地址集。
指定网络地址转换映射:
router(config)#ip nat inside source list 1 pool net-2
router(config)#ip nat outside source list 1 pool net-10
第一条语句定义把内部局部地址转换到内部全局地址,这个转换使用地址池net-2。
第二条语句定义了把外部全局地址转换成外部局部地址,这个转换使用地址池net-10。
在内部和外部端口上启用NAT:
在内部和外部端口上启用NAT:
router(config-if)#ip nat outside
router(config-if)#ip nat inside
当内部主机向外部主机发送了一个IP包后,就可以使用show ip nat translations查看连接。
-------------------------------------------------------------------------------