廣告聯播

2015年11月6日 星期五

Cisco 指令管理筆記

From: Polin Wei


Cisco 常用指令。 
1.
Config# enable password "明碼"
Config# enable Secret "暗碼"
Config# service password-encryption  telnet 密碼加密


2.
Config# line console 0
Config-line# exec-timeout 0 0 ←保持console連線,注意有安全疑慮
Config-line# logging synchronous ←使游標還原到原來位置,重新顯示被覆蓋的命令


3.
# clock rate
DCE 設備的 interface 需設定 clock rate 64000 數字部分看狀況


4.
# sh process cpu ←查看 Process 的 CPU 使用狀態
# sh session ←看telnet的聯接
# clear line [號碼] ←清除telnet連接


5.關閉Debug
# no debug service ←關閉偵測除錯
# no debug all ←關閉所有偵測除錯 


6.
# sh spanning-tree
檢查 switch 上每各 port 為 forwarding 還是 blocking,可在L2上使用


7.
Config# mac-address-table static 1111.1111.1111 fa0/9
設定靜態Mac對應來限制封包從哪些特定來源才能通過
# sh mac-address-table static
8.
Config# mac-address-table secure 1111.1111.1111 fa0/9
設定具有安全性的 mac 是要確保只有特殊設備才能連上指定的 port
# sh mac-address-table secure


9.
# sh port security ←檢查有安全性設定的port
VLAN 實作可參考 http://www.netadmin.com.tw/article_content.aspx?sn=1201100001

10. VTP (VLAN trunking Protocol)
*範圍相同的VTP領域(domain)名稱,而且互相連結在一起的switch
*VTP mode有三種,Server, Transparent, Client
*Server mode可建立、刪除、修改vlan,並進行資訊同步化
*Client mode只可接收被同步化


*設定vlan domain與密碼
# vlan database
(vlan)# vtp domain magic password cisco


*設定VTP模式
 # vlan database
(vlan)# vtp client (or # vtp server)


*顯示 VTP
# sh vtp status


*檢查 VLAN
# sh  vlan
or
# sh  vlan  brief


11.在交換器上設定Vlan
Config-if# int fa0/2
Config-if# switchport access vlan 2
Config-if# int fa0/3
Config-if# switchport access vlan 3
Config-if# int fa0/4
Config-if# switchport access vlan 4


Config# vlan 2-10 ←同時建立 2-10 的vlan
Config-vlan# end
Config# no vlan 2-10 ←同時刪除 2-10 的vlan


注意:只可以同時對一個vlan進行命名


12.
設定 trunk(2960)
Config# int fa0/2
Config-if# switchport mode trunk


設定trunk(3750 or 6509)
Config# int fa0/2
Config-if# switchport mode trunk


設定trunk
Config-if# switchport trunk encapsulation dot1q
1.進入介面配置 Switch(config)
# interface fastethernet 5/8
2.關閉介面
Config-if# shutdown
3.選擇封裝類型
Config-if# switchport trunk encapsulation dot1q
4.配置介面允許通過 VLAN
Config-if# switchport trunk allowed vlan 1,5,11,1002-1005(add,all,except,none,remove)
5.配置界面為trunk
Config-if# switchport mode trunk
6.指定 trunking native vlan
Config-if# switchport trunk native vlan 99
7.Switch(config-if)# switchport nonegotiate
8.啟動介面
Config-if# no shutdown
9.檢查trunk配置
# show interfaces fastEthernet 5/8 switchport
fa5/8
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Off
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 99 (trunk_only)
Trunking VLANs Enabled: 1,5,11,1002-1005
Pruning VLANs Enabled: 2-1001


13.Access Link 允許一個 Vlan 在線路上傳遞資料,Trunk Link 允許一個以上 Vlan 傳遞資料


14.CIDR指的是,192.168.0.1 和192.168.1.1 分別屬於兩各不同的 class C,若要整合進去同一筆,可向前借位,將原來要兩筆192.168.0.0/24,192.168.1.0/24 改成 192.168.0.0/23,打破原來class A, B, C的限制。


15.ip subnet-zero 告訴 Router 打破不能使用第一個與最後一個子網路的規則。


16.想在某一介面下新增第二筆IP,使用
Router(config-if)# ip address 172.16.20.2 255.255.255.0 secondary


17. # sh protocols ←可檢視每各介面的第一層與第二層狀態


18.static route:
# ip route [destination_network]  [mask]  [next-hop_address]
Ex:
(config)# ip route 172.16.3.0 255.255.255.0 192.168.2.4


*使用sh ip route,可看到S標記
# ip route 172.16.3.0(遠端,也就是要去哪個網段) 255.255.255.0 192.168.2.4(下個router ip)


19.
Jan 02 12:59:26 163.25.96.241 134: *Mar  1 01:49:23: %SYS-4-CONFIG_RESOLVE_FAILURE: System config parse from (tftp://255.255.255.255/network-confg) failed
Jan 02 13:00:04 163.25.96.241 135: *Mar  1 01:50:01: %SYS-4-CONFIG_RESOLVE_FAILURE: System config parse from (tftp://255.255.255.255/cisconet.cfg) failed
Jan 02 13:00:42 163.25.96.241 136: *Mar  1 01:50:39: %SYS-4-CONFIG_RESOLVE_FAILURE: System config parse from (tftp://255.255.255.255/eng4f-confg) failed


解決方式:(config)# no service config


20.OSPF設定
# Config t
# router ospf 1 (1無意義,可隨意選數字)
# network 10.1.1.1  0.0.0.0  area  0 (0為區域碼,需相同才能互通)
# network 10.5.2.1  0.0.0.0  area  0


檢查設定指令
# sh  ip  route
# sh  ip  ospf
# sh  ip  ospf  database
# sh  ip  ospf  interface
# sh  ip  ospf  neighbor
# sh  ip  protocols


OSPF debug
# debug ip ospf events
# debug ip ospf packet


21.default route
# ip route 0.0.0.0 0.0.0.0 192.168.1.9(下個router IP,或自身要離開的介面,如s0/0)


使用 default route,必須加上ip classless
另一種寫法
# ip default-network 217.124.6.0
Config# sh ip route 檢查


22.設定 domain server
# ip domain-lookup ←預設即打開,如未使用建議可關閉
# ip name-server 163.25.114.1
# ip domain-name cgu.edu.tw


23.不讓日誌消息打擾你的配置過程
Cisco IOS中另一個我認為的小毛病就是在我配置路由器時,控制臺介面就不斷彈出日誌消息(可能是控制台端口,AUX端口或VTY端口)。要預防這一點,你可以這樣做。所以在每一條端口線路上,我使用日誌同步命令。舉例如下:
Router(config)# line con 0
Router(config-line)# logging synchronous
Router(config)# line aux 0
Router(config-line)# logging synchronous
Router(config)# line vty 0 4
Router(config-line)# logging synchronous


除此之外,你可以在端口上修改這些端口的執行超時時間。例如,我們假設你想禁用 VTY線路上默認的十分鐘超時時間。在線路配置模式下使用 exec-timeout 0 0 命令,使路由器永不退出。


24.備份IOS
Router(config)# copy flash tftp


25. 升級IOS
Router(config)# copy tftp flash

補充:
26. 設定 Port Mirroring
Switch(config)# monitor session 1 source interface gigabitEthernet 0/1 both (source可以是vlan or interface, both表示進出traffic, 也可以單獨, 按?有說明)
Switch(config)# monitor session 1 destination interface gigabitEthernet 0/2 (目的地interface指的是sniffer接的interface)

沒有留言:

張貼留言