交換機命令大全

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查看連接。
-------------------------------------------------------------------------------

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章