交換機命令

交換機命令

交換機命令:
PCA login: root ;使用root用戶
password: linux ;口令是linux
# shutdown -h now ;關機
# init 0 ;關機
# logout
# login
# ifconfig ;顯示IP地址
# ifconfig eth0 <ip address> netmask <netmask> ;設置IP地址
# ifconfig eht0 <ip address> netmask <netmask> down ; 刪除IP地址
# route add 0.0.0.0 gw <ip>
# route del 0.0.0.0 gw <ip>
# route add default gw <ip> ;設置網關
# route del default gw <ip> ;刪除網關
# route ;顯示網關
# ping <ip>
# telnet <ip> ;建立telnet之前先ping一下

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
交換機基本狀態:
switch: ;ROM狀態, 路由器是
rommon>
hostname> ;用戶模式
hostname# ;特權模式
hostname(config)# ;全局配置模式
hostname(config-if)# ; 接口狀態

交換機口令設置:
switch>enable ;進入特權模式
switch#config terminal ;進入全局配置模式
switch(config)#hostname <hostname> ;設置交換機的主機名
switch(config)#enable secret xxx ;設置特權加密口令爲 xxx
switch(config)#enable password xxx ;設置特權非密口令爲 xxx
switch(config)#line console 0 ;進控制檯口(Rs232)初始化
switch(config-line)#line vty 0 4 ;進入虛擬終端virtual tty
switch(config-line)#login ;允許登錄
switch(config-line)#password xx ;設置登錄口令xx
switch#exit ;返回命令

交換機VLAN設置:
switch#vlan database ;進入VLAN設置
switch(vlan)#vlan 2 ;建VLAN 2
switch(vlan)#no vlan 2 ;刪vlan 2
switch(config)#int f0/1 ;進入端口1
switch(config-if)#switchport access vlan 2 ;當前端口1加入VLAN 2
switch(config-if)#switchport mode trunk ;設置爲幹線

交換機設置IP地址:
switch(config)#interface vlan 1 ;進入vlan 1
switch(config-if)#ip address <IP> <mask> ;添加遠程登錄IP
switch(config)#ip default-gateway <IP> ;添加默認網關
switch#dir flash: ;查看內存

交換機顯示命令:
switch#write ;寫入保存
switch#show run ;查看當前配置信息
switch#show vlan ;看VLAN
switch#show interface ;顯示所有端口信息
switch#show int f0/0 ;顯示端口0的信息
switch#reload     ;重新起動

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
路由器顯示命令:
router#show run ;顯示接口
router#show interface ;顯示接口
router#show ip route ;顯示路由
router#show cdp nei ;看阾居

設置口令:
router>enable ;進入特權模式
router#config terminal ;進入全局配置模式
router(config)#hostname <hostname> ;設置交換機的主機名
router(config)#enable secret xxx ;設置特權加密口令爲 xxx
router(config)#enable password xxx ;設置特權非密口令爲 xxx
router(config)#line console 0 ;進控制檯口(Rs232)初始化
router(config-line)#line vty 0 4 ;進入虛擬終端virtual tty
router(config-line)#login ;允許登錄
router(config-line)#password xx ;設置登錄口令xx
router(config)# (Ctrl+z) ; 返回特權模式
router#exit ;返回命令

配置IP地址:
router(config)#int s0/0 ;進行串Serail接口
router(config-if)#no shutdown ;起動接口
router(config-if)#clock rate 64000 ;設置時鐘
router(config-if)#ip address 10.1.1.1 255.255.0.0 ;設置IP地址和子網掩碼
router(config-if)#ip add 10.1.1.2 255.255.0.0 second;
router(config-if)#int f0/0.1 ; 進入子接口
router(config-subif.1)#ip address <ip><netmask> ;
router(config-subif.1)#encapsulation isl <n> ;
router(config)#config-register 0x2142 ;跳過配置文件
router(config)#config-register 0x2102 ;正常使用配置文件
router#reload ;重新引導

複製操作:
router#copy running-config startup-config ;存配置
router#copy running-config tftp ;上載
router#copy startup-config tftp
router#copy tftp flash: ;特權模式下升級IOS
router#copy tftp startup-config          ;下載配置文件到nvram

ROM狀態:
Ctrl+Break ;進入ROM監控狀態
rommon>confreg 0x2142 ;跳過配置,26 36 45xx
rommon>confreg 0x2102 ;使用配置,恢復工作狀態
rommon>reset      ;重新引導,等效於重開機
rommon>copy xmodem:<sname> flash:<dname> ;從console升級IOS

rommon>ip_address=10.65.1.100 ;設置路由器IP (默認端口)
rommon>ip_subnet_mask=255.255.0.0 ;設置路由器掩碼
rommon>tftp_server=10.65.1.48 ;指定TFTP服務器IP
rommon>tftp_file=c2600.T ;所要下載的文件
rommon>tftpdnld ;ROM監控狀態下升級IOS
rommon>dir flash: ;查看閃存中的內容
rommon>boot ;引導IOS

靜態路由:
ip route <ip-address> <subnet-mask> <gateway> 例:
router(config)#ip route 10.1.0.0 255.255.0.0 10.2.1.1
router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2

動態路由:
router(config)#ip routing ;啓動路由
router(config)#router rip ;啓動RIP路由協議。
router(config-router)#network <netid> ;配置範圍,有的支持all。
router(config-router)#negihbor <ip-address> ;點對點 幀中繼用。

幀中繼命令:
router(config)# frame-relay switching ;使能幀中繼交換
router(config-s0)# encapsulation frame-relay ;使能幀中繼
router(config-s0)# frame-relay intf-type DCE ;DCE端(需要配虛電路)
router(config-s0)# frame-relay local-dlci 20 ;配置虛電路號

基本訪問控制列表:
router(config)#access-list <number> permit|deny <source ip> <wild|any>
router(config)#interface <interface> ;default: deny any
router(config-if)#ip access-group <number> in|out ;default: out

例:
RB(config)#access-list 4 permit 10.8.1.1
RB(config)#access-list 4 deny 10.8.1.0 0.0.0.255
RB(config)#access-list 4 permit 10.8.0.0 0.0.255.255
RB(config)#access-list 4 deny 10.0.0.0 0.255.255.255
RB(config)#access-list 4 permit any
RB(config)#int f0/0
RB(config-if)#ip access-group 4 in


擴展訪問控制列表:
access-list <number> permit|deny icmp <SourceIP wild> <destinationIP
wild>[type]
access-list <number> permit|deny tcp <SourceIP wild> <destinationIP
wild>[port]
例1:
router(config)# access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echo
router(config)# access-list 101 permit ip any any
router(config)# int s0/0
router(config-if)#ip access-group 101 in
  
發佈了27 篇原創文章 · 獲贊 7 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章