文章标签 ‘Switch’
SWITCH 命令大全
1.在基于IOS的交换机上设置主机名/系统名:
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 vla
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
switch(enable) set system name name-string
switch(config)# enable password level 1 password
switch(enable) set password
switch(enable) set enalbepas
switch(config)# interface vlan 1
switch(config-if)# ip address ip-address netmask
switch(config-if)# ip default-gateway ip-address
switch(enable) set interface sc0 ip-address netmask broadcast-address
switch(enable) set interface sc0 vlan
switch(enable) set ip route default gateway
switch(config-if)# cdp enable
switch(config-if)# no cdp enable
switch# show cdp interface [type modle/port]
switch# show cdp neighbors [type module/port] [detail]
switch(enable) set cdp {enable|disable} module/port
switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilities|detail]
switch(config-if)# description description-string
switch(enable)set port name module/number description-string
switch(config-if)# speed{10|100|auto}
switch(enable) set port speed moudle/number {10|100|auto}
switch(enable) set port speed moudle/number {4|16|auto}
switch(config-if)# duplex {auto|full|half}
switch(enable) set port duplex module/number {full|half}
switch# vlan database
switch(vlan)# vlan vlan-num name vla
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
switch(enable) set vlan vlan-num [name name]
switch(enable) set vlan vlan-num mod-num/port-list
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
switch(enable) set trunk module/port [on|off|desirable|auto|nonegotiate]
Vlan-range [isl|dotlq|dotl0|lane|negotiate]
switch# vlan database
switch(vlan)# vtp domain domain-name
switch(enable) set vtp [domain domain-name]
switch# vlan database
switch(vlan)# vtp domain domain-name
switch(vlan)# vtp {sever|cilent|transparent}
switch(vlan)# vtp password password
switch(enable) set vtp [domain domain-name] [mode{ sever|cilent|transparent }][password passwor
switch# vlan database
switch(vlan)# vtp v2-mode
switch(enable) set vtp v2 enable
switch# vlan database
switch(vlan)# vtp pruning
switch(enable) set vtp pruning enable
switch(config-if)# port group group-number [distribution {source|destination}]
switch(enable) set port channel moudle/port-range mode{on|off|desirable|auto}
switch(config-if)# spanning-tree [vlan vlan-list] cost cost
switch(enable) set spantree portcost moudle/port cost
switch(enable) set spantree portvlancost moudle/port [cost cost][vlan-list]
switch(config-if)# spanning-tree[vlan vlan-list]port-priority port-priority
switch(enable) set spantree portpri {mldule/port}priority
switch(enable) set spantree portvlanpri {module/port}priority [vlans]
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
switch(enable) set spantree hello interval[vlan]
switch(enable) set spantree fwddelay delay [vlan]
switch(enable) set spantree maxage agingtiame[vlan]
switch(config-if)#spanning-tree portf
switch(enable) set spantree portfast {module/port}{enable|disable}
switch(config)# spanning-tree uplinkfast [max-update-rate pkts-per-second]
switch(enable) set spantree uplinkfast {enable|disable}[rate update-rate] [all-protocols off|on]
witch(config)# cluster enable cluster-name
switch(enable) clear trunk module/port vlan-range
switch(enable) set vlan vlan-name [name name] type trbrf bridge bridge-num[stp {ieee|ibm}]
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
二层交换技术是发展比较成熟,二层交换机属数据链路层设备,可以识别数据包中的MAC地址信息,根据MAC地址进行转发,并将这些MAC地址与对应的端口记录在自己内部的一个地址表中。具体的工作流程如下:
(1) 当交换机从某个端口收到一个数据包,它先读取包头中的源MAC地址,这样它就知道源MAC地址的机器是连在哪个端口上的;>
(2) 再去读取包头中的目的MAC地址,并在地址表中查找相应的端口;
(3) 如表中有与这目的MAC地址对应的端口,把数据包直接复制到这端口上;
(4) 如表中找不到相应的端口则把数据包广播到所有端口上,当目的机器对源机器回应时,交换机又可以学习一目的MAC地址与哪个端口对应,在下次传送数据时就不再需要对所有端口进行广播了。
不断的循环这个过程,对于全网的MAC地址信息都可以学习到,二层交换机就是这样建立和维护它自己的地址表。
从二层交换机的工作原理可以推知以下三点:
(1) 由于交换机对多数端口的数据进行同时交换,这就要求具有很宽的交换总线带宽,如果二层交换机有N个端口,每个端口的带宽是M,交换机总线带宽超过N×M,那么这交换机就可以实现线速交换;
(2) 学习端口连接的机器的MAC地址,写入地址表,地址表的大小(一般两种表示方式:一为BEFFER RAM,一为MAC表项数值),地址表大小影响交换机的接入容量;
(3) 还有一个就是二层交换机一般都含有专门用于处理数据包转发的ASIC (Application specific Integrated Circuit)芯片,因此转发速度可以做到非常快。由于各个厂家采用ASIC不同,直接影响产品性能。
以上三点也是评判二三层交换机性能优劣的主要技术参数,这一点请大家在考虑设备选型时注意比较。
路由技术
路由器工作在OSI模型的第三层---网络层操作,其工作模式与二层交换相似,但路由器工作在第三层,这个区别决定了路由和交换在传递包时使用不同的控制信息,实现功能的方式就不同。工作原理是在路由器的内部也有一个表,这个表所标示的是如果要去某一个地方,下一步应该向那里走,如果能从路由表中找到数据包下一步往那里走,把链路层信息加上转发出去;如果不能知道下一步走向那里,则将此包丢弃,然后返回一个信息交给源地址。
路由技术实质上来说不过两种功能:决定最优路由和转发数据包。路由表中写入各种信息,由路由算法计算出到达目的地址的最佳路径,然后由相对简单直接的转发机制发送数据包。接受数据的下一台路由器依照相同的工作方式继续转发,依次类推,直到数据包到达目的路由器。
而路由表的维护,也有两种不同的方式。一种是路由信息的更新,将部分或者全部的路由信息公布出去,路由器通过互相学习路由信息,就掌握了全网的拓扑结构,这一类的路由协议称为距离矢量路由协议;另一种是路由器将自己的链路状态信息进行广播,通过互相学习掌握全网的路由信息,进而计算出最佳的转发路径,这类路由协议称为链路状态路由协议。
由于路由器需要做大量的路径计算工作,一般处理器的工作能力直接决定其性能的优劣。当然这一判断还是对中低端路由器而言,因为高端路由器往往采用分布式处理系统体系设计。
三层交换技术
近年来的对三层技术的宣传,耳朵都能起茧子,到处都在喊三层技术,有人说这是个非常新的技术,也有人说,三层交换嘛,不就是路由器和二层交换机的堆叠,也没有什么新的玩意,事实果真如此吗?下面先来通过一个简单的网络来看看三层交换机的工作过程。
组网比较简单
使用IP的设备A------------------------三层交换机------------------------使用IP的设备B
比如A要给B发送数据,已知目的IP,那么A就用子网掩码取得网络地址,判断目的IP是否与自己在同一网段。
如果在同一网段,但不知道转发数据所需的MAC地址,A就发送一个ARP请求,B返回其MAC地址,A用此MAC封装数据包并发送给交换机,交换机起用二层交换模块,查找MAC地址表,将数据包转发到相应的端口。
如果目的IP地址显示不是同一网段的,那么A要实现和B的通讯,在流缓存条目中没有对应MAC地址条目,就将第一个正常数据包发送向一个缺省网关,这个缺省网关一般在操作系统中已经设好,对应第三层路由模块,所以可见对于不是同一子网的数据,最先在MAC表中放的是缺省网关的MAC地址;然后就由三层模块接收到此数据包,查询路由表以确定到达B的路由,将构造一个新的帧头,其中以缺省网关的MAC地址为源MAC地址,以主机B的MAC地址为目的MAC地址。通过一定的识别触发机制,确立主机A与B的MAC地址及转发端口的对应关系,并记录进流缓存条目表,以后的A到B的数据,就直接交由二层交换模块完成。这就通常所说的一次路由多次转发。
以上就是三层交换机工作过程的简单概括,可以看出三层交换的特点:
由硬件结合实现数据的高速转发。
这就不是简单的二层交换机和路由器的叠加,三层路由模块直接叠加在二层交换的高速背板总线上,突破了传统路由器的接口速率限制,速率可达几十Gbit/s。算上背板带宽,这些是三层交换机性能的两个重要参数。
简洁的路由软件使路由过程简化。
大部分的数据转发,除了必要的路由选择交由路由软件处理,都是又二层模块高速转发,
路由软件大多都是经过处理的高效优化软件,并不是简单照搬路由器中的软件。
结论
二层交换机用于小型的局域网络。这个就不用多言了,在小型局域网中,广播包影响不大,二层交换机的快速交换功能、多个接入端口和低谦价格为小型网络用户提供了很完善的解决方案。
路由器的优点在于接口类型丰富,支持的三层功能强大,路由能力强大,适合用于大型的网络间的路由,它的优势在于选择最佳路由,负荷分担,链路备份及和其他网络进行路由信息的交换等等路由器所具有功能。
三层交换机的最重要的功能是加快大型局域网络内部的数据的快速转发,加入路由功能也是为这个目的服务的。如果把大型网络按照部门,地域等等因素划分成一个个小局域网,这将导致大量的网际互访,单纯的使用二层交换机不能实现网际互访;如单纯的使用路由器,由于接口数量有限和路由转发速度慢,将限制网络的速度和网络规模,采用具有路由功能的快速转发的三层交换机就成为首选。
一般来说,在内网数据流量大,要求快速转发响应的网络中,如全部由三层交换机来做这个工作,会造成三层交换机负担过重,响应速度受影响,将网间的路由交由路由器去完成,充分发挥不同设备的优点,不失为一种好的组网策略,当然,前提是客户的腰包很鼓,不然就退而求其次,让三层交换机也兼为网际互连。
第四层交换的一个简单定义是:它是一种功能,它决定传输不仅仅依据MAC地址(第二层网桥)或源/目标IP地址(第三层路由),而且依据TCP/UDP(第四层) 应用端口号。第四层交换功能就象是虚IP,指向物理服务器。它传输的业务服从的协议多种多样,有HTTP、FTP、NFS、Telnet或其他协议。这些业务在物理服务器基础上,需要复杂的载量平衡算法。在IP世界,业务类型由终端TCP或UDP端口地址来决定,在第四层交换中的应用区间则由源端和终端IP地址、TCP和UDP端口共同决定。
在第四层交换中为每个供搜寻使用的服务器组设立虚IP地址(VIP),每组服务器支持某种应用。在域名服务器(DNS)中存储的每个应用服务器地址是VIP,而不是真实的服务器地址。
当某用户申请应用时,一个带有目标服务器组的VIP连接请求(例如一个TCP SYN包)发给服务器交换机。服务器交换机在组中选取最好的服务器,将终端地址中的VIP用实际服务器的IP取代,并将连接请求传给服务器。这样,同一区间所有的包由服务器交换机进行映射,在用户和同一服务器间进行传输。
第四层交换的原理
OSI模型的第四层是传输层。传输层负责端对端通信,即在网络源和目标系统之间协调通信。在IP协议栈中这是TCP(一种传输协议)和UDP(用户数据包协议)所在的协议层。
在第四层中,TCP和UDP标题包含端口号(portnumber),它们可以唯一区分每个数据包包含哪些应用协议(例如HTTP、FTP等)。端点系统利用这种信息来区分包中的数据,尤其是端口号使一个接收端计算机系统能够确定它所收到的IP包类型,并把它交给合适的高层软件。端口号和设备IP地址的组合通常称作“插口(socket)”。
1和255之间的端口号被保留,他们称为“熟知”端口,也就是说,在所有主机TCP/IP协议栈实现中,这些端口号是相同的。除了“熟知”端口外,标准UNIX服务分配在256到1024端口范围,定制的应用一般在1024以上分配端口号.
分配端口号的最近清单可以在RFc1700”Assigned Numbers”上找到。TCP/UDP端口号提供的附加信息可以为网络交换机所利用,这是第4层交换的基础。
"熟知"端口号举例:
应用协议 端口号
FTP 20(数据)
21(控制)
TELNET 23
SMTP 25
HTTP 80
NNTP 119
NNMP 16
162(SNMP traps)
TCP/UDP端口号提供的附加信息可以为网络交换机所利用,这是第四层交换的基础。
具有第四层功能的交换机能够起到与服务器相连接的“虚拟IP”(VIP)前端的作用。
每台服务器和支持单一或通用应用的服务器组都配置一个VIP地址。这个VIP地址被发送出去并在域名系统上注册。
在发出一个服务请求时,第四层交换机通过判定TCP开始,来识别一次会话的开始。然后它利用复杂的算法来确定处理这个请求的最佳服务器。一旦做出这种决定,交换机就将会话与一个具体的IP地址联系在一起,并用该服务器真正的IP地址来代替服务器上的VIP地址。
每台第四层交换机都保存一个与被选择的服务器相配的源IP地址以及源TCP 端口相关联的连接表。然后第四层交换机向这台服务器转发连接请求。所有后续包在客户机与服务器之间重新影射和转发,直到交换机发现会话为止。
在使用第四层交换的情况下,接入可以与真正的服务器连接在一起来满足用户制定的规则,诸如使每台服务器上有相等数量的接入或根据不同服务器的容量来分配传输流。
如何选用合适的第四层交换
a,速度
为了在企业网中行之有效,第四层交换必须提供与第三层线速路由器可比拟的性能。也就是说,第四层交换必须在所有端口以全介质速度操作,即使在多个千兆以太网连接上亦如此。千兆以太网速度等于以每秒1488000 个数据包的最大速度路由(假定最坏的情形,即所有包为以及网定义的最小尺寸,长64字节)。
b,服务器容量平衡算法
依据所希望的容量平衡间隔尺寸,第四层交换机将应用分配给服务器的算法有很多种,有简单的检测环路最近的连接、检测环路时延或检测服务器本身的闭环反馈。在所有的预测中,闭环反馈提供反映服务器现有业务量的最精确的检测。
c,表容量
应注意的是,进行第四层交换的交换机需要有区分和存贮大量发送表项的能力。交换机在一个企业网的核心时尤其如此。许多第二/ 三层交换机倾向发送表的大小与网络设备的数量成正比。对第四层交换机,这个数量必须乘以网络中使用的不同应用协议和会话的数量。因而发送表的大小随端点设备和应用类型数量的增长而迅速增长。第四层交换机设计者在设计其产品时需要考虑表的这种增长。大的表容量对制造支持线速发送第四层流量的高性能交换机至关重要.
d,冗余
第四层交换机内部有支持冗余拓扑结构的功能。在具有双链路的网卡容错连接时,就可能建立从一个服务器到网卡,链路和服务器交换器的完全冗余系统。

